Skip to content

Instantly share code, notes, and snippets.

@posener
posener / go-shebang-story.md
Last active March 29, 2024 08:38
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

@hilkeheremans
hilkeheremans / howto
Last active December 8, 2020 19:20
Fonts in React Native for Android vs iOS
REACT NATIVE IOS vs ANDROID FONT USE
Tested for React Native 0.41+
IOS:
- Place the fonts in the assets and make sure they are bundled along
- On iOS, fontFamily in Text match the Font Family name as described in Font Book (macOS). Font weights can be specified exactly.
ANDROID:
On Android, there are two ways of using fonts:
{ writeScriptBin, runCommand, xterm }:
let
nixposition = writeScriptBin "nix-position" ''
nix-position () {
usage () {
echo "Usage: nix-position <attribute-path-under-pkgs>"
echo "Shows the Nix source file for a given attribute path."
}
if [ $# -ne 1 ]; then usage; return -1; fi
@brennanMKE
brennanMKE / README.md
Created October 4, 2016 16:10
React Native on macOS Sierra

React Native Trouble

Updating to macOS Sierra is causing trouble with React Native due to some of the Node.js and system utilities it uses. Specifically the watch utility fails due to a limit on the number of files which can be opened at a time.

The following command shows the current limit.

launchctl limit maxfiles
anonymous
anonymous / dev_jobs_in_japan.md
Created September 16, 2016 04:34
Software dev jobs in Japan

Companies

  • Github - Recently started hiring developers in Tokyo
  • Heroku - Infrastructure-as-a-service; recently bought by Salesforce
  • Pivotal Labs - Recently started hiring developers in Tokyo; nice Mori Tower office
  • Google - Consistently ranked best place in Japan to work; nice Mori Tower office
  • Amazon - I THINK they now hire some developers
  • Microsoft - English-friendly with chances to speak Japanese; apparently have some interesting projects; nice Shinagawa office
  • Kaizen Platform - Pretty awesome company developing A/B testint as a service / analytics services; I think most people there speak English; has an office in San Francisco
  • [Treasure Data](https://www.treasureda
rec {
test1 = builtins.scopedImport { __nixPath = [ { path = test4; prefix="ssh-config-file"; } ] ++ __nixPath; };
test2 = test1 <nixpkgs/pkgs/build-support/fetchgit/private.nix>;
pkgs = import <nixpkgs> {};
test3 = pkgs.callPackage test2 {};
test4 = pkgs.writeText "sshd_config" ''
# empty file, use programs.ssh.knownHosts in configuration.nix not StrictHostKeyChecking no
'';
test5 = test3 {
url = "git@github.com:cleverca22/not-os.git";
@glogiotatidis
glogiotatidis / remove-gpg-user.sh
Created May 24, 2016 11:50
Git-crypt remove user.
#!/bin/bash
#
# Script to remove GPG key from git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.
@deshion
deshion / get_options.sh
Last active February 3, 2024 19:40
Parse command line options for a shell script (POSIX)
#!/bin/sh
# POSIX
# Reset all variables that might be set
file=
verbose=0 # Variables to be evaluated as shell arithmetic should be initialized to a default or validated beforehand.
while :; do
case $1 in
-h|-\?|--help) # Call a "show_help" function to display a synopsis, then exit.
@carcinocron
carcinocron / debugger pause beforeunload
Last active April 25, 2024 16:48
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@travisbhartwell
travisbhartwell / nix-shell-shebang.md
Last active March 29, 2024 19:55
nix-shell and Shebang Lines

NOTE: a more up-to-date version of this can be found on my blog

nix-shell and Shebang Lines

A few days ago, version 1.9 of the Nix package manager was released. From the release notes:

nix-shell can now be used as a #!-interpreter. This allows you to write scripts that dynamically fetch their own dependencies.