Skip to content

Instantly share code, notes, and snippets.

View JKring's full-sized avatar

jake kring JKring

View GitHub Profile
@JKring
JKring / nginx.conf
Last active September 28, 2015 19:38
Scripted Nginx Configuration
user deploy;
worker_processes 4;
error_log /var/log/nginx/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
@JKring
JKring / ma.rb
Created May 23, 2012 00:21
MongoMapper Associations
require 'rubygems'
require 'mongo_mapper'
MongoMapper.database = "test_associations"
class Job
include MongoMapper::Document
belongs_to :invoice
@JKring
JKring / ma.rb
Created May 23, 2012 00:42
MongoMapper Associations
require 'rubygems'
require 'mongo_mapper'
MongoMapper.database = "test_associations"
class Job
include MongoMapper::Document
belongs_to :invoice
@JKring
JKring / mongo_test.rb
Created July 13, 2012 00:00
MongoMapper Associations
require 'rubygems'
require 'mongo_mapper'
MongoMapper.database = "test_associations"
class Job
include MongoMapper::Document
belongs_to :invoice
@JKring
JKring / collage.js
Created July 20, 2012 05:25
collage
function collage(id){
var el = "#" + id;
if ($(el).attr('class').indexOf('disabled') != -1){
$("#collage-helper").remove();
$(el).css('z-index', '100');
var lft = $(el).offset().left.toString() + "px";
var tp = $(el).offset().top.toString() + "px";
$(el).css('position', 'absolute');
$(el).css('left', lft);
$(el).css('top', tp);
@JKring
JKring / fsockopen.php
Created July 27, 2012 00:02
fsockopen
$host = 'ssl://scripted.com';
$path = 'formats';
$fp = fsockopen($host,443);
fputs($fp,"GET $path HTTP/1.1\r\n");
fputs($fp,"Host: $host\r\n\r\n");
while(!feof($fp)){
echo fgets($fp,1024);
fclose($fp);
@JKring
JKring / crontab
Created August 1, 2012 18:15
whenever
# Begin Whenever generated tasks for: /home/deploy/cap/releases/20120731190330/config/schedule.rb
0,10,20,30,40,50 * * * * /bin/bash -l -c 'cd /home/deploy/cap/current; RAILS_ENV=production /home/deploy/.rvm/gems/ruby-1.9.2-p290@production/bin/bundle exec rake cull 2>&1 > /tmp/cron.out'
0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /bin/bash -l -c 'cd /home/deploy/cap/current; RAILS_ENV=production /home/deploy/.rvm/gems/ruby-1.9.2-p290@production/bin/bundle exec rake cull_businesses 2>&1 > /tmp/cron.out'
30 2 * * * /bin/bash -l -c 'cd /home/deploy/cap/current; RAILS_ENV=production /home/deploy/.rvm/gems/ruby-1.9.2-p290@production/bin/bundle exec rake update_contents 2>&1 > /tmp/cron.out'
30 2 * * * /bin/bash -l -c 'cd /home/deploy/cap/current; RAILS_ENV=production /home/deploy/.rvm/gems/ruby-1.9.2-p290@production/bin/bundle exec rake cull_invoices 2>&1 > /tmp/cron.out'
@JKring
JKring / http_post_weird.rb
Created August 24, 2012 20:24
Ruby Net:HTTP Post
# rvm use 1.9.2
@api_parameters = {"USER"=>"our username", "PWD"=>"our password", "VERSION"=>"74.0", "SIGNATURE"=>"our sig", "METHOD"=>"MassPay", "RECEIVERTYPE"=>"EmailAddress", "CURRENCYCODE"=>"USD", "EMAILSUBJECT"=>"Scripted: Payment for Test", "L_EMAIL0"=>"kringj@gmail.com", "L_UNIQUEID0"=>"", "L_NOTE0"=>"", "L_AMT0"=>"1.0"}
@paypal_url = 'api-3t.paypal.com/nvp'
response = Net::HTTPS.post_form(URI("https://#{@paypal_url}"), @api_parameters)
response.body => "TIMESTAMP=2012%2d08%2d24T20%3a20%3a42Z&CORRELATIONID=1a3af9521ac71&ACK=Success&VERSION=74%2e0&BUILD=3556406"
@JKring
JKring / gist:3824275
Created October 3, 2012 00:54
lots of rake nlps
deploy@scripted-ruby:~/cap/current$ ps -ef | grep rake
deploy 1850 1 0 Aug18 ? 00:00:00 /bin/sh -c /bin/bash -l -c 'cd /home/deploy/cap/current; RAILS_ENV=production /home/deploy/.rvm/gems/ruby-1.9.2-p290@production/bin/bundle exec rake nlp alg=lda 2>&1 > /tmp/cron.out'
deploy 1855 1850 0 Aug18 ? 00:00:00 /bin/bash -l -c cd /home/deploy/cap/current; RAILS_ENV=production /home/deploy/.rvm/gems/ruby-1.9.2-p290@production/bin/bundle exec rake nlp alg=lda 2>&1 > /tmp/cron.out
deploy 2532 1855 0 Aug18 ? 00:19:06 ruby /home/deploy/cap/shared/bundle/ruby/1.9.1/bin/rake nlp alg=lda
deploy 5445 1 0 Sep02 ? 00:00:00 /bin/sh -c /bin/bash -l -c 'cd /home/deploy/cap/current; RAILS_ENV=production /home/deploy/.rvm/gems/ruby-1.9.3-p194@global/bin/bundle exec rake nlp alg=lda 2>&1 > /tmp/cron.out'
deploy 5454 5445 0 Sep02 ? 00:00:00 /bin/bash -l -c cd /home/deploy/cap/current; RAILS_ENV=production /home/deploy/.rvm/gems/ruby-1.9.3-p194@global/bin/bundle exec r
@JKring
JKring / terms.rb
Created October 4, 2012 18:18
top terms
{"feature"=>1.0, "management"=>0.992967451, "hotel"=>0.987985968597, "asset"=>0.92460578682, "cm"=>0.92460578682, "crm"=>0.600620590919, "maintenance"=>0.583698681887, "capability"=>0.503300935755, "preventive"=>0.434077430902, "theme"=>0.41637112296, "content"=>0.416021238529, "system"=>0.396580819325, "addons"=>0.325071129587, "automation"=>0.325071129587, "marketer"=>0.310583965259, "implementation"=>0.29933640828, "addon"=>0.25629581076, "blogging"=>0.221155637545, "setup"=>0.213255213241, "update"=>0.199207138085, "additionally"=>0.198965486824, "manage"=>0.193267711057, "plugins"=>0.187520491934, "user"=>0.185796810589, "platform"=>0.185796810589, "security"=>0.17909164684, "include"=>0.162458049666, "network"=>0.162305959143, "sandbox"=>0.161561677614, "ez"=>0.161561677614, "inspection"=>0.161561677614, "connection"=>0.161561677614, "privilege"=>0.161561677614, "simplify"=>0.161561677614, "expression"=>0.161561677614, "design"=>0.161393776569, "testing"=>0.155942447552, "manager"=>0.155942447552, "soft