Skip to content

Instantly share code, notes, and snippets.

View maxp's full-sized avatar

Maxim Penzin maxp

View GitHub Profile
#
# mlib: common client js routines v0.5.0
# m@penzin.ru
#
# -- globals --
window.lib = x = {}
# window._csrf used as token, replaced by _csrf cookie if empty
// - http://habrahabr.ru/post/236251/
// set edge event on specific gpio_line
int gpio_edge_set(int n, const char *edge_str)
{
char filename[PATH_MAX];
FILE *file;
snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/edge", n);
@maxp
maxp / poweroff.c
Created July 7, 2014 12:01
arduino pro micro - 5 min power off
//
// arduino pro micro
//
#define POWER_GREEN 240
#define POWER_YELLOW 40
#define POWER_BLINK 20
#define POWER_OFF 3
@maxp
maxp / session-example.py
Created April 30, 2014 03:31
python-session-example
# -*- coding: utf-8 -*-
"""
mpws: main
@author: maxp
"""
from datetime import datetime, timedelta
import conf
@maxp
maxp / rasp-setup
Created April 29, 2014 16:07
Raspberry Pi Setup - embedded
### Raspberry Pi setup
(29.04.2014)
http://downloads.raspberrypi.org/raspbian_latest
# 2014-01-07-wheezy-raspbian.zip
dd if=2014-01-07-wheezy-raspbian.img od=/dev/mmcblk0
@maxp
maxp / calc-sha1.js
Created February 8, 2014 14:12
calc sha1
require('crypto').createHash('sha1').update("123").digest('hex')
' Функции рабочей книги для преобразования
' геодезических координат из координатной системы Пулково 1942
' в координатную систему WGS84
' Все угловые значения передаются и возвращаются в градусах,
' высоты передаются и возвращаются в метрах
' Сделано на основании ГОСТ Р 51794-2001 Российской Федерации
Const Pi As Double = 3.14159265358979 ' Число Пи
Const ro As Double = 206264.8062 ' Число угловых секунд в радиане
' Эллипсоид Красовского
Const aP As Double = 6378245 ' Большая полуось
Const alP As Double = 1 / 298.3 ' Сжатие
Const e2P As Double = 2 * alP - alP ^ 2 ' Квадрат эксцентриситета
' Эллипсоид WGS84 (GRS80, эти два эллипсоида сходны по большинству параметров)
Const aW As Double = 6378137 ' Большая полуось
@maxp
maxp / es5-methods.js
Created November 17, 2013 08:17
ES5 missing methods implementation
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);
@maxp
maxp / nodejs-settings.js
Last active December 28, 2015 11:59
Load json settings from current directory.
var settings = JSON.parse(
require('fs').readFileSync(
require('path').resolve(__dirname, 'settings.json'),
'utf8'
)
);