Skip to content

Instantly share code, notes, and snippets.

View chriddyp's full-sized avatar

Chris Parmer chriddyp

View GitHub Profile
static float floatvar = 12345.67;
static char sprintfbuffer[15];
static char dtostrfbuffer[15];
void setup() {
sprintf(sprintfbuffer,"%f", floatvar);
dtostrf(floatvar,8, 2, dtostrfbuffer);
Serial.begin(9600);
Serial.print("sprintf: ");
@paulirish
paulirish / gist:2926904
Created June 13, 2012 22:31
My SublimeLinter.sublime-settings file
{
"// my options for SublimeLinter " : "//",
"jshint_options" : {
"boss": true,
"browser": true,
"curly": false,
"devel": true,
"eqeqeq": false,
"eqnull": true,
@scjody
scjody / sierpinski.py
Last active December 17, 2015 03:38
Sierpinski triangle script for plot.ly, based on their Lindenmayer System demo
# Python 2.7.3 (default, Apr 20 2012, 23:04:22) [GCC 4.6.3]
# Use plot() to plot lists or arrays
# Use print to show results in the command line history
from numpy import sin, cos, pi
def f(s,itr):
xo=0
yo=0
a=0
var myURL="mydomain.com";
var restifyOptions={}
restifyOptions.certificate = fs.readFileSync('PathTo:fullchain.pem');
restifyOptions.key = fs.readFileSync('PathTo:privkey.pem');
var server = restify.createServer(restifyOptions);
var nonSecure = restify.createServer({name: 'redirectToSSL'});
nonSecure.get(/.*/,function (req, res, next) {
res.redirect(301, 'https://' + myURL + req._url.href, next);
@mick
mick / readme.md
Last active January 17, 2017 17:02
Use Plotly to generate a chart from Mapbox Analytics

First your need plotly npm package, and a plotly account.

npm install plotly export PLOTLY_USERNAME=<plotly-username> export PLOTLY_APIKEY=<plotly-apikey> export MAPBOX_ACCESS_TOKEN=<your-mapbox-token>

To generate a image: curl --silent "https://api.mapbox.com/analytics/v1/accounts/?period=2016-01-01,2016-04-29&amp;access_token=$MAPBOX_ACCESS_TOKEN" | ./render-image.js &gt; chart.png

@max-mapper
max-mapper / readme.md
Created September 28, 2011 02:01
SLEEP - syncable.org

Your API does REST, but can it SLEEP?

SLEEP (Syncable Lightweight Event Emitting Persistence) is an emerging standard for distributed data sync using HTTP and JSON. A generalized version of CouchDB's much lauded built-in replication, SLEEP extends the REST architecture to define a way in which databases can offer syncable JSON APIs that foster open data innovation by allowing developers to replicate entire databases over the net.


SLEEP comes from the Apache CouchDB project which is now widely known for it's multi-master streaming HTTP + JSON replication. This is possible in part because of the CouchDB _changes feed, which is a particular API that lets you see if there have been any changes made to the database since last time you synchronized. CouchDB can efficiently implement the _changes feed because of one subtle difference between it and most other databases: it stores a history of all changes that happen to the database, including deletes.

If you synchronize data from a remote source and then the

@internaut
internaut / pcp.R
Created September 27, 2016 13:07
Comparison of Parallel Coordinate Plots for Discrete and Categorical Data in R
### generate questionnaire data
library(triangle)
set.seed(0)
q1_d1 <- round(rtriangle(1000, 1, 7, 5))
q1_d2 <- round(rtriangle(1000, 1, 7, 6))
q1_d3 <- round(rtriangle(1000, 1, 7, 2))
@mmueller
mmueller / bitly.py
Created April 28, 2011 22:52
Command-line bit.ly URL generator (Python)
#!/usr/bin/env python
#
# Copyright 2009 Empeeric LTD. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@zoul
zoul / build-notifier.rb
Last active May 17, 2018 15:21
Posts a message to the OS X notification center when a Jekyll build is finished. Requires TerminalNotifier, see http://git.io/5X99Eg or “gem install terminal-notifier”.
begin
require 'terminal-notifier'
module Jekyll
class Site
alias jekyll_process process
def process
jekyll_process
TerminalNotifier.notify('Jekyll rebuild finished.')
end
end