Skip to content

Instantly share code, notes, and snippets.

View Arkham's full-sized avatar
🏠
Working from home

Ju Liu Arkham

🏠
Working from home
View GitHub Profile
@Arkham
Arkham / gist:5461609
Created April 25, 2013 17:44
Numbers
"one"
"two"
"three"
"four"
"five"
"six"
"seven"
"eight"
"nine"
"ten"
[10:43] arkham ~/code/vintage-contemporaneo [2.0.0-p0] (master)
↳ $ rspec spec/models/admin_user_spec.rb
/Users/arkham/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- activeadmin-gallery (LoadError)
from /Users/arkham/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/arkham/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/arkham/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/arkham/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /Users/arkham/code/vintage-contemporaneo/spec/model_spec_helper.rb:11:in `<top (required)>'
from /Users/arkham/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45
@Arkham
Arkham / gist:5592899
Created May 16, 2013 16:08
active_admin monkey patch
module ActiveAdmin
module Views
class PaginatedCollection < ActiveAdmin::Component
protected
def build_pagination_with_formats(options)
div :id => "index_footer" do
build_pagination
div(page_entries_info(options).html_safe, :class => "pagination_information")
class SearchPlaces
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :lat, :lng, :distance, :address
attr_accessor :query
attr_accessor :type_id
attr_accessor :category_id
@Arkham
Arkham / memeorama.md
Last active December 30, 2015 00:49
Meme-O-Rama

Meme-O-Rama!

The Basics

Setup a new Rails app and start it

  • rails new memeorama
  • rails server

Create our first scaffold

  • rails generate scaffold meme name:string description:text picture:string
@Arkham
Arkham / rename_clean.sh
Created January 9, 2014 15:36
Rename files removing extra characters
#! /bin/bash
set -e
DIR=${1:-.}
PRUNED_CHARS=":?"
find $DIR -type f -print | while read filename
do
cleaned=${filename//[$PRUNED_CHARS]/}
@Arkham
Arkham / calc.erl
Created January 14, 2014 16:25
Reverse Polish Notation calculator
-module(calc).
-export([rpn/1, rpn_test/0]).
rpn(L) when is_list(L) ->
[Result] = lists:foldl(fun rpn/2, [], string:tokens(L, " ")),
Result.
read(Val) ->
case string:to_float(Val) of
{error, no_float} -> list_to_integer(Val);
@Arkham
Arkham / gist:8556546
Created January 22, 2014 10:28
postgres recursive queries
WITH RECURSIVE friendship_tree(id, name, path) AS (
SELECT id, name, ARRAY[id]
FROM members
WHERE members.h1 LIKE '%Cortina%'
UNION ALL
SELECT members.id, members.name, path || members.id
FROM friendship_tree
JOIN friendships ON friendships.friend_id = friendship_tree.id
JOIN members ON members.id = friendships.member_id
WHERE NOT members.id = ANY(path)
@Arkham
Arkham / vimrc
Created March 24, 2014 16:50
Convert old rspec should syntax to new expect syntax
function! ConvertShouldToExpect()
let rspec_conversions = {
\ 'should': 'to',
\ 'should_not': 'not_to',
\ 'should_receive': 'to receive',
\ 'should_not_receive': 'not_to receive',
\ }
for [old, new] in items(rspec_conversions)
execute "normal! " . ':%s/\v^(\s+)(.+)\.' . old . '>/\1expect(\2).' . new . '/ge' . "\<CR>"
@Arkham
Arkham / remote.md
Last active November 25, 2023 09:34
Remote, office not required

Remote, Office Not Required

The Time is Right for Remote Work

Why work doesn't happen at work

The office during the day has become the last place people want to be when then really want to get work done.

Offices have become interruption factories: it's just one interruption after