Skip to content

Instantly share code, notes, and snippets.

@dejan
dejan / README.txt
Created September 23, 2009 23:47 — forked from rmm5t/README.md
You can represent time statements in most western languages where
a prefix and/or suffix is used.
The default case is to use suffix only (as in English), which you
do by providing the `suffixAgo` and `suffixFromNow` settings in
the strings hash (earlier versions of timeago used the deprecated
`ago` and `fromNow` options). If present, they are used.
2 minutes [suffixAgo]
2 minutes [suffixFromNow]
# Resolving permission corruption
chmod -R 755 photos
find photos/ -type f -perm 755 -print0 | xargs -0 chmod 644
@dejan
dejan / rmagick on snow leopard
Created April 12, 2010 12:03
rmagick on snow leopard
#!/bin/sh
# http://onrails.org/articles/2009/09/04/rmagick-from-source-on-snow-leopard
# install wget, which is cleverer than curl
# curl -O http://ftp.gnu.org/gnu/wget/wget-1.11.tar.gz
# tar zxvf wget-1.11.tar.gz
# cd wget-1.11
# ./configure --prefix=/usr/local
# make
@dejan
dejan / campfire-emoji.txt
Created October 19, 2011 14:40 — forked from bryanl/campfire-emoji.txt
campfire emoji
Surround these with : e.g. :calling:
+1
-1
bulb
calling
clap
cop
email
feet
@dejan
dejan / whatevers.css.scss
Created July 21, 2012 15:58 — forked from justinfrench/whatevers.css.scss
Bootstrap mixins
@import "twitter/bootstrap";
.whatever {
@extend .well;
}
@dejan
dejan / gist:3913203
Created October 18, 2012 16:51
SF CollectionSelectInput monkey patch
# This is a monkey patch for the SimpleForm issue (actually it's a Rails' collection_select issue)
# of adding attributes to select options. Downside is that you loose value/label_method options,
# but that's easily replacable by using map on the collection (and should be done in some decorator anyways).
# See here for more details about the issue: https://github.com/plataformatec/simple_form/issues/188
module SimpleForm
module Inputs
class CollectionSelectInput < CollectionInput
def input
@builder.select attribute_name, collection, input_options, input_html_options
end
@dejan
dejan / auto_html.html.haml
Created February 14, 2013 16:36
auto_html demo
- title = 'auto_html demo'
- content_for :title, title
.page-header
%h1
.pull-right
.btn-group
= link_to 'article', '/2010/08/15/auto_html', class: 'btn'
= link_to 'source', 'https://github.com/dejan/auto_html', class: 'btn'
@dejan
dejan / WTF Rails
Last active December 23, 2015 04:48
[18] pry(main)> expense.errors.keys
=> []
[19] pry(main)> expense.errors[:something]
=> []
[20] pry(main)> expense.errors.keys
=> [:something] ### !!! so getter on L19 changed the state
[21] pry(main)> expense.errors.has_key? :something
package main
// using asymmetric crypto/RSA keys
import (
"fmt"
"io/ioutil"
"log"
"net/http"
@dejan
dejan / compression.scala
Created August 24, 2014 22:51
Scala challenge #1
// Solution to Pere's first Scala challenge
// by Dejan
object Compression {
// Drops element ++el++ and all its consecutive appearances in head of the list ++li++
def chop(li: List[Any], el: Any) = {
li dropWhile (_ == el)
}
// Eliminates consecutive duplicates of list elements