Skip to content

Instantly share code, notes, and snippets.

@cbarrick
cbarrick / [0] TicTacToe-base3.md
Last active March 12, 2024 18:03
Encoding tic-tac-toe in 15 bits

Test cases for the blog post [Encoding tic-tac-toe in 15 bits][post].

Run like this:

# Base4 test
$ cc base4.c && ./a.out

# Base3 test
$ cc base3.c && ./a.out
@smiled0g
smiled0g / run_llama.sh
Last active June 21, 2023 00:45
Easy way to run local LLM for your M-series Macbooks
#!/usr/bin/env bash
# Install Git Large File Storage (LFS)
brew install git-lfs
git lfs install
# Download & Install Llama
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
LLAMA_METAL=1 make -j # build with Metal support for (M-series) Apple Silicon

LOAD CSV into Neo4j quickly and successfully

Since version 2.1 Neo4j provides out-of-the box support for CSV ingestion. The LOAD CSV command that was added to the Cypher Query language is a versatile and powerful ETL tool. It allows you to ingest CSV data from any URL into a friendly parameter stream for your simple or complex graph update operation, that …​ conversion.

# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = 'EMAIL@provider.com'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }
@postrational
postrational / gunicorn_start.bash
Last active April 4, 2024 12:48
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
GUIDE: https://github.com/jbergantine/django-newproj/blob/master/docs/vagrant.markdown
mkdir website
cd website
curl https://gist.github.com/rileycrane/5326580/raw/294046048b77bfd610685307de31df2199ac4935/Gemfile > Gemfile
bundle
@chrisconley
chrisconley / heroku_deploy.sh
Created August 20, 2012 19:38
Deploying Twitter's Clockwork Raven to Heroku
# Make sure we're using Ruby 1.9.3 and checkout the heroku-demo branch of our fork
rvm use 1.9.3
git clone git://github.com/chrisconley/clockworkraven.git my-raven
cd my-raven/
git checkout heroku-demo
# Create the heroku app and add the Redis and Mysql add-ons
heroku create
heroku addons:add redistogo:nano
heroku addons:add cleardb:ignite
import time
import win32api, win32con
VK_CODE = {'left_arrow':0x25,
'spacebar':0x20,
'right_arrow':0x27}
def press(x):
win32api.keybd_event(VK_CODE[x], 0,0,0)
win32api.keybd_event(VK_CODE[x],0 ,win32con.KEYEVENTF_KEYUP ,0)
@jboner
jboner / latency.txt
Last active May 9, 2024 06:01
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD