Skip to content

Instantly share code, notes, and snippets.

@lazybios
lazybios / registrations_controller.rb
Created January 7, 2016 02:40 — forked from jwo/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
{
"images": [
{
"startdate": "20160106",
"fullstartdate": "201601060800",
"enddate": "20160107",
"url": "http://s.cn.bing.net/az/hprichbg/rb/SmoketreeDew_EN-US15933564921_1920x1080.jpg",
"urlbase": "/az/hprichbg/rb/SmoketreeDew_EN-US15933564921",
"copyright": "Dew on the leaf of a smoke tree (© Jogchum Reitsma/Minden Pictures)",
"copyrightlink": "http://www.bing.com/search?q=dew+(condensation)&form=hpcapt&filters=HpDate:%2220160106_0800%22",
@lazybios
lazybios / things.rb
Created December 29, 2015 04:52
a script to analyze your Things app
#!/usr/bin/env ruby
# Usuage
# things 'thisweek'
# things 'lastweek'
# things 'thismonth'
require 'fileutils'
require 'date'
# please install the following 5 gems.
@lazybios
lazybios / .railsrc
Created December 21, 2015 10:48 — forked from ivanoats/.railsrc
# .railsrc
-B #Skip Bundle
-T #Skip Test-Unit
-d postgresql #Use postgres
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
require 'mina/unicorn'
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
@lazybios
lazybios / Rakefile
Created October 20, 2015 00:20 — forked from jerodsanto/Rakefile
A code dump showing how we generate "The Changelog Weekly" using the Trello API
require "rubygems"
require "bundler"
require_relative "lib/importer"
Bundler.setup
desc "Import from Trello board"
task :import do
Importer.new(File.dirname(__FILE__)).import ENV["ISSUE"]
end
@lazybios
lazybios / digital_ocean_setup.md
Created October 16, 2015 14:38 — forked from ChuckJHardy/digital_ocean_setup.md
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions

DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3

SSH into Root

$ ssh root@123.123.123.123

Change Root Password

https://github.com/rails/rails-dev-box
nginx
mongodb
@lazybios
lazybios / gist:e58a0e208b804e6c368a
Created October 6, 2015 09:39 — forked from BenjaminKim/gist:6590816
Calculate average of response time in Rails 3 server.
cat log/production.log| grep "^Completed .* in [0-9]*ms .*" | sed "s/.* in \([0-9]*\)ms.*/\1/" | awk '{ s += $1 } END { print "sum: ", s, " average: ", s/NR, " samples: ", NR }'
@lazybios
lazybios / route.sh
Created September 28, 2015 15:12 — forked from kevinzhow/route.sh
AnyConnect 路由表
route = 8.0.0.0/255.0.0.0
route = 58.0.0.0/255.0.0.0
route = 23.0.0.0/255.0.0.0
route = 117.0.0.0/255.0.0.0
route = 199.0.0.0/255.0.0.0
route = 190.0.0.0/255.0.0.0
route = 198.0.0.0/255.0.0.0
route = 173.0.0.0/255.0.0.0
route = 174.0.0.0/255.0.0.0
route = 168.0.0.0/255.0.0.0