Skip to content

Instantly share code, notes, and snippets.

View cktricky's full-sized avatar
🏠
Working from home

Ken Johnson cktricky

🏠
Working from home
View GitHub Profile
@cktricky
cktricky / celluloid.rb
Created September 17, 2012 21:04
Celluloid Test
#!/usr/bin/env ruby
require 'celluloid'
require 'net/http'
class Fetcher
include Celluloid
def get(url)
puts "requesting url #{url}"
response = Net::HTTP.get URI(url)
@cktricky
cktricky / proc-it-like-its-hawt
Created September 30, 2012 01:33
Cool proc-ness
#!/usr/bin/env ruby
require 'celluloid'
require 'net/http'
class Fetcher
include Celluloid
def get(action, url)
puts "doing work.."
res = action.call(url)
require 'wXf/wXfui'
begin
require 'rubygems'
require 'celluloid'
rescue LoadError
end
module WXf
module WXfassists
@cktricky
cktricky / gist:4967248
Last active December 13, 2015 20:08
crappy solution for parsing sources from a string
require 'uri'
a = %{rubygems repository http://blahblah.net/, https://rubygems.org/}
b = a.split().inject([]) {|array, string|
begin
x = URI.parse(string).absolute?
array << string if x
rescue
end
cd /usr/share/tomcat7
sudo ln –s /var/lib/tomcat7/conf conf
sudo ln –s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
sudo ln –s /var/log/tomcat7 log
sudo chmod –R 777 /usr/share/tomcat7/conf
@cktricky
cktricky / embed-gist.js
Last active February 5, 2023 11:26
Syntax highlighting for embedded gists
/*
To use this file, save it to a JS file and include it (<script src=) or
wrap it in <script type="text/javascript"> </script> tags on the page you are embedding the code on.
1) When you craft the script tag for including the gist assign it a class="embed-gist"
2) Give a file parameter, this is the name of the file, this is something absolutely necessary,
needs to be the first parameter (before lines)
@cktricky
cktricky / request_handling.md
Last active January 2, 2016 15:59
mass-assignment

##Client Request##

The following is a post request sent by a user during the registration process

POST /api/create_user HTTP/1.1
Accept: application/json
Content-Type: application/json;charset=UTF-8
Host: localhost
Connection: Keep-Alive

Accept-Encoding: gzip

@cktricky
cktricky / safe_request_handling.md
Last active January 2, 2016 15:59
Mass Assignment Part 2

##Web Application Code##

Within the request handling code:

_ = require('underscore');
var user = new User(_.pick(req.body, User.userCreateSafeFields));

Within the User model:

UserSchema.statics = {

@cktricky
cktricky / aws_signing.rb
Created March 4, 2014 22:33
AWS Cloudfront Signing Config File
# Add config/keys/pk-someRandomString.pem to your .gitignore file so...
# that it isn't stored in source code repos
key_file = Rails.root.join("config", "keys", "pk-someRandomString.pem")
SIGNER = AwsCfSigner.new(key_file)
# AWS URL Signing Gem
gem 'aws_cf_signer'