Sunday, October 21, 2018

Android O: identify battery sucking apps

Source: Android O: How to Identify and Bitch Slap Those Battery Sucking Apps
On my Oneplus 5T, Android 8.1:

List apps. running in background permanently
  • Settings > Dev. Options > Running Services 
Kill the background activity of an app.
  • Settings > Apps > Application list > Select app > Battery > Uncheck Background activity

Thursday, October 18, 2018

macOS mojave: bluetooth headphones keep on disconnecting

Uncheck "Allow Handoff between this Mac and your iCloud devices" in Preferences | General.

Thursday, October 4, 2018

macOS: xcrun: error: invalid active developer path

Source: macOS Mojave: invalid active developer path
If after upgrading from High Sierra to Mojave, you get the following error:
[jerome@jeroboam] > make
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Then re-install xcode developer tools like in:
[jerome@jeroboam] > xcode-select --install
xcode-select: note: install requested for command line developer tools

Saturday, September 29, 2018

macOS: from High Sierra to Mojave

Steps:
  • Download "Install macOS Mojave" application from the Mac App Store, and run it.
  • Reboot. At Clover boot screen, choose Boot macOS Install option. Multiple reboots expected. At some time, pick "Boot FileVault Prebooter from Preboot" option to finish the install.
  • Update Clover configuration in order to hide the 2 preboot options at boot time. For this, add "Preboot" in Clover Configurator | Gui | Hide Volume
  • And here it is.
  • Optional step: Create a Bootable USB with UniBeast

Monday, September 24, 2018

macOS: downloading .gz from Chrome turns into .cpgz

If you download a .gz from Chrome, and double-clicking it simply creates a .cpgz, then the downloaded file is not a .gz
Try
> file --mime-type ~/Desktop/42a3-909a-1b5bdb4a4b8b.gz
text/plain
Then simply rename it into .txt, and you will be able to open it.

Friday, September 21, 2018

macOS: turn text into links automatically

Use Edit > Substitutions > Smart Links

Tuesday, September 18, 2018

macOS: how to page up with byobu in Terminal.app

Source: How can I page up or down in tmux with Terminal.app?
Terminal.app captures PageUp / PageDown. So, in order to send them to byobu again:
If on a PC keyboard:
  • F7
  • Shift + PageUp / Shift + PageDown
Or if on a MacBookPro:
  • F7
  • Fn + Shift + Up / Fn + Shift + Down

Wednesday, September 12, 2018

Tuesday, September 4, 2018

git: merge files from another branch

Source: Git tip: How to "merge" specific files from another branch
git checkout [TARGET_BRANCH]
git checkout [SOURCE_BRANCH] my_file1 my_file2

Friday, August 31, 2018

Perl: slurp STDIN

Source: How can I slurp STDIN in Perl?
my $str = do { local $/;  };

Wednesday, August 1, 2018

git: rename a branch

Source: Rename a local and remote branch in git

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:
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:
Host bastion
HostName bastion-01.golgoth.com
User jgallinari

Host remote1
HostName remote1.toto.swir
User jgallinari
ProxyCommand ssh jgallinari@bastion -W %h:%p
Then 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.
  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
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.

Clojure: transducers from the ground up

Clojure transducers from the ground up: the practice

AWS: !Sub |


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.