Skip to content

Instantly share code, notes, and snippets.

View juliend2's full-sized avatar

Julien Desrosiers juliend2

View GitHub Profile
@jnunemaker
jnunemaker / harmony.rb
Created November 10, 2009 01:20
simple app configuration
module Harmony
# Allows accessing config variables from harmony.yml like so:
# Harmony[:domain] => harmonyapp.com
def self.[](key)
unless @config
raw_config = File.read(RAILS_ROOT + "/config/harmony.yml")
@config = YAML.load(raw_config)[RAILS_ENV].symbolize_keys
end
@config[key]
end
#redirect all traffic to https over ssl with Sinatra
configure :production do
# us a simple before filter to redirect all requests in production to https
# before do
# unless (@env['HTTP_X_FORWARDED_PROTO'] || @env['rack.url_scheme'])=='https'
# redirect "https://#{request.env['HTTP_HOST']}#{request.env["REQUEST_PATH"]}"
# end
# end
/*
Expanding color pixels on the current (and only loaded image)
*/
var doc = app.documents[0];
doc.colorSamplers.removeAll(); // otherwise it will create an error if there is already a colorSampler on this point
var offset = 4;
for (var w=0; w < doc.width; w+=offset) {
for (var h=0; h < doc.height; h+=offset) {
require "bigdecimal"
montant = BigDecimal.new(ARGV[0])
GSTpercent = 5
QSTpercent = BigDecimal.new("8.5")
myGST = montant * GSTpercent / 100
myQST = (montant + myGST) * QSTpercent / 100
total = montant + myGST + myQST
@adaburrows
adaburrows / compose_functions.php
Created April 26, 2011 06:24
Composing functions in PHP
<?php
/**
* Just trying out more functional programming in PHP
* This gist provides some basic utility functions for:
* + Working with functions
* + Working with arrays
*/
// This function allows creating a new function from two functions passed into it
function compose(&$f, &$g) {
@markbates
markbates / config.ru
Created August 31, 2011 19:01
Sprockets with a simple Rack app
require 'sprockets'
project_root = File.expand_path(File.dirname(__FILE__))
assets = Sprockets::Environment.new(project_root) do |env|
env.logger = Logger.new(STDOUT)
end
assets.append_path(File.join(project_root, 'app', 'assets'))
assets.append_path(File.join(project_root, 'app', 'assets', 'javascripts'))
assets.append_path(File.join(project_root, 'app', 'assets', 'stylesheets'))
@jkudish
jkudish / limit_submissions_by_ip.php
Created September 1, 2011 23:50
filters a Gravity Form to prevent submissions from an already submitted IP, good for spam prevention
<?php
/**
* limit_submissions_by_ip()
* filters a Gravity Form to prevent submissions from an already submitted IP, good for spam prevention
* change the ID to match your form (ex: gform_pre_render_6)
* @param $form (array) the form
* @return $form (array) the filtered form
* @author Joachim Kudish <[email protected]>
* @link http://jkudish.com
*/
@andrewrcollins
andrewrcollins / trim.awk
Created January 11, 2012 04:22
ltrim(), rtrim(), and trim() in awk
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
# whatever
}
{
# whatever
}
END {
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@dongilbert
dongilbert / git-wordpress.txt
Created April 27, 2012 14:27
Use Git with WordPress Plugin Development
=== Using Git with WordPress Plugin Development ===
git svn clone -s -r<rev-number> https://svn.wp-plugins.org/<plugin-path> <-- Clone the plugin repo
cd <plugin-path> <-- change to directory
git svn fetch <-- Pull svn history
git remote add -f github [email protected]:<github-url> <-- add github remote
/* ADD CODE */ <-- write code
git add * <-- add to git
git commit -m "Starting to code" <-- commit changes
git svn dcommit <-- push to svn
git push -f github <-- push to github