Skip to content

Instantly share code, notes, and snippets.

View ctmakro's full-sized avatar

Qin Yongliang ctmakro

View GitHub Profile
@ctmakro
ctmakro / test.cpp
Last active April 28, 2020 18:01
Correct way to do precisely timed routine task on Arduino
/*
With an Arduino,
If you want to:
1) execute a function precisely every N microseconds (or precisely 1,000,000/N times every second),
REGARDLESS of the running time of that function
2) obtain a precision of +-4 microseconds with NO ACCUMULATION OF ERROR
3) use no 3rd party libraries
Then this is for you.
*/
@savarin
savarin / bplustree.py
Last active April 28, 2024 23:04
Python implementation of a B+ tree
"""Simple implementation of a B+ tree, a self-balancing tree data structure that (1) maintains sort
data order and (2) allows insertions and access in logarithmic time.
"""
class Node(object):
"""Base node object.
Each node stores keys and values. Keys are not unique to each value, and as such values are
stored as a list under each key.
@brandonb927
brandonb927 / gist:9587436
Created March 16, 2014 18:13
Simple JSON database with Node.JS

From: http://run-node.com/littlest-database-that-could/

I've written numerous tiny databases. They don't have much features, but they don't need much features. Usually I'm looking for fast simple key/value stores and Node never disappoints. The point here is, why abstract key value store when JS gives us one for free, as it's most basic component: object.

Will it meet every need? No. But it will meet ALOT of scenarios.

In memory JS object lookups, were talking hundreds of thousands of lookups (you'll easily flood http before the db), and save hundreds of thousands of records in a JSON file written to disk. Not a 200ms r/t to some hosted Redis. Hey, that's fine if that's your thing.

Here's the requirements:

@fatihacet
fatihacet / pubsub-simple.js
Created October 15, 2011 22:02
Simple PubSub implementation with JavaScript - taken from Addy Osmani's design patterns book -
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,
@avsej
avsej / hosts
Created April 13, 2011 08:24
Block Adobe Activation
127.0.0.1 activate.adobe.com
127.0.0.1 practivate.adobe.com
127.0.0.1 ereg.adobe.com
127.0.0.1 activate.wip3.adobe.com
127.0.0.1 wip3.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 adobe-dns.adobe.com
127.0.0.1 adobe-dns-2.adobe.com
127.0.0.1 adobe-dns-3.adobe.com