Skip to content

Instantly share code, notes, and snippets.

View TRex22's full-sized avatar
🎮
Life

Jason Chalom TRex22

🎮
Life
View GitHub Profile
@TRex22
TRex22 / useful_ruby_rails_console_tricks.md
Last active May 16, 2025 07:11
Useful Ruby/Rails console tricks

Get all records in state

Rails.application.eager_load!
ActiveRecord::Base.subclasses(&:name)

Get last console output

variable = _

Run a rails console in Sandbox mode

@TRex22
TRex22 / kill_rails_processes.sh
Created August 21, 2018 11:01
Stop and kill processes that start with certain rails config - sidekiq and other services
#/bin/bash
./bin/spring stop
kill -9 $(lsof -i tcp:6379 -t)
kill -9 $(lsof -i tcp:3000 -t)
kill -9 $(lsof -i tcp:45449 -t)
kill -9 $(lsof -i tcp:8888 -t)
@TRex22
TRex22 / single_thread_start.sh
Created July 16, 2018 08:45
Start Rails, Redis and Sidekiq whilst not tying up the console to help with debugging - this is for development use
#!/usr/bin/env sh
echo "Starting Redis-Server in the background ..."
nohup redis-server --save "" --appendonly no > log/redis_server_dev_nohup.log &
echo "Starting Sidekiq in the background ..."
nohup bundle exec sidekiq -C config/sidekiq.yml > log/sidekiq_dev_nohup.log &
nohup bundle exec sidekiq -C config/sidekiq-serial.yml > log/sidekiq_dev_nohup.log &
nohup bundle exec sidekiq -C config/sidekiq-reports.yml > log/sidekiq_dev_nohup.log &
echo "Starting Server ..."
@TRex22
TRex22 / git_addall.sh
Created April 4, 2018 08:21
A bash script to help with ruby on rails development. It will warn you when there is a `focus` or a `binding.pry` being staged in your code. Future versions of this will use variables and maybe identify the specific code (I dont really have plans for any of this atm)
#!/bin/bash
# git config --global alias.addall '! ~/git_addall.sh'
git diff|grep 'focus' --color
git diff --name-only | xargs grep --color -Hn focus
git diff|grep 'binding.pry' --color
git diff --name-only | xargs grep --color -Hn binding.pry
git add --all
git status
@TRex22
TRex22 / fix-brew.md
Last active September 1, 2018 06:26
Fixing Homebrew, rails (rvm) and any other dev environment stuff after a mac machine transfer or some other disaster

Some hints and tips and things to try when something goes awry with Homebrew, gem or npm

If dtrace is not working correctly when trying to build packages (like gems or npm packages)

rvm install 2.3.5 -- --disable-dtrace

You can write the installed brews to a list on your old machine:

@TRex22
TRex22 / happy_git_on_osx.md
Last active February 5, 2018 14:42 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

@TRex22
TRex22 / PyFM_Player_Makezine.py
Created June 7, 2017 10:22
PIFM Make Magazine Player edited for a project I am working on
#!/usr/bin/env python
# Pirate Radio
# Author: Wynter Woods (Make Magazine)
# Edited by @TRex22 (Jason Chalom)
import os
import sys
import subprocess
import configparser
import re
@TRex22
TRex22 / slack_history.py
Created March 7, 2017 11:35 — forked from Chandler/slack_history.py
Download Slack Channel/PrivateChannel/DirectMessage History
# MIT License
# Copyright (c) 2016 Chandler Abraham
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@TRex22
TRex22 / example.js
Created September 25, 2016 20:30 — forked from swarajgiri/example.js
example
function mySexyMethod() {
return new Promise(function (resolve, reject) {
someAsync.method(params, function (err, data) {
if (err) {
return reject(err);
}
resolve(data);
})
});
@TRex22
TRex22 / baseController.js
Last active December 14, 2015 08:32
AngularJs Pagination ... with some hacks. Pretty much used for older version of Angular (very old versions)
//pagination for all
$scope.pagination = {};
$scope.pagination.pageSize = 3;
$scope.pagination.currentPage = 1;
$scope.pagination.totalPages = 1;
$scope.pagination.totalItems = 0;
$scope.pagination.hasNextPage = false;
$scope.pagination.hasPreviousPage = false;
function firstPage(fn){