Skip to content

Instantly share code, notes, and snippets.

@ceberly
ceberly / Makefile
Last active November 13, 2023 17:31
Row vs. Column access patterns
default:
gcc -O0 -g3 -Wall -Wextra -Wconversion -Wdouble-promotion \
-Wno-unused-parameter -Wno-unused-function -Wno-sign-conversion \
main.c
format:
clang-format -i main.c
@amondnet
amondnet / genymotionwithplay.txt
Created March 4, 2016 04:58 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
@dukenmarga
dukenmarga / cherrypy_static_image.py
Last active April 24, 2020 23:23
Serve dynamic image from Matplotlib using base64 encode string, from web framework CherryPy
# modified from https://gist.github.com/tebeka/5426211
# updated to work with Python 3
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot
import numpy
import cherrypy
from io import BytesIO
import base64
@david-christiansen
david-christiansen / FizzBuzzC.idr
Last active August 29, 2022 20:00
Dependently typed FizzBuzz, now with 30% more constructive thinking
module FizzBuzzC
%default total
-- Dependently typed FizzBuzz, constructively
-- A number is fizzy if it is evenly divisible by 3
data Fizzy : Nat -> Type where
ZeroFizzy : Fizzy 0
Fizz : Fizzy n -> Fizzy (3 + n)
@felipap
felipap / events.js
Last active December 29, 2015 17:09
Minimalistic backbone-like Javascript events for light usage.
function implementEvents() {
this._callbacks = {};
this.on = function (eventName, func, t) {
if (typeof func !== 'function')
throw "Invalid argument to .on() "+func
if (this._callbacks[eventName])
this._callbacks[eventName].push(t?func.bind(t):func);
else
this._callbacks[eventName] = [t?func.bind(t):func];
@cerebrl
cerebrl / 1-securing-express.md
Last active August 2, 2023 22:48
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
@niravmehta
niravmehta / kue_cleanup.js
Created July 30, 2013 11:57
Cleanup script for Kue job queueing system in Node.js. Deletes failed, active and completed jobs after specified time. Can run on command line directly with "node kue_cleanup". Requires Kue installed :-)
var kue = require('kue'),
jobs = kue.createQueue(),
util = require('util'),
noop = function() {};
jobs.CLEANUP_MAX_FAILED_TIME = 30 * 24 * 60 * 60 * 1000; // 30 days
jobs.CLEANUP_MAX_ACTIVE_TIME = 1 * 24 * 60 * 60 * 1000; // 1 day
jobs.CLEANUP_MAX_COMPLETE_TIME = 5 * 24 * 60 * 60 * 1000; // 5 days
jobs.CLEANUP_INTERVAL = 5 * 60 * 1000; // 5 minutes
@dasdennis
dasdennis / Warning for Source Ruby Gems.rb
Last active January 6, 2016 17:41
The source :rubygems is deprecated because HTTP requests are insecure. Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
# Change Gemfile source to https://rubygems.org to stop warning.
# The source :rubygems is deprecated because HTTP requests are insecure.
# Please change your source to 'https://rubygems.org' if possible, or
# 'http://rubygems.org' if not.
# In Gemfile:
# Comment this line:
# source :rubygems
@ricardobeat
ricardobeat / privates.js
Created November 25, 2012 23:37
Private properties with no memory leaks.
var Thing = (function(){
var instances = []
, data = []
function setId(){
data[instances.indexOf(this)] = id
}
function getId(){
@stefanv
stefanv / sparks.py
Created November 17, 2011 00:25
Command line sparks in Python
#!/usr/bin/python
# coding=utf-8
# Python version of Zach Holman's "spark"
# https://github.com/holman/spark
# by Stefan van der Walt <stefan@sun.ac.za>
"""
USAGE: