Skip to content

Instantly share code, notes, and snippets.

@bigfatgreg
bigfatgreg / xw.rb
Last active September 6, 2020 04:56 — forked from eliotfowler/xw.rb
.puz to xpf-json converter
#!/usr/bin/env ruby
require 'json'
@filename = ARGV[0]
def read_puz(length, offset)
return IO.read(@filename, length, offset)
end
# app / controllers / application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
@bigfatgreg
bigfatgreg / setup.sh
Last active December 19, 2015 18:08 — forked from krisf/setup.sh
#!/bin/bash
# install dependencies
apt-get update && apt-get upgrade
apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
# install RVM
\curl -L https://get.rvm.io | bash
# install ruby 2.0.0
@bigfatgreg
bigfatgreg / unicorn_init.sh
Created October 16, 2012 20:56
unicorn config from railscast
#!/bin/sh
set -e
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/deployer/apps/APP_NAME/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
AS_USER=deployer
set -u
@bigfatgreg
bigfatgreg / unicorn.rb
Created October 16, 2012 20:55
unicorn config
root = "/home/deployer/apps/APP_NAME/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
listen "/tmp/unicorn.blog.sock"
worker_processes 2
timeout 30
@bigfatgreg
bigfatgreg / nginx.conf
Created October 16, 2012 20:52
nginx conf
upstream unicorn {
server unix:/tmp/unicorn.blog.sock fail_timeout=0;
}
server {
listen 80 default deferred;
# server_name example.com;
root /home/deployer/apps/APP_NAME/current/public;
location ^~ /assets/ {
@bigfatgreg
bigfatgreg / deploy.rb
Created October 16, 2012 20:42
Generic Capistrano Recipe from Railscast
server "178.xxx.xxx.xxx", :web, :app, :db, primary: true
set :application, "APP_NAME"
set :user, "deployer"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "[email protected]:eifion/#{application}.git"
@bigfatgreg
bigfatgreg / make_friends.rb
Created October 10, 2012 21:37
rake task for making facebook test users friends with each other
task :make_friends => :environment do
# uses the fb_graph gem to talk to facebook
token = FbGraph::Application.new(AUTH_PARAMS[:facebook_id], :secret => AUTH_PARAMS[:facebook_secret]).get_access_token
link = JSON.parse(open(URI.escape("https://graph.facebook.com/#{AUTH_PARAMS[:facebook_id]}/accounts/test-users?access_token=#{token}")).read)
link['data'].each do |r|
link_beg = "https://graph.facebook.com/" + r['id'] + "/friends/"
link_end = "?method=post&access_token=" + r['access_token']