Skip to content

Instantly share code, notes, and snippets.

@theprogrammerin
theprogrammerin / loadDev.js
Created March 13, 2014 06:46
Load Jquery & Underscore via console
function loadDev(){
var jq = document.createElement("script");
jq.setAttribute("src","http://code.jquery.com/jquery-2.1.0.js")
document.head.appendChild(jq);
var us = document.createElement("script");
us.setAttribute("src","http://underscorejs.org/underscore.js")
document.head.appendChild(us);
console.log("Loaded Jquery and Underscore")
}
loadDev()
## IMPORTANT -> The expectation must come before the invocation, so that it can catch the invocation when it happens
# Able to stub an instance's method. Will return whatever is in the block. The instance's method would have to be invoked in the RSpec.
@person.stub(:get_relevant_experts) { @collection_of_possibilities }
# Expectation of an instance that is available in the testing context to receive a particular method, choose return value
expect(@person).to receive(:get_relevant_experts).with("Medical").and_return(@collection_of_possibilities)
# Expectation of an instance to receive a method and return a result
expect_any_instance_of(Classification).to receive(:valid_matches).and_return(@collection_of_possibilities)
@bootcoder
bootcoder / .bash_profile
Last active December 12, 2020 13:17
bash_profile - rbenv
# echo is like puts for bash (bash is the program running in your terminal)
echo "Loading ~/.bash_profile a shell script that runs in every new terminal you open"
# $VARIABLE will render before the rest of the command is executed
echo "Logged in as $USER at $(hostname)"
# Rbenv autocomplete and shims
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# Path for RBENV
test -d $HOME/.rbenv/ && PATH="$HOME/.rbenv/bin:$PATH"
@jaywon
jaywon / job-import.js
Created November 10, 2015 22:16
CSV import utility for Node
var fs = require('fs');
var csv = require('fast-csv');
var stream = fs.createReadStream('/home/jaywon/Downloads/modified-salary-per-state-per-jobtitle.csv');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var masterList = [];
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/job-imports');
//define schema for import data
@manjula-dube
manjula-dube / .eslintrc.js
Created February 6, 2018 15:55
.eslintrc.js
// use this format since .eslintrc is deprecated.
// You can logically derive this format.
module.exports = {
parser: 'babel-eslint',
extends: [
'plugin:flowtype/recommended',
'plugin:jest/recommended',
'plugin:react/recommended',
'eslint-config-airbnb',
@chrissimpkins
chrissimpkins / gist:5bf5686bae86b8129bee
Last active March 6, 2023 00:10
Atom Editor Cheat Sheet: macOS

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on macOS.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@jessieay
jessieay / ActiveRecord Cheat Sheet v1
Created July 17, 2012 19:55
Active Record cheat sheet with examples of queries I've needed most so far
ActiveRecord cheat sheet / EXAMPLES
INSTALL
=======
$ gem install activerecord
in GEMFILE: gem ‘activerecord’
REQUIRE
=======
require ‘active_record’
@aspyct
aspyct / sort.rb
Last active October 29, 2023 03:08
Ruby implementation of quicksort, mergesort and binary search
# Sample implementation of quicksort and mergesort in ruby
# Both algorithm sort in O(n * lg(n)) time
# Quicksort works inplace, where mergesort works in a new array
def quicksort(array, from=0, to=nil)
if to == nil
# Sort the whole array, by default
to = array.count - 1
end
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@stevenyap
stevenyap / Rails Controller.md
Created October 19, 2013 13:58
Rails controller cheatsheet

Flash

# supports only notice and alert by default
# the rest has to go into flash hash
redirect_to :index, notice: "success"
redirect_to :new, notice: "errors"
redirect_to :new, flash: { success: "yeah" }
flash[:info] = "updated"