Skip to content

Instantly share code, notes, and snippets.

Ying Quan Tan brightredchilli

Block or report user

Report or block brightredchilli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@brightredchilli
brightredchilli / countlines.sh
Created Jun 11, 2018
Count lines in files matching a certain criteria
View countlines.sh
"grep all filenames containing Interactor.swift, quote the output so that we can pass to xargs
"then sort by line count, then use awk again to remove some unnecessary columns
find Code | grep Interactor.swift | awk '{printf("\"%s\"\n", $0);}' | xargs wc | sort --reverse -k 1 | awk '{$2=$3=""}1'
@brightredchilli
brightredchilli / print-all.rb
Created Jun 5, 2018
Rails print all models
View print-all.rb
ActiveRecord::Base.send(:subclasses).map(&:name)
View gist:658d26e379ef8e05ff8c63e72d0fadf7
# Use awk to remove spaces. strips the trailing ":" from the first column
# adds quotes around the second.
heroku config --remote staging | grep -v "Config Vars" | awk '{print substr($1, 1, length($1)-1)"=""\""$2"\""}' > .env.developmen
@brightredchilli
brightredchilli / get-all-branches-and-committers.sh
Created Mar 21, 2018
Get all commiter names and branches from github
View get-all-branches-and-committers.sh
git branch -a | grep origin | grep --invert-match HEAD | xargs -n1 git show --no-patch --format="%cn %d
@brightredchilli
brightredchilli / mount_drives.sh
Created Dec 29, 2017
Script to mount volumes on aws instances
View mount_drives.sh
#!/bin/bash
# note - /dev/xvdh that is what /dev/sdh is mapped to
devpath=$(readlink -f /dev/xvdh)
MNTPOINT=/images
sudo file -s $devpath | grep -q ext4
if [[ 1 == $? && -b $devpath ]]; then
sudo mkfs -t ext4 $devpath
fi
@brightredchilli
brightredchilli / package.json
Created Dec 14, 2017
A sane default for web development
View package.json
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"autoprefixer": "^7.2.3",
"babel-core": "^6.26.0",
"babelify": "^8.0.0",
View guard-build.sh
#!/bin/sh
# This script is made to run inside a docker container, when we need to watch for changes in the container and build.
# Initially used for watching changes and doing a Hugo build, but this should be pretty general purpose.
# We simply calculate the md5sum of the entire directory every second, and trigger the build command if something has changed
PREV_VALUE=""
while :
do
VALUE=`tar --exclude="dir/to/exclude" --exclude="anotherdir/to/exclude" -cf - . | md5sum`
View Coalesce.java
public interface CoalescingCallback<U> {
U call();
}
/***
* See documentation for coalesce(CoalescingCallback<T>, T)
*/
@brightredchilli
brightredchilli / editplist.sh
Created Sep 23, 2015
Remove CFBundleExecutable from pods
View editplist.sh
#!/bin/bash
# The purpose of this script is to remove the CFBundleExecutable script from all
# third party dependencies that dont'actually contain executables. This appears
# to be a new Xcode 7 requirement.
KEY='CFBundleExecutable'
GOOGLESIGNINPLISTPATH="$SRCROOT"/Pods/GoogleSignIn/Resources/GoogleSignIn.bundle/Info
if defaults read $GOOGLESIGNINPLISTPATH $KEY
You can’t perform that action at this time.