Skip to content

Instantly share code, notes, and snippets.

@mankind
mankind / rails_nodejs_install.sh
Last active August 29, 2015 14:01
script to install ruby, rails and nodejs. Run the script.
# install using the line below in your terminal
# wget --no-check-certificate https://gist.githubusercontent.com/mankind/3926ea58d2172c260f21/raw/0b426c12c04f75dc78e51e0b556421070801ddae/rails_nodejs_install.sh && bash rails_nodejs_install.sh
echo "======================================="
echo "========= updating Packages repo ========="
echo "======================================="
sudo apt-get -y update && apt-get upgrade
@mankind
mankind / ruby_dependencies.sh
Last active August 29, 2015 14:02
install ruby dependencies
# install using the line below in your terminal
#wget --no-check-certificate https://gist.githubusercontent.com/mankind/f44f8232f5d23a774bae/raw/1f53948207b9ff97cf55954f26b2069096b4d82b/ruby_dependencies.sh && bash ruby_dependencies.sh
echo "======================================="
echo "========= updating Packages repo ========="
echo "======================================="
sudo apt-get -y update && apt-get upgrade
@mankind
mankind / rbenv_install.sh
Last active August 29, 2015 14:02
install rbenv
#https://github.com/fesplugas/rbenv-installer/blob/master/bin/rbenv-installer
#wget --no-check-certificate https://gist.githubusercontent.com/mankind/de9ef556a579f3980dea/raw/301942dcfd869879d9b1f7224d4bb52d78813bec/rbenv_install.sh && bash rbenv_install.sh
sudo apt-get -y update && apt-get upgrade
echo "======================================="
echo "========= Cloning Rbenv ========="
echo "======================================="
# https://gorails.com/setup/ubuntu/13.10
@mankind
mankind / session_controller.rb
Created November 2, 2014 15:25
devise session controller
class SessionsController < Devise::SessionsController
#fix Filter chain halted as :require_no_authentication
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
#to tackle: Filter chain halted as :verify_signed_out_user
skip_before_filter :verify_signed_out_user, only: :destroy
# disable it for everything except a few methods
#skip_before_action :verify_authenticity_token, :only => :create
@mankind
mankind / controller--application.js
Created November 4, 2014 12:24
ember-cli authentication & user signup
// controllers/application.js
import Ember from 'ember';
export default Ember.Controller.extend({
currentUser: null,
authToken: '',
// used to show, or not show, the log out button
loggedIn: false,
@mankind
mankind / route.rb
Created November 4, 2014 14:04
namespaceing devise_for user but not current_user helper
namespace :api do
#when devise_for is called in a namespace, the helpers and controller filters change
#:singular => :user added so we can use current_user instead of current_api_user.
#And before_filter authenticate_user! instead of authenticate_api_user!
#https://github.com/plataformatec/devise/issues/412
#devise_for :users, :singular => :user, skip: :all
get :csrf, to: 'csrf#index'
resources :users
@mankind
mankind / attachments.hbs
Created November 18, 2014 09:53
Emberjs file upload with HTML-5 formData
{{upload-file action="saveUpload"}}
@mankind
mankind / cms.js
Last active August 29, 2015 14:14
emberjs course
ember new cms
ember generate model page navbar:string title:string body:string
import DS from 'ember-data';
export default DS.Model.extend({
navbar: DS.attr('string'),
title: DS.attr('string'),
body: DS.attr('string'),
//https://github.com/maccman/abba/blob/master/app/assets/javascripts/client/index.coffee
var extend, getCookie, host, request, setCookie,
slice = [].slice;
host = function(url) {
var parent, parser;
parent = document.createElement('div');
parent.innerHTML = "<a href=\"" + url + "\">x</a>";
parser = parent.firstChild;
return "" + parser.host;
@mankind
mankind / gTest.R
Created July 27, 2015 08:49
GTEST CALCULATION WITH R
#https://rforge.net/doc/packages/Deducer/likelihood.test.html
#http://www.pmc.ucsc.edu/~mclapham/Rtips/G%20test.txt
# Log-likelihood tests of independence & goodness of fit
# Does Williams' and Yates' correction
# does Monte Carlo simulation of p-values, via gtestsim.c
#
# G & q calculation from Sokal & Rohlf (1995) Biometry 3rd ed.
# TOI Yates' correction taken from Mike Camann's 2x2 G-test fn.
# GOF Yates' correction as described in Zar (2000)