Skip to content

Instantly share code, notes, and snippets.

[1] pry(#)> self.member = Array.new

=> []

[2] pry(#)> self.member.push( User.find(memberUid.first).dn )

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.push

The code in the ruby file is a little different. The above resulted by removing the each loop for debugging.

# Useful aliases {{{
alias c 'clear'
alias hl 'less -R'
alias paththis 'set PATH (pwd) $PATH'
alias ef 'vim ~/.config/fish/config.fish'
# }}}
# Environment variables {{{
@martinklepsch
martinklepsch / test.js
Created July 11, 2012 20:42
Trying to get an animation from one path to another working here... onclick
window.onload = function(){
var paper = new Raphael("pseudologo", 160, 300),
// shape = paper.circle(80, 140, 50),
circlepath = "M80,40c0,-30 40,-30 40,0z",
rectpath = "M15,179l140,0 0,30 -140,0z",
groovy = { stroke: "none", fill: Raphael.hsl(117, 53, 76), cursor: "pointer" },
dashed = { fill: "green", stroke: "black", "stroke-dasharray": "- " }
testtrigger = paper.circle(20, 20, 20).attr(groovy)
// var rect = paper.path(path2).attr(dashed)
@martinklepsch
martinklepsch / config.fish
Created February 19, 2013 23:04
Add information about the git repository you're in to Fish shell's prompt
# Fish git prompt
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
set __fish_git_prompt_showupstream 'yes'
set __fish_git_prompt_color_branch yellow
# Status Chars
set __fish_git_prompt_char_dirtystate '⚡'
set __fish_git_prompt_char_stagedstate '→'
set __fish_git_prompt_char_stashstate '↩'
@martinklepsch
martinklepsch / AWS S3 Bucket Policy.json
Created February 20, 2013 00:55
a bucket policy to allow everyone getting objects from your bucket. required to use s3 as static site host
{
"Version":"2008-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": {
"AWS": "*"
},
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::www.REPLACE-THIS.org/*"]
/** @jsx React.DOM */
var Thread = React.createClass({
getInitialState: function() {
return {
replies: []
};
},
handleReply: function() {
(ns chaf2.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.core.async :refer [put! chan]]))
(enable-console-print!)
(defn log [obj]
(.log js/console (pr-str obj)))
(defn listen [el ev]
(let [out (chan)]
(events/listen el ev
(fn [e] (put! out e)))
out))
;; My current try
(defn listen [tagsel ev]
(let [out (chan)
els (.getElementsByTagName js/document tagsel)]
@martinklepsch
martinklepsch / random-color.clj
Last active April 23, 2022 20:07
Generate a random HEX color in cojure or clojurescript
(require '[clojure.string :as s])
;; My initial attempt
(def c [:0 :1 :2 :3 :4 :5 :6 :7 :8 :9 :A :B :C :D :E :F])
(str "#" (s/join (map name (repeatedly 6 #(rand-nth c)))))
;; Another option not using keywords (/ht locks in #clojure)
(def c [0 1 2 3 4 5 6 7 8 9 \A \B \C \D \E \F])
(str "#" (s/join (repeatedly 6 #(rand-nth c))))
;; the last line can be simplified even more (/ht xificurC in #clojure)
Started GET "/auth/twitter?use_authorize=true" for 127.0.0.1 at 2014-02-03 17:39:08 +0100
NoMethodError - undefined method `encoding' for nil:NilClass:
/Users/martin/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/cgi/util.rb:7:in `escape'
oauth (0.4.7) lib/oauth/tokens/request_token.rb:28:in `block in build_authorize_url'
oauth (0.4.7) lib/oauth/tokens/request_token.rb:28:in `build_authorize_url'
oauth (0.4.7) lib/oauth/tokens/request_token.rb:9:in `authorize_url'
omniauth-oauth (1.0.1) lib/omniauth/strategies/oauth.rb:36:in `request_phase'
omniauth-twitter (1.0.1) lib/omniauth/strategies/twitter.rb:60:in `request_phase'
omniauth (1.2.1) lib/omniauth/strategy.rb:215:in `request_call'