Skip to content

Instantly share code, notes, and snippets.

Ezekiel Templin ezkl

Block or report user

Report or block ezkl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@karlseguin
karlseguin / dnscache.go
Created Jun 12, 2013
Cache DNS responses and refresh them using a single goroutine on a 1 minute timer. Avoids having a spike of threads from cgo launched under load.
View dnscache.go
package dnscache
import (
"net"
"sync"
"time"
"math/rand"
)
var (
@creationix
creationix / run.js
Last active Mar 7, 2017
universal callback/continuable/thunk generator runner
View run.js
function run(generator) {
// Pass in resume for no-wrap function calls
var iterator = generator(resume);
var data = null, yielded = false;
next();
check();
function next(item) {
var cont = iterator.next(item).value;
View changing-the-public-api.md

Changing the Public API

When I started looking for ways to help on the "github.com/alecthomas/gozmq" package a few months ago, a recurring topic in discussions was that an earlier decision to provide a hidden struct type through a public interface type had become restrictive. We couldn't just drop the interface and make the struct public because that would be backwards-incompatible. Or could we?

No

This had to be the first considered option, and was the standing decision at the time. If we could continue providing what the package aims to provide without breaking backwards compatibility, then by all means, we should not break it.

Unfortunately this meant we couldn't provide all that we aimed to provide. Or could we?

View helloworld.js
var serialport = require('node-serialport')
var sp = new serialport.SerialPort("/dev/ttyO3", {
parser: serialport.parsers.raw,
baud: 9600
})
sp.on('data', function(chunk) {
console.log(chunk.toString('hex'), chunk.toString(), chunk)
})
@mattb
mattb / gist:3888345
Created Oct 14, 2012
Some pointers for Natural Language Processing / Machine Learning
View gist:3888345

Here are the areas I've been researching, some things I've read and some open source packages...

Nearly all text processing starts by transforming text into vectors: http://en.wikipedia.org/wiki/Vector_space_model

Often it uses transforms such as TFIDF to normalise the data and control for outliers (words that are too frequent or too rare confuse the algorithms): http://en.wikipedia.org/wiki/Tf%E2%80%93idf

Collocations is a technique to detect when two or more words occur more commonly together than separately (e.g. "wishy-washy" in English) - I use this to group words into n-gram tokens because many NLP techniques consider each word as if it's independent of all the others in a document, ignoring order: http://matpalm.com/blog/2011/10/22/collocations_1/

@roryokane
roryokane / .rbenv-version
Created Sep 4, 2012
editing Wikipedia ISBN calculation code
@jstorimer
jstorimer / port_scanner.rb
Created Aug 30, 2012
Simple, parallel port scanner in Ruby built with connect_nonblock and IO.select.
View port_scanner.rb
require 'socket'
# Set up the parameters.
PORT_RANGE = 1..512
HOST = 'archive.org'
TIME_TO_WAIT = 5 # seconds
# Create a socket for each port and initiate the nonblocking
# connect.
sockets = PORT_RANGE.map do |port|
@bsingr
bsingr / actor.rb
Created Aug 26, 2012
Different methods to spawn Celluloid Actors.
View actor.rb
# instantiate a cat object named 'Garfield' within its own actor thread
cat = Cat.new 'Garfield'
# blocking (the main thread waits until the cat has finished..)
cat.spray
# non-blocking
cat.spray!
# cats do what cats do
View gist:2878267
16:19 t432: What is the best way to approach the following problem.... A user logs in, application connects to database, retrieves latest 100 records and display the content. if user scrolls to bottom of page, retrieve next 100 records and display continue till end. In addition if a new record is created whilst logged in automatically display record on top... Might look familiar you use twitter
16:19 mattgordon has joined (~mattgordo@208.66.31.98)
16:20 will_: Great :)
16:20 Psi-Jack: I'm also using the primary_conninfo line in recovery.conf.
16:20 Psi-Jack: And trigger_File.
16:20 Psi-Jack: But, it's simply not streaming. :)
16:20 Psi-Jack: I'
16:20 luckyruby: t432, what web framework are u using?
16:21 orf_ has left IRC (Quit: Leaving)
16:21 bwlang_ has joined (~anonymous@70-91-134-14-ma-ne.hfc.comcastbusiness.net)
@pauldix
pauldix / gist:2830675
Created May 29, 2012
ideas for fetching
View gist:2830675
# set the thread pool size and the timeout in seconds.
fetcher = Feedzirra::Fetcher.new({:thread_pool_size => 100, :timeout => 5})
# some feed data objects. also include feed_entry data objects
feeds = [Feed.new({:entries => [], etag => "..", :last_modified => "...", :url => "...", :feed_url => "...", :title => ""})]
# async style
fetcher.get(feeds, :on_success => lambda {|feed, updated_feed| ...}, :on_failure => lambda {|feed, failure_object| ...})
# that returns before finishing fetching the feeds. just adds them to a thread-safe queue to be processed by a worker pool.
# the failure condition could actually call fetcher.get on the failed feed again if you wanted to retry.
You can’t perform that action at this time.