Skip to content

Instantly share code, notes, and snippets.

View maxp's full-sized avatar

Maxim Penzin maxp

View GitHub Profile
.file "c1.cpp"
.section .rodata.str1.1,"aMS",@progbits,1
.LC1:
.string "%g %gi"
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB42:
#include <stdio.h>
#include <complex.h>
#include <math.h>
#ifndef complex
#define complex _Complex
#endif
@maxp
maxp / autoreload.coffee
Created July 5, 2013 11:45
nodejs exit on source file timestamp change
fs = require 'fs'
_reload_timestamp = null
setInterval(
-> fs.stat __filename, (err, stat) ->
_reload_timestamp ?= stat.mtime
if stat.mtime > _reload_timestamp
console.info "reloading"
process.exit(100)
3000
fetch_url = (st, param, cb) ->
request {
url: param.url
pool: false
timeout: (param.timeout ? config_def.timeout) * 1000
},
(err, resp, body) ->
if err or resp.statusCode != 200
warn "fetch_url() failed:", param.url, err
else
#!/usr/bin/python3
# from functools import reduce
# from itertools import product
from time import time
t0 = time()
digs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
sums = {i:0 for i in range(28)}
@maxp
maxp / ds1820-read.cpp
Last active December 14, 2015 22:49
Arduino OneWire DS1820 reader.
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
// http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip
// http://playground.arduino.cc/Learning/OneWire
//
#include <OneWire.h>
// DS18S20 Temperature chip i/o
OneWire ds(10); // on pin 10
def parse( data ):
"""
@return {ok:<0|1>,ts:<utc_datetime>,coord:[<lon>,<lat>],speed:<km/h>,dir:<bearing>}
or None on error or not gps ok
"""
try:
gp = data.index("GPRMC")
cp = data.index("*",gp+4)
@maxp
maxp / b1.py
Created January 23, 2013 05:02
botttle.py sample
#!/usr/bin/python
# coding: utf-8
from bottle import get, post, route, run, template, request, redirect
posts = []
form_html = \
"""
<form method=POST action="form">
def getWindchill(self):
"""
Return wind chill in degrees Celsius
"""
# http://en.wikipedia.org/wiki/Wind_chill - North American wind chill
# index
if self.w_chill is None:
if (self.temp and self.temp <= 10 and
self.windspeed and (self.windspeed*3.6) > 4.8):
body {
padding:100px;
}
/* Tooltip block */
.tooltip {
font-size: 12px;
color:#FFF;
position:relative;