Skip to content

Instantly share code, notes, and snippets.

View charliemoseley's full-sized avatar

Charlie Moseley charliemoseley

View GitHub Profile
stripe_id: string
plan_id: integer <= rails
subscription_id: rails <= Lookup on stripe subscription_id
user_id: integer <= rails
credit_card_id: integer <= rails
attempted: boolean
paid: boolean
attempt_count: integer
next_payment: date time <= convert from unix
require 'execjs'
class JSContextValidator
attr_accessor :answer, :errors
def initialize(context, validation_script, api_call)
@errors = []
# Load any javascript libraries
js = ""
open(Rails.root.join('app', 'assets', 'javascripts', 'lib', 'underscore.min.js')) { |file| js << file.read }
@charliemoseley
charliemoseley / gist:9043379
Created February 17, 2014 01:56
Sapphire 290x Tri-x settings
{
"pools" : [
{
"url" : "stratum+tcp://stratum1.shibepool.com:3333",
"user" : "xxxxxxxxxxx",
"pass" : "xxxxxxxxxxx"
}
]
,
"intensity" : "20,20",
@charliemoseley
charliemoseley / euler1-2.rb
Created July 17, 2013 12:17
project euler answers for 1-2
# Euler more effecient/ruby like answers
# Problem One Examples
sum = 0
(1..100).each do |int|
sum += int if (int % 3 == 0) || (int % 5 == 0)
end
puts "Sum is: #{sum}"
(1..100).to_a.reduce(0) do |sum, int|
sum += int if (int % 3 == 0) || (int % 5 == 0)
@charliemoseley
charliemoseley / gist:5992390
Created July 13, 2013 22:01
Basic Jquery AJAX for gets/post on a real ajax server.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ajax</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<script>
# Since this gem is only loaded with the assets group, we have to check to
# see if it's defined before configuring it.
if defined?(AssetSync)
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
config.fog_directory = ENV['FOG_DIRECTORY']
# Fail silently. Useful for environments such as Heroku
#!/usr/bin/ruby
require 'csv'
xml_docs = Dir["./*xml"]
status_counter = xml_docs.count / 10
status_counter = 1 if status_counter == 0
outfile = File.open('unique_ids.csv', 'wb')
CSV::Writer.generate(outfile) do |csv|
[
{
"kind":"movie",
"title":"Harry Potter and the Sorcerers Stone",
"slug":"harry-potter-and-the-sorcerers-stone",
"image":"http://cdn.hark.com/images/000/589/442/589442/harry-potter-and-the-sorcerer_small.jpg",
"url":"/harry-potter-and-the-sorcerers-stone"
},
{
"kind":"movie",
@charliemoseley
charliemoseley / neo4j-static-stubber
Created November 18, 2012 22:50
A rudimentary stubber for nodes in Neo4j that needs to understand what type of fields your nodes may have.
require 'faker'
require 'stringex'
module NodeStubber
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def stub_defaults
location = / {
proxy_pass http://clink;
}
location ~* ^/cas/(.*) {
proxy_pass http://clink;
}
location ~* ^/300-the-movie {
proxy_pass http://clink;
}