Skip to content

Instantly share code, notes, and snippets.

View Spaceghost's full-sized avatar
👻
Building distributed and decentralized systems that run in the browser

Johnneylee Jack Rollins Spaceghost

👻
Building distributed and decentralized systems that run in the browser
View GitHub Profile
class UserCreator
def initialize(listener)
@listener = listener
end
def create(attributes)
user = User.new(attributes)
if user.save
# send email
@avdi
avdi / recruiter_message.txt
Created March 19, 2012 07:10
My best recruiter email yet
Dear IT Professional,
We have the following position provided below available.
Skills: Ruby on Rails
Location: Atlanta, GA
They will talk to anyone who has RUBY.
This digital start-up is searching for a progressive Software Engineer
@mpapis
mpapis / osx_rails_env_setup_in_1_step.md
Created March 30, 2012 04:54 — forked from solnic/osx_rails_env_setup_in_6_steps.md
One step to get up'n'running with Rails on OS X or Linux

Use this command and follow the instructions:

curl -L get.rvm.io | bash -s stable --rails

Other options include(any gems imply --ruby):

--ruby=1.9.3
--gems=rails,gist

Optionally on OSX install homebrew, use brew command to install whatever database engine you need, ie brew install sqlite

module PubSub
class << self
def create type, channel, object
channel = channel.to_sym
case type
when :listener
listeners[channel] ||= Array.new
listeners[channel] << object
channels[channel] ||= Array.new
@pengwynn
pengwynn / octocat_zen.sh
Created November 14, 2012 02:42
GitHub Zen
$ curl https://api.github.com/zen | octocatsay
MMM. .MMM
MMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMM ____________________________
MMMMMMMMMMMMMMMMMMMMM | |
MMMMMMMMMMMMMMMMMMMMMMM | Practicality beats purity. |
MMMMMMMMMMMMMMMMMMMMMMMM |_ ________________________|
MMMM::- -:::::::- -::MMMM |/
MM~:~ ~:::::~ ~:~MM
@tagrudev
tagrudev / yolo
Last active May 13, 2017 13:51
YOLO practices #RubyOnRails
# Do not refactor, it is a bad practice. YOLO
# Not understanding why or how something works is always good. YOLO
# Do not ever test your code yourself, just ask. YOLO
# No one is going to read your code, at any point don't comment. YOLO
# Why do it the easy way when you can reinvent the wheel? Future-proofing is for pussies. YOLO
###
# Scheme code is translated to YARV byte code, then evaluated in the
# Ruby Virtual Machine
require 'rbconfig'
require 'dl'
require 'fiddle'
require 'strscan'
class RubyVM
@bsodmike
bsodmike / gist:4525870
Last active October 26, 2017 10:32
Differences Between Unit, Functional, and Integration Testing

The difference between those are that unit tests one object and one object only. Typically mocking anything else outside the SUT (System under test).

Integration tests a system of collaborators, or multiple objects that work in concert. Functional tests a system from the outside into the centre as a full stack test. User stories test interactions and outcomes.

The difference between functional and user stories is that a functional test exercises a system with a focus of "given this kind of input, I expect this output back" and user story is more focused on "When I perform this kind of thing, given the system is in this kind of state or has this data, I expect to see this kind of thing as a result."

Functional can also test the side-effects rather than just the input and output.

@minhajuddin
minhajuddin / ticker.ex
Created November 29, 2016 13:32
A simple GenServer to do some work every few seconds
# Ticker
defmodule Ticker do
use GenServer
def start_link(%{module: module, function: function, interval: interval} = state)
when is_atom(module) and is_atom(function) and is_integer(interval) and interval > 0 do
GenServer.start_link(__MODULE__, state)
end
def init(state) do
@davidcelis
davidcelis / zelda-battery.sh
Created December 18, 2012 00:28
Output a Zelda-style heart meter for your MacBook's battery level. On the command line. Based on an idea from @stephencelis, executed by myself. For a tmux version, see https://gist.github.com/4324139
#!/usr/bin/env zsh
#
# Works best with blinking text; the last heart will blink
# when you have less than 25% of your battery life remaining.
BATTERY="$(pmset -g ps | awk 'NR==2' | perl -pe 's/.*?(\d+)%.*/\1/')"
if [[ $BATTERY -lt 25 ]]; then
echo "\e[5;31m♥\e[0;31m♡♡\e[0m"
elif [[ $BATTERY -lt 50 ]]; then