Skip to content

Instantly share code, notes, and snippets.

View aaronlifton's full-sized avatar

Aaron Lifton aaronlifton

View GitHub Profile
@p1nox
p1nox / application_controller.rb
Last active February 24, 2017 19:04
Using Cookies.js and jquery.base64.js to parse a signed cookie generated by Rails into an JavaScript Object
# ... after succesful login
def set_current_user_cookie( user )
client_side_user_obj = { id: user.id, email: user.email }
cookies.signed[:_application_alt_session] = client_side_user_obj.to_json
end
# ...
@skolf
skolf / Gemfile
Created June 19, 2014 22:10
A Rake task for precompiling assets in a Sinatra app using Sprockets.
source 'http://rubygems.org'
# app base
gem 'logger'
gem 'rack'
gem 'sinatra'
gem 'sinatra-assetpack'
gem 'sprockets'
gem 'sprockets-helpers'
<script>
(function() {
'use strict';
angular.module('TRKUA').directive('isolateScroll', function () {
return {
restrict: 'A',
link: function ($scope, element, attrs) {
element.on('mousewheel DOMMouseScroll', function (e) {
var delta = e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.detail,
bottomOverflow = this.scrollTop + $(this).outerHeight() - this.scrollHeight >= 0,
@hallettj
hallettj / routes.elm
Last active May 30, 2017 19:52
Example of a graph in Elm
import Html exposing (text)
import List exposing (concatMap, filter)
import List.Extra exposing (uniqueBy)
type alias CityId = Int
type alias City =
{ id: CityId
, name: String
}
@ChristianPeters
ChristianPeters / config-application.rb
Created April 16, 2012 12:29
Adapted for Rails Asset Pipeline: Split CSS files so that there are no more than a given number of selectors in one style sheet. This is a tool to cope with Internet Explorer's limitation of max. 4095 selectors per stylesheet.
#...
module MyProject
class Application < Rails::Application
config.assets.precompile += %w( ie6.css ie6_portion2.css ie7.css ie7_portion2.css ie8.css ie8_portion2.css ie9.css ie9_portion2.css)
#...
@cmbankester
cmbankester / install.sh
Last active August 16, 2017 20:32
Nginx w/ Passenger & Ngx Pagespeed
# Install some deps with yum
yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel libcurl-devel
# Install ngx_pagespeed
cd /usr/local/src
NPS_VERSION=1.9.32.2
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip
unzip release-${NPS_VERSION}-beta.zip
cd ngx_pagespeed-release-${NPS_VERSION}-beta/
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
@seabre
seabre / cur_time_sql.rb
Created December 7, 2011 19:58
Format Time in Ruby for SQL Datetime Comparison
#Gets current time, then formats current time for SQL.
Time.now.to_s(:db)
@runeleaf
runeleaf / 000_common.sh
Last active October 26, 2017 08:41
nginx+spdy+pagespeed+passenger(ruby2.0+rails4)+varnish
rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/ius-release-1.0-11.ius.el6.noarch.rpm
yum -y install vim git wget curl-devel curl
yum -y install gcc-c++ pcre-devel zlib-devel make ncurses-devel
yum -y install yum-plugin-replace
yum -y install openssl-devel
yum replace openssl --replace-with=openssl10
@joedee
joedee / aws_config.json
Last active December 2, 2017 21:06
File upload to S3 with Hapi
{ "accessKeyId": "yourkey", "secretAccessKey": "yoursecretkey", "region": "us-east-1" }
@erikaxel
erikaxel / a_setup.md
Last active December 9, 2017 19:25
Rails Engine with RSpec and Trailblazer

This example is called "stock". Use your own name instead.

  1. Setup new project: rails plugin new stock --mountable -T --dummy-path=spec/dummy
  2. Edit gemspec
  3. Edit engine.rb
  4. Install RSpec: bundle install rails generate rspec:install
  5. Make edits to spec/rails_helper.rb according to: http://blog.honeybadger.io/rails4-engine-controller-specs/