Skip to content

Instantly share code, notes, and snippets.

View gnepud's full-sized avatar

Peng Du gnepud

  • Grenoble, France
View GitHub Profile
@gnepud
gnepud / gist:f6b9707efe588d94d741
Last active March 22, 2016 09:25
Get External IP / local IPs
# Get External IP / local IPs
alias ip="curl ipinfo.io/ip"
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'"
## other get external ip methods
# dig +short myip.opendns.com @resolver1.opendns.com
# curl echoip.com
# curl ifconfig.me
if defined? Rails
$LOAD_PATH << "/Users/peng/.rvm/gems/ruby-1.9.3-p194@global/gems/awesome_print-1.1.0/lib"
end
begin
require 'awesome_print'
AwesomePrint.irb!
rescue LoadError
end
@gnepud
gnepud / a start
Created September 20, 2013 08:36 — forked from dorkalev/a start
sentence = "there is a wild rose"
letters = sentence.gsub(' ','').split(//)
@gnepud
gnepud / gist:5827411
Last active April 3, 2016 23:48
Spree 2.0 + RefineryCMS 2.1.dev
brew update
rvm get stable
rvm requirements
rvm install 2.0.0
rvm use --default 2.0.0
rvm gemset create piron
rvm gemset use piron
gem install rails
@gnepud
gnepud / gist:5804215
Created June 18, 2013 10:13
Generate token paymill
def get_payment_token
# Simulate the JavaScript bridge we would use in production
params = {
'transaction.mode' => 'CONNECTOR_TEST',
'channel.id' => APP_CONFIG[:paymill_pub_key],
'jsonPFunction' => 'function',
'account.number' => '4111111111111111',
'account.expiry.month' => '02',
'account.expiry.year' => '2014',
'account.verification' => '111',
@gnepud
gnepud / gist:4573927
Created January 19, 2013 17:55
mac mountain lion clean duplicate items in open with menu
cd /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/
./lsregister -kill -domain local -domain system -domain user
@gnepud
gnepud / gist:3833862
Created October 4, 2012 14:28
Placeholder
//---------------------------------------------------------------------------------------------
// PLACEHOLDER
//---------------------------------------------------------------------------------------------
if(!Modernizr.input.placeholder){
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
@gnepud
gnepud / css_compressor.rb
Created September 19, 2012 12:10
CSS Compressor
class CssCompressor
def compress(css)
#define formatting around the characters
colon = ':'
semicolon = ';'
comma = ','
open_brace = '{'
close_brace = '}'
#one block per line
@gnepud
gnepud / db.rb
Created September 10, 2012 12:21 — forked from alg/db.rb
namespace :db do
desc 'Seed database from db/seed.sql file instead of the traditional db/seed.rb'
namespace :seed do
config = Rails::Configuration.new.database_configuration[RAILS_ENV]
seed_sql = File.expand_path(File.dirname(__FILE__) + '/../../db/seed.sql')
if !File.exists?(seed_sql)
puts "Missing RAILS_ROOT/db/seed.sql"
@gnepud
gnepud / model_caching.coffee
Created July 11, 2012 17:42 — forked from rstacruz/model_caching.coffee
Backbone.js model caching
# ## Backbone model caching
# This is a simple solution to the problem "how do I make less requests to
# my server?".
#
# Whenever you need a model instance, this will check first if the same thing
# has been fetched before, and gives you the same instance instead of fetching
# the same data from the server again.
#
# Reusing the same instance also has the great side-effect of making your
# model changeable from one part of your code, with your changes being available