Skip to content

Instantly share code, notes, and snippets.

View double-z's full-sized avatar

Zack Zondlo double-z

View GitHub Profile
@double-z
double-z / gist:1174805
Created August 27, 2011 01:02 — forked from cyakimov/gist:1139981
Decode Facebook signed_request with NodeJS
//npm install b64url
//A signed_request for testing:
//WGvK-mUKB_Utg0l8gSPvf6smzacp46977pTtcRx0puE.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEyOTI4MjEyMDAsImlzc3VlZF9hdCI6MTI5MjgxNDgyMCwib2F1dGhfdG9rZW4iOiIxNTI1NDk2ODQ3NzczMDJ8Mi5ZV2NxV2k2T0k0U0h4Y2JwTWJRaDdBX18uMzYwMC4xMjkyODIxMjAwLTcyMTU5OTQ3NnxQaDRmb2t6S1IyamozQWlxVldqNXp2cTBmeFEiLCJ1c2VyIjp7ImxvY2FsZSI6ImVuX0dCIiwiY291bnRyeSI6ImF1In0sInVzZXJfaWQiOiI3MjE1OTk0NzYifQ
function parse_signed_request(signed_request, secret) {
encoded_data = signed_request.split('.',2);
// decode the data
sig = encoded_data[0];
json = base64url.decode(encoded_data[1]);
data = JSON.parse(json); // ERROR Occurs Here!
@double-z
double-z / gist:1174814
Created August 27, 2011 01:07 — forked from chanon/gist:661597
Facebook iframe Canvas App Authentication in node.js
var base64ToString = function(str) {
return (new Buffer(str || "", "base64")).toString("ascii");
};
var base64UrlToString = function(str) {
return base64ToString( base64UrlToBase64(str) );
};
var base64UrlToBase64 = function(str) {
var paddingNeeded = (4- (str.length%4));
# put on the server
# put in /etc/puppet/custom/plugins/facter/custom_facts.rb
require 'yaml'
if File.exist?("/etc/puppet/custom_facts.yml")
YAML.load_file("/etc/puppet/custom_facts.yml").each do |key, value|
Facter.add(key.to_sym) do
setcode { value }
end
end
# cookbooks/chef_notifier/libraries/chef_notifier.rb
#
# This monkeypatches Chef::Runner to report the result of run_action calls via MCollective
require 'mcollective'
class MRPC
include MCollective::RPC
def report_action(resource, action)
options = MCollective::Util.default_options
cfengine
declarative
runs continuously
language is "baroque"
supports classes
large number of action sequences
-----
puppet
@double-z
double-z / application.rb
Created October 19, 2012 19:29 — forked from finack/application.rb
Example Chef Deploy Revision for Rails 3+
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]
@double-z
double-z / base5.rb
Created November 23, 2012 09:04 — forked from atomic-penguin/base5.rb
chef-baseline-role-example
name "base5"
description "Contains run list of roles which are safe to run on all RHEL5 and RHEL6 servers."
override_attributes "inittab" => {
"runlevel" => "3"
},
"chef_client" => {
"server_url" => "http://chef.example.com:4000",
"init_style" => "init"
},
"logwatch" => {
@double-z
double-z / gist:4151480
Created November 27, 2012 00:02 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@double-z
double-z / README.md
Created November 27, 2012 05:56 — forked from gburd/README.md
CloudStack DevCloud bootstrap
  • CloudStack is all about allocating a pool of resources out to customers/clients but we don't have a pool of assets (racks of machines) when developing. Luckily there is a pre-configured VirtualBox VM all setup to pretend to be available to CloudStack for just such testing/development purposes.
  • I work out of ~/eng, so the cloudstack git repo is there, but it's scripted to live elsewhere, so...
    • mkdir -p /opt/cloudstack (might have to sudo, chmod etc.)
    • ln -s /Users/gburd/eng/cloudstack /opt/cloudstack/incubator-cloudstack
  • We'll need the cloudstack-python-client later, install that...
    • git clone git://github.com/jasonhancock/cloudstack-python-client.git
    • cd cloudstack-python-client
    • pip install .
  • A few ant commands will need additional jars in your Ant library path, so do that...

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.