Skip to content

Instantly share code, notes, and snippets.

View geetfun's full-sized avatar

Simon Chiu geetfun

View GitHub Profile
@geetfun
geetfun / cheatsheet.rb
Created January 12, 2023 15:00 — forked from mabenson00/cheatsheet.rb
Rails ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today
@geetfun
geetfun / wale_postgres_recovery.md
Created November 19, 2015 08:11 — forked from elithrar/wale_postgres_recovery.md
WAL-E + Postgres 9.x (single server + DB) Setup and Recovery

A quick "how to" on what you need to do to both setup AND recover a single-server PostgreSQL database using WAL-E

  • WAL-E: https://github.com/wal-e/wal-e
  • Assuming Ubuntu 12.04 LTS ("Precise")
  • We'll be using S3. Make sure you have an IAM in a group with GetObject, ListBucket and PutObject on the bucket you want to use (and that it's not public).

Setup:

  1. These packages:
var b = new CustomBinding();
var sec = (AsymmetricSecurityBindingElement)SecurityBindingElement.CreateMutualCertificateBindingElement(MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10);
sec.EndpointSupportingTokenParameters.Signed.Add(new UserNameSecurityTokenParameters());
sec.MessageSecurityVersion =MessageSecurityVersion.
WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;
sec.IncludeTimestamp = true;
sec.MessageProtectionOrder = System.ServiceModel.Security.MessageProtectionOrder.SignBeforeEncrypt;
sec.EnableUnsecuredResponse = true;
b.Elements.Add(sec);
App.AccountEditRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('content', this.get('currentUser'));
}
});
@geetfun
geetfun / Retinafy.md
Created July 24, 2012 02:38 — forked from nijikokun/Retinafy.md
Retinafy your site, a free book

Retinafy Your Site / Device

By Nijiko Yonskai

=====

I made a book, its one page.

Why Use Larger Images?

Higher resolution, twice the size, more detail, better experience on a device that provides it. There is also that thing where people make the desktop version and go to mobile more often than they do the reverse, why? Because, people like making complicated stuff first.

@geetfun
geetfun / chef_solo_bootstrap.sh
Created June 21, 2012 00:18 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@geetfun
geetfun / i18n.coffee
Created November 14, 2011 16:04 — forked from madrobby/i18n.coffee
Backbone i18n with CoffeeScript
window.t = (id, vars = {}) ->
template = i18n[__locale][id] or i18n['en'][id] or "(?) #{id}"
_.template(template, vars)
# yes, that's it
@geetfun
geetfun / grape_api_sample.rb
Created June 4, 2011 02:53 — forked from yorzi/grape_api_sample.rb
a well documented ruby api based on GrapeAPI.
require 'grape'
module My
class API < Grape::API
prefix 'api'
## params key list
#################################################################################################################
# 1. login
# 2. sign
require 'nokogiri'
require 'pstore'
#
# Rack::DomainSprinkler
#
# Modifies outgoing HTML markup so that common static assets like script source
# files, images, and stylesheets will be served from one of a number of domains
# rather than just a single one in order to improve parallelization of resource