Skip to content

Instantly share code, notes, and snippets.

View quocble's full-sized avatar

quocble quocble

  • Cryptoland, Moon
View GitHub Profile
@quocble
quocble / square_root.c
Created April 27, 2014 23:45
Comparing square root methods - Brute force vs Babylonian method. An understanding of mathematical convergence, and time complexity
/*
The MIT License (MIT)
Copyright (c) 2014 Quoc Le <quocble@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
#!/bin/sh
PROJDIR=`cd ..;pwd`
PROJECT_BUILDDIR="${PROJDIR}/build/Release-iphoneos"
DEVELOPPER_NAME="iPhone Distribution"
APPLICATION_NAME=SomeAppName
IPA_NAME=${APPLICATION_NAME}.ipa
# compile project
echo Building Project
# sum.py
#
# Sums up a specific column in a csv, input is via PIPE
# Useful for piping multiple files in at once.
import sys
import csv
if len(sys.argv) < 2:
print "Usage: cat file | python sum.py column#"
# import the necessary packages
import argparse
import cv2
import numpy as np
import math
# initialize the list of reference points and boolean indicating
# whether cropping is being performed or not
refPt = []
cropping = False
@quocble
quocble / gist:3754866
Created September 20, 2012 09:19
Simple Chef Recipe for Redis
package "redis-server"
ruby_block "redis-conf" do
block do
filename = "/etc/redis/redis.conf"
if File::exists?(filename)
redisConf = File.read(filename)
redisConf = redisConf.gsub(/bind .*/, "bind 0.0.0.0")
File.open(filename, 'w') {|f| f.write(redisConf) }
end
config setup
cachecrls=yes
uniqueids=yes
conn ios
keyexchange=ikev1
authby=xauthpsk
xauth=server
left=%defaultroute
leftsubnet=0.0.0.0/0
@quocble
quocble / gist:2be2d646a7df2d892b0650a90b9351a0
Created July 25, 2016 19:46
converts 3 hex into 6 hex
// converts 3 hex into 6 hex
function normalizeHex(hex) {
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return '#' + r + r + g + g + b + b;
});
return hex;
}
@quocble
quocble / analytic_wfm.py
Created March 31, 2017 07:39 — forked from sixtenbe/analytic_wfm.py
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See
@quocble
quocble / aggregate_prices.sql
Created October 22, 2018 22:49
QUANTA: aggregate_prices
# --- !Ups
CREATE FUNCTION first_agg(anyelement, anyelement) RETURNS anyelement
LANGUAGE SQL IMMUTABLE STRICT
AS $_$ SELECT $1 $_$;
/* rng_es
*
* Copyright (C) 1996, 1997, 1998, 1999, 2000 James Theiler, Brian Gough
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but