Skip to content

Instantly share code, notes, and snippets.

View nhocki's full-sized avatar
💭
I may be slow to respond.

Nicolás Hock-Isaza nhocki

💭
I may be slow to respond.
View GitHub Profile
@nhocki
nhocki / description_hash.java
Created February 12, 2014 22:22
Description Hash in Ruby & Java
private String descriptionVariable(final String text){
if(isFeatured()){
return "<b>" + text + "</b>";
}else{
return "<b><font color='#FD93B1'>" + text + "</font></b>";
}
}
private Map<String, String> buildDescriptionContext(final JSONObject descriptionHash) throws JSONException, ParseException{
Map<String, String> context = new HashMap<String, String>();
desc "compile and run the site"
task :default do
pids = [
spawn("jekyll serve -w"), # put `auto: true` in your _config.yml
spawn("scss --watch css"),
spawn("coffee -b -w -o js -c coffee/*.coffee")
]
trap "INT" do
Process.kill "INT", *pids
@nhocki
nhocki / keymap.cson
Created March 7, 2014 18:44
Atom keymap
'.editor:not(.mini)':
'ctrl-shift-down': 'rails-rspec:toggle-spec-file'
'cmd-ctrl->': 'editor:add-selection-below'
'.editor':
'alt-cmd-r': 'rails-rspec:toggle-spec-file'
'cmd-shift-R': 'rspec:run-for-line'
'cmd-shift-T': 'rspec:run'
'body':
@nhocki
nhocki / markdown.rb
Created April 2, 2014 02:10
Simple markdown include renderer for Jekyll.
module Jekyll
class MarkdownTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text.strip
end
def html_renderer(config)
@html_renderer ||= Jekyll::Converters::Markdown.new(config)
end
@nhocki
nhocki / fail_brazil.coffee
Created July 9, 2014 15:15
Send a sad brazilian face every time someone says "fail"
# As requested on https://twitter.com/bcardarella/status/486885890837725184
#
# Send a sad brazilian everytime someone says fail. Images from http://sadbrazilians.tumblr.com/
#
# Thanks to Kimono Labs for giving me the JSON to get the images
#
#
images = [
"http://33.media.tumblr.com/75ad65b40e42b9bb0a487d29467e84f3/tumblr_n8f721uO1M1tga27vo1_1280.jpg",
"http://37.media.tumblr.com/6892659fd667d73d9fc395d3b95cff36/tumblr_n8f5ep7d051tga27vo1_1280.jpg",
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cctype>
@nhocki
nhocki / cpptemplate.cpp
Created September 23, 2014 02:06
Topcoder cpp template
using namespace std;
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
@nhocki
nhocki / office_hours.rb
Created October 10, 2014 19:53
Disable something if not on a specific time-frame // day
def office_hours?
Time.use_zone('Pacific Time (US & Canada)') do
# window = Time.zone.parse("2014-04-30")
now = Time.zone.now
start, finish = Time.zone.parse('9:30'), Time.zone.parse('16:30')
now.between?(start, finish) # && now.yday == window.yday
end
end