Skip to content

Instantly share code, notes, and snippets.

@mikeash
mikeash / blockforward.m
Created October 21, 2011 02:38
NSInvocation works for blocks too!
#import <dlfcn.h>
#import <Foundation/Foundation.h>
struct BlockDescriptor
{
unsigned long reserved;
unsigned long size;
void *rest[1];
@shripadk
shripadk / gist:652819
Created October 29, 2010 03:10
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@adautoneto
adautoneto / BusinessLogicInstaller.cs
Created August 8, 2012 21:07 — forked from martinnormark/BusinessLogicInstaller.cs
Castle Windsor IoC Container setup for ASP.NET MVC
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using MyApp.BusinessLogic.Facades;
namespace MyApp.Web.PresentationLogic.Container
{
public class BusinessLogicInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
@faiface
faiface / .md
Last active January 23, 2020 04:53
Go 2 generics counterproposal: giving up restricting types

Go 2 generics counterproposal: giving up restricting types

"I want to make a generic function which works on any type that satisfies these and these constraints."

When we think about generics, this is the sort of problem that pops up into our minds. The critical part is restricting the set of types our function intends to work on. Trying to solve this problem of restriction has led people to what I call reasons why we hesitate to have generics in Go.

C++ templates with horrific error messages, or even it's new concepts, Java's T extends Comparable<T>, Rust's generic traits, Haskell's type classes, and sadly even contracts from the [original generics proposal by the Go Team](https://go.googlesource.com/proposal/+/master/desig

export abstract class Result<T> {
abstract isOk(): boolean;
abstract isErr(): boolean;
abstract ok(): T | undefined;
abstract err(): Error | undefined;
static Ok<T>(val: T): Result<T> {
return new OkValue(val);
}
@dowlingw
dowlingw / main.go
Created June 4, 2019 14:05
gocv yolov3 troubleshooting
package main
import (
"fmt"
"gocv.io/x/gocv"
"image"
)
const vehicleWeights = "data/yolov3/yolov3.weights"
const vehicleNetcfg = "data/yolov3/yolov3.cfg"
@jonhoo
jonhoo / README.md
Last active July 19, 2021 10:49
Distributed RWMutex in Go
@n1k0
n1k0 / Howto.md
Created October 1, 2012 17:59
CasperJS test cli hooks example

Put test1.js and test2.js into a tests/ directory, then run the suite:

$ casperjs test tests/ --pre=pre.js --includes=inc.js --post=post.js
Test file: /Users/nperriault/tmp/pre-inc/pre.js                                 
Hey, I'm executed before the suite.
Test file: /Users/nperriault/tmp/pre-inc/tests/test1.js                         
# this is test 1
Hi, I've been included.
PASS Subject is strictly true
@lantrix
lantrix / experimental.md
Created April 15, 2020 05:16
Docker Buildkit Experimental

Dockerfile frontend experimental syntaxes

Note for Docker users

If you are using Docker v18.06 or later, BuildKit mode can be enabled by setting export DOCKER_BUILDKIT=1 on the client side. Docker v18.06 also requires the daemon to be running in experimental mode.

You need to use docker build CLI instead of buildctl CLI mentioned in this document. See the docker build document for the usage.

@lebedov
lebedov / pyzmq_client_server_demo.py
Created April 11, 2012 16:38
Demo of how to extend multiprocessing.Process to communicate with pyzmq
#!/usr/bin/env python
"""
Demo of how to extend multiprocessing.Process to communicate with
pyzmq.
"""
import zmq
from multiprocessing import Process
import time