Skip to content

Instantly share code, notes, and snippets.

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

Vitalii Mikhnevych rooty

🏠
Working from home
View GitHub Profile
@rooty
rooty / tastypie_resource.py
Created June 20, 2012 20:55
Example of a custom django-tastypie Resource
from tastypie import fields
from tastypie.authentication import Authentication
from tastypie.authorization import Authorization
from tastypie.bundle import Bundle
from tastypie.exceptions import NotFound
from tastypie.resources import Resource
# a dummy class representing a row of data
class Row(object):
import datetime
def daterange(start, stop, step=datetime.timedelta(days=1), inclusive=True):
# inclusive=False to behave like range by default
if step.days > 0:
while start < stop:
yield start
start = start + step
elif step.days < 0:
while start > stop:
/*
Подключение AT2424C15 по I2C
*/
#define ADDR 0x50
void setup() {
Wire.begin();
Serial.begin(38400);
randomSeed(analogRead(0));
@rooty
rooty / .gitignore
Created June 21, 2013 16:28
.gitignore
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
@rooty
rooty / youtube.py
Last active December 19, 2015 01:59
youtube id parser without regexp
def video_id(value):
"""
Examples:
- http://youtu.be/SA2iWivDJiE
- http://www.youtube.com/watch?v=_oPAwA_Udwc&feature=feedu
- http://www.youtube.com/embed/SA2iWivDJiE
- http://www.youtube.com/v/SA2iWivDJiE?version=3&amp;hl=en_US
"""
query = urlparse(value)
if query.hostname == 'youtu.be':
@rooty
rooty / i2c-arduino-slave
Created August 25, 2013 18:31
i2c-arduino-slave
#include <Wire.h>
#define ADDR 128 //адрес устройства
void setup()
{
Serial.begin(115200);//скорость обмена с компом
Wire.begin(ADDR); //определим как ведомый с указанным адресом
Wire.onReceive(receive_handler); //ждем данных от мастера, функция возвращает int число байт данных
}
@rooty
rooty / smpset.sh
Created August 17, 2014 21:26
Распределение IRQ процессоры
#!/bin/bash
NUM=0
CPUS=
for ARG in "$@"
do
if [ $NUM -eq 0 ]; then INTERFACE=$ARG; fi
if [ $NUM -gt 0 ]; then CPUS[$[$NUM-1]]=$ARG; fi
let NUM++
done
@rooty
rooty / gist:36cd9eb6941ae95974a4
Created October 13, 2014 22:15
Get local IP addresses
Use net.InterfaceAddrs().
addrs, err := net.InterfaceAddrs()
if err != nil {
panic(err)
}
for i, addr := range addrs {
fmt.Printf("%d %v\n", i, addr)
}
If you want to know interface names too, use net.Interfaces() to get a list of interfaces first.
<script>
window.intercomSettings =
{ // TODO: The current logged in user's full name name: "John Doe", // TODO: The current logged in user's email address. email: "john.doe@example.com", // TODO: The current logged in user's sign-up date as a Unix timestamp. created_at: 1234567890, app_id: "qq55r2qw" }
;
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function")
{ic('reattach_activator');ic('update',intercomSettings);}
else{var d=document;var i=function()
{i.c(arguments)}
;i.q=[];i.c=function(args)
#!/usr/bin/env python
#
# Copyright 2012 Patrick Hetu <patrick.hetu@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,