Skip to content

Instantly share code, notes, and snippets.

$ rspec spec
/Users/foo/.rvm/gems/ruby-2.0.0-p353@bar/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require': cannot load such file -- active_support/base64 (LoadError)
from /Users/foo/.rvm/gems/ruby-2.0.0-p353@bar/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
from /Users/foo/.rvm/gems/ruby-2.0.0-p353@bar/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from /Users/foo/.rvm/gems/ruby-2.0.0-p353@bar/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from /Users/foo/.rvm/gems/ruby-2.0.0-p353@bar/bundler/gems/active_merchant-e555501cba35/lib/active_merchant.rb:33:in `<top (required)>'
from /Users/foo/.rvm/gems/ruby-2.0.0-p353@bar/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from /Users/foo/.rvm/gems/ruby-2.0.0-p353@bar/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
(asdf:operate 'asdf:load-op '#:restas)
(restas:define-module #:restas.hello-world
(:use :cl))
(in-package #:restas.hello-world)
(restas:define-route main ("")
"<h1>Hello world!</h1>")
@arkiver
arkiver / 1_last_of_list.lisp
Last active August 29, 2015 13:56
Simple implementation(s) for finding last element from a list using Common Lisp.
(defun last-of-list (l)
"Returns last element of a list"
(nth (- (list-length l) 1) l))
@arkiver
arkiver / nth_element.lisp
Last active August 29, 2015 13:56
Purely recursive funtion to fetch nth element of list
(defun elek (lst n)
(if (= n 0)
(progn
(car lst))
(elek (rest lst) (- n 1))
)
)
;; CL-USER> (elek '(1 2 3 4) 2)
;; 3
@arkiver
arkiver / no-of-ele.lisp
Last active August 29, 2015 13:56
Return the no of elements in a list
(defun no-of-ele (lst)
"Return the no. of elements in a list"
(if (endp lst)
0
(progn (+ 1 (no-of-ele (rest lst))))
)
)
;; CL-USER> (no-of-ele '(1 2 3))
;; 3
@arkiver
arkiver / auto_scroll.js
Created March 13, 2014 11:07
Browse twitter/facebook handsfree :)
// run this in your browser's console
setInterval(function(){window.scrollBy(0, 1), 4000 })
// not well tested
irb(main):012:0> Date.today
=> Thu, 09 Jul 2015
irb(main):013:0> Date.tomorrow
=> Sat, 11 Jul 2015
irb(main):014:0> Date.today.tomorrow
=> Fri, 10 Jul 2015
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# Destructive! Use carefully.
# merged branches
((`git branch --merge master`).strip!.split(' ') - ['master', 'release']).map{ |b| `git branch -D "#{b}"; git push origin :"#{b}"` }
# All local branches
((`git branch`).strip!.split(' ') - ['master', 'release', 'development']).map{ |b| `git branch -D "#{b}"; git push origin :"#{b}"` }
@arkiver
arkiver / replace.pl
Last active March 22, 2016 19:12
Replace all occurrences of and with && in all ruby files in current directory
perl -pi -w -e 's/ and/ &&/g;' *.rb