Skip to content

Instantly share code, notes, and snippets.

View ffedoroff's full-sized avatar
🏠
Working from home

ffedoroff

🏠
Working from home
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from raven import Client
client = Client('https://c0615656d179475ba9fc93e60ca3af60:[email protected]:446/2')
# record a simple message
client.captureMessage("hello world from roma с переводом строк\nеще и по русски и очень длинный текст \nи очень длинный текст и очень длинный текст и очень длинный текст и очень длинный текст и очень длинный текст\n ыфвафывафыавфыа")
@ffedoroff
ffedoroff / gist:5598450
Last active December 17, 2015 10:58
png recolor
<?php
function resizeImage($img, $new_color, $color_range) {
list($width_orig, $height_orig) = getimagesize($img);
$src = imagecreatefrompng($img);
$dst = imagecreatetruecolor($width_orig+50,$height_orig+50);
$pink = imagecolorallocate($dst, 255, 105, 180);
imagefilledrectangle($dst, 15, 50, 150, 150, $pink);
$size_arr = getimagesize($img);
for ($y=0; $y<$size_arr[1]; $y++) {
@ffedoroff
ffedoroff / RaspberryPi-HC-SR04.py
Last active December 21, 2015 08:28
Raspberry Pi HC-SR04 Module ( view demo on http://youtu.be/etWD_-KDLnA )
# Module: ultrasound.py
# This module can be used to operate an HC-SR04 ultrasonic sensor
# from a raspberry pi GPIO.
import time
import RPi.GPIO as GPIO
# setup which pins are which
TRIG = 8
ECHO = 7
; supervisor config file
[unix_http_server]
file=/var/run//supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
@ffedoroff
ffedoroff / arduino_trouble
Last active December 28, 2015 16:09
arduino trouble
BaseSensor sensors[] = {
SonicSensor ("s0", 13, 12, 55, 5000, 0),
SonicSensor ("s1", 11, 55, 5000, 0),
SonicSensor ("s2", 10, 55, 5000, 0),
SonicSensor ("s3", 9, 45, 5000, 0),
ButtonSensor ("b01", 8, 10, 100, 0),
ButtonSensor ("b02", 7, 10, 100, 0),
BoolSensor ("m1", 6, 5000, 0),
@ffedoroff
ffedoroff / arduino.cpp
Last active December 28, 2015 16:09
arduino.cpp
// есть базовый класс BaseSensor и есть у него наследники SonicSensor и остальные...
// у них у всех есть public: virtual void init() {}
// я точно проверил, что virtual не забыл
// объявляю все красиво и удобно для меня
BaseSensor sensors[] = {
SonicSensor ("s0", 13, 12, 55, 5000, 0),
SonicSensor ("s1", 11, 55, 5000, 0),
SonicSensor ("s2", 10, 55, 5000, 0),
SonicSensor ("s3", 9, 45, 5000, 0),
@ffedoroff
ffedoroff / ihate.cpp
Last active December 29, 2015 13:29
I hate cpp
#include <StandardCplusplus.h>
#include <boost_1_51_0.h>
#include <vector>
#include "Arduino.h"
using namespace std;
class BaseSensor {
public:
const char* name;
virtual bool is_sonic() {return false;};
@ffedoroff
ffedoroff / sentry
Created December 19, 2013 10:44
sentry
Running service: 'http'
2013-12-19 10:40:35 [24035] [INFO] Starting gunicorn 0.17.2
2013-12-19 10:40:35 [24035] [INFO] Listening at: http://127.0.0.1:9000 (24035)
2013-12-19 10:40:35 [24035] [INFO] Using worker: sync
2013-12-19 10:40:35 [24046] [INFO] Booting worker with pid: 24046
2013-12-19 10:40:35 [24048] [INFO] Booting worker with pid: 24048
2013-12-19 10:40:35 [24047] [INFO] Booting worker with pid: 24047
Internal Server Error: /test/one/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Django-1.5.5-py2.7.egg/django/core/handlers/base.py", line 115, in get_response
@ffedoroff
ffedoroff / resp
Created March 5, 2014 04:19
resp
.test {
width: 100%;
}
@media only screen and (min-device-width: 480px) {
.test {
width: 90%;
}
}
public static void permutation()
{
string sourceText = "1bc23a";
// remove duplicates and sort
string[] s = sourceText.Select(c => c.ToString()).Distinct().OrderBy(c => c).ToArray();
int combinations = Factorial(s.Length);
int len = s.Length;