my $str = do { local $/; };
Friday, August 31, 2018
Monday, August 27, 2018
Wednesday, August 1, 2018
git: rename a branch
Source: Rename a local and remote branch in git
Rename local branch.
Rename local branch.
git branch -m new-name
Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name
Reset the upstream branch for the new-name local branch.
git push origin -u new-name
Thursday, July 26, 2018
macOS: checking for OpenSSL... configure: error: not found
Source: Problem with openssl on macOS
If your ./configure (e.g. for pgbouncer) terminates with the following error despite openssl being installed:
If your ./configure (e.g. for pgbouncer) terminates with the following error despite openssl being installed:
checking for OpenSSL... configure: error: not found
Then, restart it like follows:
./configure --with-openssl=/usr/local/opt/openssl
macOS: listening ports
Source: How can I list my open network ports with netstat?
[jerome@jeroboam] > sudo lsof -PiTCP -sTCP:LISTEN | grep 6432
pgbouncer 10533 jerome 9u IPv6 0x8678a9be8d9262f5 0t0 TCP *:6432 (LISTEN)
pgbouncer 10533 jerome 10u IPv4 0x8678a9be9e2f23dd 0t0 TCP *:6432 (LISTEN)
Wednesday, July 25, 2018
ssh: ssh a remote host via a bastion
Source: SSH ProxyCommand example: Going through one host to reach another server
In order to reach remote1 through a bastion host, add the following lines in your .ssh/config:
In order to reach remote1 through a bastion host, add the following lines in your .ssh/config:
Host bastion HostName bastion-01.golgoth.com User jgallinari Host remote1 HostName remote1.toto.swir User jgallinari ProxyCommand ssh jgallinari@bastion -W %h:%pThen ssh remote1 should do it.
Friday, July 20, 2018
macOS: find your CPU
[jerome@jeroboam] > sysctl -n machdep.cpu.brand_string
Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Thursday, July 19, 2018
AWS: Using environment variables in CodeBuild buildspec
Source: Using environment variables in AWS CodeBuild buildspec.yml
See S3_BUCKET below, which is first expanded from ImportValue, then used in BuildSpec.
See S3_BUCKET below, which is first expanded from ImportValue, then used in BuildSpec.
AvUsageQuarantineBuildProject:
Type: AWS::CodeBuild::Project
Condition: Preprod
Properties:
Name: av-usage-quarantine-build
ServiceRole: !GetAtt AvUsageQuarantineBuildProjectRole.Arn
Artifacts:
Type: CODEPIPELINE
Name: av-usage-quarantine
Environment:
Type: LINUX_CONTAINER
ComputeType: BUILD_GENERAL1_SMALL
Image: aws/codebuild/java:openjdk-8
EnvironmentVariables:
- Name: S3_BUCKET
Value: !ImportValue delivery-AvDeliveryUtilsBucket
Source:
Type: CODEPIPELINE
BuildSpec: !Sub |
version: 0.2
phases:
install:
commands:
- cd ~; wget https://raw.github.com/technomancy/leiningen/stable/bin/lein; chmod +x lein; mv lein /bin
- LEIN_ROOT=true lein
build:
commands:
- cd $CODEBUILD_SRC_DIR
- LEIN_ROOT=true lein uberjar
post_build:
commands:
- aws cloudformation package --template template.yaml --s3-bucket $S3_BUCKET --s3-prefix lambda --output-template av-usage-quarantine-output-template.yaml
macOS: Terminal follow focus
Source: Set Terminal Focus to Follow the Mouse Cursor in Mac OS X
Follow focus ON
Working on High Sierra 10.13.6.
Follow focus ON
defaults write com.apple.Terminal FocusFollowsMouse -string YES
Follow focus OFF
defaults write com.apple.Terminal FocusFollowsMouse -string NO
Then, restart Terminal.
Working on High Sierra 10.13.6.
AWS: !Sub |
- Understanding AWS CloudFormation !Sub Syntax
- What does “!Sub |” mean in AWS UserData field with YAML syntax?
Q: What does !Sub | mean ?
A: This means that you can enter normal looking text without having to use things like "\n" to mean end of line.
Tuesday, July 17, 2018
Clojure: count truthy occurences
Count truthy occurences
(count (filter identity [nil 1 nil 4 nil])) 2Count falsey occurences
(count (filter #(or (false? %) (nil? %)) [nil 1 false 4 nil])) 3
Saturday, July 14, 2018
macOS: know the previous shutdowns cause
centurion:~ jerome$ log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h Filtering the log data using "eventMessage CONTAINS "Previous shutdown cause"" Skipping info and debug messages, pass --info and/or --debug to include. Timestamp Thread Type Activity PID TTL 2018-07-14 11:14:28.111106+0200 0xe5 Default 0x0 0 0 kernel: (AppleSMC) Previous shutdown cause: 5 2018-07-14 11:32:41.196172+0200 0xe3 Default 0x0 0 0 kernel: (AppleSMC) Previous shutdown cause: 5 -------------------------------------------------------------------------------------------------------------------- Log - Default: 2, Info: 0, Debug: 0, Error: 0, Fault: 0 Activity - Create: 0, Transition: 0, Actions: 0
Tuesday, July 10, 2018
macOS: release C-left, C-right, C-up, C-top for Emacs
On Emacs, I use key bindings for ^↑ (C-up), ^↓ (C-down), ^← (C-left) and ^→ (C-right), but macOS by default maps them to Mission Control. In order to replace ^ with ⌘ for Mission Control shortcuts, use System Preferences > Keyboard > Shortcuts like in
macOS: install Apache2::Request mod_perl module
Sources:
For this, install httpd from homebrew.
So, install it from the Apple Store.
Then, Apache2::Request install will try to have access to multiple Xcode directories that do not exist.
So, create symbolic links and missing directory.
Then update Apache configuration.
- Compile mod_perl for Apache 2.4 on Mac OS X 10.10 Yosemite
- Installing RApache on Mac OS X Snow Leopard
- Apache libapreq2
cpan Apache2::Request
First, we will need apxs (Apache Extension tool).For this, install httpd from homebrew.
brew install httpd
Then, we will need Xcode.So, install it from the Apple Store.
Then, Apache2::Request install will try to have access to multiple Xcode directories that do not exist.
So, create symbolic links and missing directory.
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.13.xctoolchain sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.13.xctoolchain/usr/local/bin/ sudo ln -s /usr/local/bin/apxs /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.13.xctoolchain/usr/local/bin/apsx sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdkThen install libapreq2 library.
- Download libapreq2-2.13.
- Compile libapreq2 sources.
tar xvfz libapreq2-2.13.tar.gz
cd libapreq2-2.13
./configure
make
make install
Then install mod_perl 2.
svn checkout https://svn.apache.org/repos/asf/perl/modperl/trunk/ mod_perl-2.0
cd mod_perl-2.0
perl Makefile.PL MP_CCOPTS=-std=gnu89
make
make install
NB: mod_perl.so and mod_apreq2.so will be installed in /usr/local/lib/httpd/modules.Then update Apache configuration.
vi /usr/local/etc/httpd/httpd.conf
LoadModule perl_module lib/httpd/modules/mod_perl.so
LoadModule apreq_module lib/httpd/modules/mod_apreq2.so
...
ServerName jeroboam:8080
...
PerlSwitches -I /Users/jerome/perl5/lib/perl5
PerlModule Apache::DBI
PerlModule ModPerl::Registry
PerlRequire /Users/jerome/src/connectmv/perl/lib/startup.pl
<Location /hlr_vas/>
SetHandler perl-script
PerlResponseHandler MBQT::mod_perl::HlrVas
</Location>
# PerlSetEnv DBG_FLG 1
Apache restart
/usr/local/bin/apachectl restart
Friday, July 6, 2018
macOS: iconify / deiconify shortcuts
- Iconify: ⌘+M
- Deiconify: ⌘+TAB, then select application, then press ⌥, then, release ⌘
macOS: paste without style
Instead of using ⌘+V , you can press ⌥+⇧+⌘+V to paste text without any formatting.
Thursday, July 5, 2018
macOS: triple click to select path in Terminal
Source: Is there a UNIX-style triple click to select path in Terminal.app?
The shortcut for Terminal.app is ⌘+⇧+doubleclick.
The shortcut for Terminal.app is ⌘+⇧+doubleclick.
macOS: install postgreSQL 9.4
brew install postgresql@9.4 --with-python
brew link postgresql@9.4 --force
Labels:
macos,
postgresql
Subscribe to:
Posts (Atom)
