Skip to content

Instantly share code, notes, and snippets.

View khash's full-sized avatar
😷
Having fun!

Kash Sajadi khash

😷
Having fun!
View GitHub Profile
@khash
khash / oauth.rb
Created March 4, 2014 18:35
Cloud 66 oAuth 2.0 Example
require 'rubygems'
require 'oauth2'
require 'json'
base = 'https://www.cloud66.com'
api_url = 'https://www.cloud66.com/api/2'
if File.exists? '/tmp/cloud66_oauth_test.json'
config = JSON.parse(File.read('/tmp/cloud66_oauth_test.json'))
client = OAuth2::Client.new(config['app_id'], config['app_secret'], :site => base)
#!/bin/bash
# reset.fw - Reset firewall
# set x to 0 - No reset
# set x to 1 - Reset firewall
# ---------------------------------------------------------------------------------------------------------------
# Added support for IPV6 Firewall
# ---------------------------------------------------------------------------------------------------------------
# Written by Vivek Gite <vivek@nixcraft.com>
# ---------------------------------------------------------------------------------------------------------------
# You can copy / paste / redistribute this script under GPL version 2.0 or above
@khash
khash / gist:50af4d0a75067b86bf02
Last active August 29, 2015 14:08
keybase.md

Keybase proof

I hereby claim:

  • I am khash on github.
  • I am khash (https://keybase.io/khash) on keybase.
  • I have a public key whose fingerprint is 4997 A4A4 8346 3294 2B66 2709 5B97 2C40 6E35 49BE

To claim this, I am signing this object:

@khash
khash / deployer.coffee
Created December 22, 2014 12:01
Hubot script to deploy your stack using Cloud 66
# Description:
# Deploys stacks with Cloud 66
#
# Dependencies:
# "deploy": "0.0.1"
#
# Configuration:
# STAGING_HOOK_UID
#
# Commands:
require "bundler/capistrano"
require 'san_juan'
set :application, "myapp"
set :repository, "git@git.assembla.com:myapp.git"
set :scm, :git
set :user, 'deploy'
set :use_sudo, false
set :deploy_to, "/var/www/#{application}"
@khash
khash / gist:1364171
Created November 14, 2011 15:25
WCF Services Issue
namespace MyApp
{
public class Installer : IWindsorInstaller
{
public static Binding DefaultBinding
{
get
{
return new BasicHttpBinding
{
@khash
khash / check_security.rb
Created December 13, 2011 11:40
Bypass security in controller in unit test
def check_signature
return if request.host == 'test.host'
# check signature
# ...
end
@khash
khash / MixpanelTrackEventJob.rb
Created January 1, 2012 12:41
Mixpanel Resque Job
require 'net/http'
class MixpanelTrackEventJob
@queue = :slow
def self.perform(name, params, user_id, user_ip = nil)
user = User.find(user_id)
params.merge!({ :distinct_id => user.id, :mp_name_tag => user.email }) if !user.nil?
params.merge!({ :ip => user_ip }) if !user_ip.nil?
@khash
khash / layout.html
Created January 1, 2012 12:42
Mixpanel Integration
<script type="text/javascript">var mpq=[];mpq.push(["init","<%= AppSettings.api_keys.mixpanel %>"]);(function(){var b,a,e,d,c;b=document.createElement("script");b.type="text/javascript";b.async=true;b.src=(document.location.protocol==="https:"?"https:":"http:")+"//api.mixpanel.com/site_media/js/api/mixpanel.js";a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(b,a);e=function(f){return function(){mpq.push([f].concat(Array.prototype.slice.call(arguments,0)))}};d=["init","track","track_links","track_forms","register","register_once","identify","name_tag","set_config"];for(c=0;c<d.length;c++){mpq[d[c]]=e(d[c])}})();
</script>
@khash
khash / mixpanelevent.rb
Created January 1, 2012 12:46
Call Mixpanel Event in Resque
Resque.enqueue(MixpanelTrackEventJob, "Added CC Info", {:type => 'AMEX'}, current_user.id)