Skip to content

Instantly share code, notes, and snippets.



View GitHub Profile
View example.js
// Write a function that takes an object. The object contains a left, right and operator properties. The left and right properties are numbers. The operator property is a string. The function should return the result of the operation. The function should return null if the operator is not one of the following: +, -, *, /.
// Example:
// calculate({ left: 1, right: 2, operator: '+' }) // 3
// calculate({ left: 1, right: 2, operator: '-' }) // -1
// calculate({ left: 1, right: 2, operator: '*' }) // 2
// calculate({ left: 1, right: 2, operator: '/' }) // 0.5
// calculate({ left: 1, right: 2, operator: '%' }) // null
View formbot.rb
require 'ostruct'
def send_mail(to:, from:, subject:, body:)
puts "Sending mail to: #{to}"
puts "From: #{from}"
puts "Subject: #{subject}"
puts "Body: #{body}"
module FormBot


This README would normally document whatever steps are necessary to get the application up and running.

Things you may want to cover:

  • Ruby version

  • System dependencies

View work_hour.rb
def permutations(day_hours, missing_days, target)
results = []
values = (0..day_hours).to_a
size = missing_days
puts target
permuts = values.repeated_permutation(size).to_a
permuts.each do |permut|
if permut.inject(:+) == target.to_i
theterminalguy /
Created Aug 12, 2018 — forked from anotheruiguy/
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

theterminalguy / example_activejob.rb
Last active Jun 8, 2018 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
View example_activejob.rb
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
def perform(*args)*args)
View tetris.html
<body onload='setInterval(onkeydown=d=>{
.toString(d=32).replace(/v/,""),d),b=new Date%22?1:3)
<pre id=O>
View .vimrc new
" Leader
let mapleader = " "
set nocompatible " be iMproved, required
set backspace=2
set noswapfile " no swapfile
set ruler " show the cursor position all the time
set nowritebackup
set autowrite
View .zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/simonpeterdamian/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See
# ZSH_THEME="robbyrussell"
View alias_method.rb
module ObjectTracker
module ClassMethods
def track_method(method_name)
alias_method :"#{method_name}_without_tracking", method_name
define_method :"#{method_name}_with_tracking" do |*splat|
params = self.class.instance_method(:"#{method_name}_without_tracking").parameters.collect(&:last)
self.send(:"#{method_name}_without_tracking", *splat) # do method first
self.track_event!(method_name, Hash[*(]) # then track
alias_method method_name, :"#{method_name}_with_tracking"