Skip to content

Instantly share code, notes, and snippets.

@sethyanow
sethyanow / .spacemacs
Created August 22, 2015 22:35
spacemacs config
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration."
(setq-default
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (i.e. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '()
sudo chsh -s $(which zsh) $(whoami)
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@sethyanow
sethyanow / thermo.ino
Created October 10, 2014 23:42
Thermostat
/*
Thermo
Seth
It's a really hacky thermostat, getting cold outside
*/
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@sethyanow
sethyanow / fib.rb
Last active August 29, 2015 14:06
fibonacci enumerator
# fib should return an enumeration over the fibonacci numbers
def fib()
Enumerator.new do |f|
a = b = 1
loop do
f << a
a, b = b, a + b
end
end
@sethyanow
sethyanow / rot13.rb
Last active August 29, 2015 14:06
it's a simple rot13 in ruby
def rot13(string)
string.bytes.map { |n|
if n.between?(78, 90) || n.between?(110, 122)
(n - 13).chr
elsif n.between?(65, 89) || n.between?(97, 109)
(n + 13).chr
else
n.chr
end
}.join
@sethyanow
sethyanow / base_adapter.rb
Last active July 29, 2016 21:51
BaseCRM lead sorting hat
class BaseAdapter
attr_accessor :session
def initialize
@session = BaseCrm::Session.new('your_key')
end
def leads
@session.leads.all
end
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
# from the cache for up to 1 hour.
# 2. Varnish will pass X-Forwarded-For headers through to the backend
# 3. Varnish will remove cookies from urls that match static content file
# extensions (jpg, gif, ...)