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

@JoeNoPhoto
JoeNoPhoto / rails_postgres_enum.rb
Created September 12, 2018 06:30 — forked from theaxel/rails_postgres_enum.rb
Support for PostgreSQL enum types in Rails 5.2 (including schema dump)
# Support for PostgreSQL enum types in Rails 5.2 (including schema dump)
module ActiveRecord
class SchemaDumper
def dump(stream)
header(stream)
extensions(stream)
enums(stream)
tables(stream)
trailer(stream)
stream
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
# /Users/JoeNoPhoto/Virtualenvs/nfldb/lib/python2.7/site-packages/nflgame/update_players.py:179:
last_name, first_name = map(lambda s: s.strip(), name.split(','))[:2]
#> psql nfldb -U nfldb
insert into team values('JAX','Jacksonville', 'Jaguars');
insert into team values('LAC','Los Angeles', 'Chargers');
#> nfldb-update
#> nflgame-update-players
@JoeNoPhoto
JoeNoPhoto / .bash_profile
Created August 1, 2017 20:00 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
jnp-port [master] $ bower list
bower check-new Checking for new versions of the project dependencies...
foundation-ssg#1.0.0 /Users/JoeNoPhoto/Projects/jnp-port
├── PreloadJS#0.6.2
├── Swiper#3.3.1
├── classie#1.0.1
├── fastclick#1.0.6
├─┬ foundation-sites#6.2.1 (6.2.3 available)
│ ├── jquery#2.1.4 incompatible with ~2.2.0 (2.2.4 available, latest is 3.1.1)
│ └── what-input#2.0.1 (latest is 4.0.1)
@JoeNoPhoto
JoeNoPhoto / action_index.js
Created September 7, 2016 10:45
action and API index.js files for Loading Gallery DATA
import { normalize } from 'normalizr';
import * as schema from './schema';
import * as api from '../api';
import { getIsGalleryLoading } from '../reducers';
// ignore this. I doing console.logs from within my action just to see what kind of data would come from it.
// api.galleryDB.galleries.map(gallery => gallery.name));
// ["Music", "People", "Performers", "World", "BLK", "Design"]
export const loadGalleryData = (gallery) => (dispatch, getState) => {
@JoeNoPhoto
JoeNoPhoto / Avoiding Object Mutations with Object.assign() and ...spread.js
Created August 24, 2016 20:08
use Object.assign() and the spread operator proposed for ES7 to avoid mutating objects.
const toggleTodo = (todo) => {
return {
...todo, // ES7
completed: !todo.completed,
};
/* ES6
return Object.assign({}, todo, {
completed: !todo.completed,
});
@JoeNoPhoto
JoeNoPhoto / Add,Remove, and Increment,Avoiding Array Mutations with concat(), slice(), and ...spread.js
Last active July 5, 2023 09:29
(ES6) Avoiding Array Mutations with concat(), slice(), and ...spread
const addCounter = (list) => {
return [...list, 0];
};
const removeCounter = (list, index) => {\
return [
...list.slice(0, index),
...list.slice(index + 1)
];
};
@JoeNoPhoto
JoeNoPhoto / remPixelFallback.sass
Created October 18, 2015 19:38
REM Units w/ Pixel Fallback
@mixin rem($property, $values...) {
$n: length($values);
$i: 1;
$pxlist: ();
$remlist: ();
@while $i <= $n {
$itemVal: (nth($values, $i));
@if $itemVal != "auto"{