Skip to content

Instantly share code, notes, and snippets.

View daralthus's full-sized avatar

Peter Kadlot daralthus

  • Makethink
  • London
View GitHub Profile
var AmbTest = TestCase("AmbTest");
AmbTest.prototype.testBasic = function () {
function beats(ix, iy, jx, jy) {
return ix == jx || Math.abs(ix-jx) == jy-iy;
}
var result = ambRun(function (amb, fail) {
var queenPos = [];
for (var i = 0; i < 8; i++) {
var lastPos = amb([0,1,2,3,4,5,6,7]);
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mattweyant
mattweyant / redis-delallbykey
Created June 4, 2012 19:05
Delete all keys from Redis matching a regular expression
# All credit: http://stackoverflow.com/questions/4006324/how-to-atomically-delete-keys-matching-a-pattern-with-redis
redis-cli [options] KEYS "prefix:*" | xargs redis-cli [options] DEL
@dfkaye
dfkaye / mocking-private-functions.md
Last active March 13, 2019 15:40
mocking - not testing - private functions in JavaScript, using new Function() - followup to https://gist.github.com/dfkaye/5971486

Mocking - not testing - private functions in JavaScript

Instead of trying to extract a private function, we can rely on mocking/spying. This gist shows how to use the "new Function()" constructor to replace an internal call so that we can mock, spy or stub.

Another response to @philwalton - 
http://philipwalton.com/articles/how-to-unit-test-private-functions-in-javascript/

This is a followup to https://gist.github.com/dfkaye/5971486 - a suggestion for 
*annotating* functions to be extracted and tested separately (publicly).
@tracker1
tracker1 / .eslintrc
Created March 24, 2015 00:43
ES6 Testing With Mocha and BabelJS
{
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": false,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": true,

Build tensorflow on OSX with NVIDIA CUDA support (GPU acceleration)

These instructions are based on Mistobaan's gist but expanded and updated to work with the latest tensorflow OSX CUDA PR.

Requirements

OS X 10.10 (Yosemite) or newer

@karpathy
karpathy / nes.py
Last active June 28, 2024 12:59
Natural Evolution Strategies (NES) toy example that optimizes a quadratic function
"""
A bare bones examples of optimizing a black-box function (f) using
Natural Evolution Strategies (NES), where the parameter distribution is a
gaussian of fixed standard deviation.
"""
import numpy as np
np.random.seed(0)
# the function we want to optimize
@0chroma
0chroma / VFIO Setup Guide.md
Last active March 12, 2024 13:49
Windows 10 VFIO QEMU Setup

VFIO Setup Guide

I play games regularly, and the sad reality is that it forces me to use Windows on my desktop. There's a Linux installation on there, but rebooting into it is such a massive interruption that I usually just move over to my laptop for programming. Working on a laptop leads to all sorts of ergonomic issues, and it felt like a massive waste to not develop on the desktop hardware I invested so much in. So after extensively researching what the VFIO community has been doing, I've deleted my Windows installation and moved all my gaming into a virtual machine on a Linux host.

Normally VMs are too slow for gaming, but thanks to a feature called VFIO you can run games at near-native performance by passing graphics cards and USB controllers directly to a virtual machine. The only requirement is that your board supports IOMMU, which most modern systems have. In this guide I'll wal