Skip to content

Instantly share code, notes, and snippets.

View he-and-her's full-sized avatar
Value Loyalty. Above. All. Else.

he and her he-and-her

Value Loyalty. Above. All. Else.
View GitHub Profile
@he-and-her
he-and-her / capybara cheat sheet
Created September 5, 2016 21:46 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@he-and-her
he-and-her / gist:911fdfa85e9db3168a93b00233ddde82
Created August 1, 2016 12:47 — forked from WizardOfOgz/gist:1012107
Save Base64-encoded images with Paperclip
class Avatar < ActiveRecord::Base
attr_accessor :content_type, :original_filename, :image_data
before_save :decode_base64_image
has_attached_file :image,
PAPERCLIP_CONFIG.merge(
:styles => {
:thumb => '32x32#',
:medium => '64x64#',
@he-and-her
he-and-her / Rakefile
Created March 23, 2016 21:22 — forked from andyvanee/Rakefile
Rake migrate without rails
require 'active_record'
require 'yaml'
require 'mysql'
require 'logger'
task :default => :migrate
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
task :migrate => :environment do
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
@he-and-her
he-and-her / ssl_puma.sh
Created March 17, 2016 17:34 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@he-and-her
he-and-her / nginxproxy.md
Created March 12, 2016 03:45 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@he-and-her
he-and-her / base_controller.rb
Created March 3, 2016 03:48 — forked from dhoelzgen/base_controller.rb
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@he-and-her
he-and-her / nginx.conf
Created February 11, 2016 03:18 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@he-and-her
he-and-her / IsoCamSetup
Created January 31, 2016 06:11 — forked from KeyMaster-/IsoCamSetup
Isometric view in the luxe engine
//Rotate the camera such that z points up and x to the right
var o:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(-90, 0, 0).radians());
//Rotate by Arctan(sin(45°)) (grabbed from wikipedia) around x, to get the top-down part
var q:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(Math.atan(Math.sin(45 * Maths.DEG2RAD)), 0, 0));
//Rotate around z by -45° to get the side-on part
var p:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(0, 0, -45).radians());
//Combine the rotations and apply to the camera
@he-and-her
he-and-her / binarytree.rb
Created January 7, 2016 14:47 — forked from yuya-takeyama/binarytree.rb
Binary Tree implemented in Ruby.
module BinaryTree
class Node
attr_reader :word, :count, :left, :right
include Enumerable
def initialize(word)
@word, @count = word, 1
end
@he-and-her
he-and-her / audio.rb
Created November 29, 2015 15:49 — forked from phil-monroe/audio.rb
Use CoreAudio with Ruby to make a real time CLI level meter and frequency response chart
require "thread"
require "fftw3"
require "coreaudio"
require 'ruby-progressbar'
# progressbar = ProgressBar.create
# progressbar.total = 100
Thread.abort_on_exception = true