This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== 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 |
OlderNewer