Skip to content

Instantly share code, notes, and snippets.

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@macouella
macouella / _grid.sass
Created June 21, 2017 07:48
Igi's 3rd party sass hacker kit
.container
position: relative
+desktop
margin: 0 auto
max-width: $desktop - 40px
width: $desktop - 40px
// Modifiers
&.is-fluid
margin: 0 20px
max-width: none

ES6

ECMAScript table

https://kangax.github.io/compat-table/es6/

Block Scoping

A variable can be either of global or local scope. A global variable is a variable declared in the main body of the source code, outside all functions, while a local variable is one declared within the body of a function or a block. Modern versions allow nested lexical scoping.

Let vs var

The difference is scoping. var is scoped to the nearest function block and let is scoped to the nearest enclosing block, which can be smaller than a function block. Both are global if outside any block.

@macouella
macouella / index.js
Created December 11, 2017 11:25
Comparing javascript pubsub frameworks
/**
* EventEmitter x 2,590,624 ops/sec ±4.54% (79 runs sampled)
* EventEmitter2 x 9,239,432 ops/sec ±1.95% (90 runs sampled)
* Mitt x 3,161 ops/sec ±43.29% (10 runs sampled)
* Tiny Emitter x 2,380,065 ops/sec ±1.46% (94 runs sampled)
* PubsubJS x 231,646 ops/sec ±14.09% (64 runs sampled)
* Fastest is EventEmitter2
*/
var Benchmark = require('benchmark');
@macouella
macouella / abandoned_tickets.yml
Last active December 18, 2017 20:52
Show this to Jan because Ruby Factory Girl (js) === Python Factory Boy hahaha
# test/fixtures/abandoned_tickets.yml
<% two_days_ago = Time.now - 2.days %>
abandoned_ticket_one:
company: company_one
user: user_one
abandoned_ticket_two:
company: company_one
user: user_one
@macouella
macouella / persist-ssh-add.md
Last active February 12, 2018 01:33
Persist ssh-add across reboots | Mac OSX

Add to ~/.ssh/config

Host *
  UseKeychain yes
  AddKeysToAgent yes

Add ssh key to keychain

Using /usr/bin/ssh ensures that you use the system ssh-add and not the one installed by brew (if ever)

@macouella
macouella / slow.js
Last active March 11, 2018 08:42
slow.js
for(var x = 0; x < 50000; x++){
console.log(x);
}
@macouella
macouella / requestAnimFrame.js
Last active March 12, 2018 21:02 — forked from joelambert/README
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
window.requestAnimFrame = (function() {
return window.requestAnimationFrame ||
function(/* function */ callback, /* DOMElement */ element){
window.setTimeout(callback, 1000 / 60);
};
})();
const path = require('path');
const pathConfig = require('./path-config.json');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const opn = require('opn');
module.exports = {
html: false,
ghPages: false,
images: true,