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 / foo.sh
Last active February 11, 2017 17:22
#!/usr/bin/env bash
CMD=${1:-false}
URL=${2:-example.com}
if [ $CMD = false ]; then
echo "usage: " $0 "command [url:example.com]"
exit 1
fi
require 'rubygems'
require 'pry'
$nodes = Hash.new
class Index
attr_reader :children, :name
attr_accessor :parent
def initialize(size, name, children = Array.new)

Keybase proof

I hereby claim:

  • I am nhocki on github.
  • I am nhocki (https://keybase.io/nhocki) on keybase.
  • I have a public key ASAapzaRg-je5LhP7oDwNcUwVtbKVeEBCsezA2gZUQL60Ao

To claim this, I am signing this object:

@nhocki
nhocki / bitly.coffee
Created October 22, 2016 18:10
Bitly library for Hubot
# Bit.ly shortener
#
# Configuration:
# HUBOT_BITLY_ACCESS_TOKEN
module.exports = (robot) ->
shorten: (url, callback) ->
robot.http("https://api-ssl.bitly.com/v3/shorten")
.query
access_token: process.env.HUBOT_BITLY_ACCESS_TOKEN
format: "json"
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxRequestWorkers: maximum number of server processes allowed to start
# MaxConnectionsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
@nhocki
nhocki / introrx.md
Created May 9, 2016 22:14 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@nhocki
nhocki / poller.go
Last active December 2, 2023 11:38
Simple task scheduling with Redis & Go. Similar to Sidekiq's `perform_in` and `perform_at`.
// poller.go
package main
import (
"fmt"
"os"
"os/signal"
"time"
@nhocki
nhocki / .env.example
Last active November 4, 2015 00:31
PubNub concept
PUBNUB_PUBLISH_KEY=YourPublishKey
PUBNUB_SUBSCRIBE_KEY=YourSubscribeKey
# app/models/puntos.rb
class Puntos < AR::Base
PUNTOS_ALL_KEY = "all_puntos".freeze
after_save :expire_cache
after_destroy :expire_cache
# Guarda un arreglo de hashes con el JSON pa mandar.
def self.all_cached
Rails.cache.fetch(PUNTOS_ALL_KEY) do
@nhocki
nhocki / aho_corasick.cpp
Created April 2, 2015 04:00
Aho-Corasick Algorithm in C++
///////////////////////////////////////////////////////////////
// Aho-Corasick's algorithm, as explained in //
// http://dx.doi.org/10.1145/360825.360855 //
///////////////////////////////////////////////////////////////
// Max number of states in the matching machine.
// Should be equal to the sum of the length of all keywords.
const int MAXS = 6 * 50 + 10;
// Number of characters in the alphabet.