Skip to content

Instantly share code, notes, and snippets.

View liushooter's full-sized avatar

Shooter liushooter

View GitHub Profile
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@liushooter
liushooter / custom_auth_failure_app.rb
Created February 8, 2017 05:20 — forked from emilsoman/custom_auth_failure_app.rb
Custom failure app to render a custom json on auth failure
class CustomAuthFailure < Devise::FailureApp
def respond
self.status = 401
self.content_type = 'json'
self.response_body = {"errors" => ["Invalid login credentials"]}.to_json
end
end
@liushooter
liushooter / where_is.rb
Created February 6, 2017 09:01 — forked from wtaysom/where_is.rb
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@liushooter
liushooter / where_is.rb
Created February 6, 2017 09:01 — forked from wtaysom/where_is.rb
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@liushooter
liushooter / vagrant-clean.sh
Created January 17, 2017 04:27 — forked from jdowning/vagrant-clean.sh
Script to clean up Ubuntu Vagrant box before packaging
#!/bin/bash
# This script zeroes out any space not needed for packaging a new Ubuntu Vagrant base box.
# Run the following command in a root shell:
#
# bash <(curl -s https://gist.github.com/justindowning/5670884/raw/vagrant-clean.sh)
function print_green {
echo -e "\e[32m${1}\e[0m"
}
@liushooter
liushooter / genymotionwithplay.txt
Created January 2, 2017 10:10 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
@liushooter
liushooter / proxy.rb
Created December 26, 2016 05:39 — forked from torsten/proxy.rb
A quick HTTP proxy server in Ruby.
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009-2014 Torsten Becker <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
@liushooter
liushooter / redis.markdown
Created December 20, 2016 04:58 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@liushooter
liushooter / algorithm-prototype.js
Created September 22, 2016 17:17
A main text search algorithm prototype depend on browser rendering tree.
'use strict'
import R from 'ramda'
let fixOverflowVisible = ([clientValue, scrollValue]) => scrollValue / clientValue > 2 ? scrollValue : clientValue
, getHeight = R.compose(fixOverflowVisible, e => [e.clientHeight, e.scrollHeight])
, getWidth = R.compose(fixOverflowVisible, e => [e.clientWidth, e.scrollWidth])
, getWindowHeight = () => document.documentElement.clientHeight
, getWindowWidth = () => document.documentElement.clientWidth
, getScrollX = () => window.scrollX
, getScrollY = () => window.scrollY
@liushooter
liushooter / fields.py
Created September 1, 2016 07:05 — forked from gregmuellegger/fields.py
A django.db.models.fields.EmailField that forces lower case letters.
'''
Taken from: https://code.djangoproject.com/ticket/17561#comment:7
'''
from django.db import models
class EmailField(models.EmailField):
def get_prep_value(self, value):
value = super(EmailField, self).get_prep_value(value)