Skip to content

Instantly share code, notes, and snippets.

@creationix
creationix / output.log
Created May 8, 2013 22:02
Working version of generator async code sample. Using node from https://github.com/andywingo/node/tree/v8-3.19
tim@touchsmart:~/Code$ nvm use v0.11.2-generators
Now using node v0.11.2-generators
tim@touchsmart:~/Code$ node --harmony testgen.js
<Buffer 76 61 72 20 66 73 20 3d 20 72 65 71 75 69 72 65 28 27 66 73 27 29 3b 0a 66 75 6e 63 74 69 6f 6e 20 72 65 61 64 46 69 6c 65 28 70 61 74 68 2c 20 65 6e 63 ...>
Sleeping for 2000ms...
Done
@bretwalker
bretwalker / ssl_validator.py
Last active January 28, 2024 12:02
A Python script that uses M2Crypto to check the validity of an SSL certificate.
from M2Crypto import SSL
from M2Crypto.SSL.Checker import SSLVerificationError, NoCertificate, WrongCertificate, WrongHost
import socket, re
from datetime import datetime
import pytz
class ValidationResults:
def __init__(self):
self.connection_error = False
@yllan
yllan / GO63Channel.scala
Last active December 15, 2015 16:49
Rewrite the Go tutorial of goroutine with scala.concurrent.
// Rewrite http://tour.golang.org/#63 to scala using Channel
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
object GO63Channel extends App {
def sum(a: List[Int], c: Channel[Int]) = future {
c write a.sum
}
val c = new Channel[Int]()
import square.SquareRoot;
import java.math.BigInteger;
public class FindRoot {
private static final int TIMING_LOOP_COUNT = 10;
public static void main(String[] args) {
// max and min bound the square-root of n: min < sqrt(n) <= max
// maxN and minN bound the square, n (i.e. SquareRoot.n): minN < n <= maxN
(function(Backbone, _) {
var leave, leaveArgs;
_.extend(Backbone.Router.prototype, Backbone.Events, {
route : function(route, name, callback) {
if(!callback)
callback = this[name];
var before
, fn = callback
@wrr
wrr / index.html
Last active May 14, 2019 00:27
Random walk illustrated with D3.
<!DOCTYPE html>
<!-- By Jan Wrobel. See it working at:
http://mixedbit.org/blog/2013/02/10/random_walk_illustrated_with_d3.html
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Random walk</title>
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 28, 2025 00:02
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@ndarville
ndarville / business-models.md
Last active February 27, 2025 10:00
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@wfaler
wfaler / cake-pattern-example.scala
Created October 22, 2012 16:57
simple-cake-pattern-example.scala
// simple example of the cake pattern
// abstract DAO trait
trait Repository[A, B]{
// saves an entity, returns an ID
def save(entity: A): B
// more features..
}
trait RdbmsRepository extends Repository[MyUserCaseClass, Long]{
@vinsonizer
vinsonizer / Pivot.scala
Created October 19, 2012 19:18
Sample Pivot Table starter implementation
package pivot
class Pivot(val rows: List[List[String]]) {
val headers = rows.head.zipWithIndex.map(_.swap)
val body = rows.tail
def addCalcCol(f: List[String] => String)(newColName: String) : Pivot = {
val newRows = (headers.map(_._2) :+ newColName) +:
body.map(row => { row :+ f(row)})