Skip to content

Instantly share code, notes, and snippets.

View Snegovikufa's full-sized avatar
📍
Push the red button

Rustam Safin Snegovikufa

📍
Push the red button
View GitHub Profile
@Snegovikufa
Snegovikufa / template_render.py
Created July 17, 2012 04:15
Chaco multiple plots and axes
def view (self, data) :
index, filteredIndex = self.dataIndex (data)
indexData = ArrayDataSource (filteredIndex, sort_order = "ascending")
indexMapper = LinearMapper (range = DataRange1D (indexData))
grid = ChacoGridContainer (padding = 35,
padding_bottom = 65,
fill_padding = True,
use_backbuffer = True,
shape = gridShape (len (self._grid)),
spacing = (0, 0))
@Snegovikufa
Snegovikufa / gist:3839437
Created October 5, 2012 12:04
Run custom builds from Sublime Text 2 prompt
// Create your own "my_build.sublime-build", mark it as active
// Open Preferences - Key bindings - User
// And add :
{
// ...
"keys": ["f8"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Build: "}.
// ...
}
@Snegovikufa
Snegovikufa / Context.sublime-menu
Created January 14, 2013 09:31
PuDb breakpoint helper for Sublime Text 2
[
{
"command": "add_breakpoint",
"caption": "Add pudb breakpoint"
}
]
@Snegovikufa
Snegovikufa / home1.sml
Created January 28, 2013 05:39
coursera_prog_lang_home1
(*
Func 1:
Write a function is_older that takes two dates and evaluates to true or false. It evaluates to true if
the First argument is a date that comes before the second argument. (If the two dates are the same,
the result is false.)
*)
fun is_equal (date1 : int * int * int, date2 : int * int * int) =
(#1 date1 = #1 date2) andalso (#2 date1 = #2 date2) andalso (#3 date1 = #3 date2)
fun is_older (date1 : int * int * int, date2 : int * int * int) =
@Snegovikufa
Snegovikufa / Eversong.xml
Created February 4, 2013 07:36
PyCharm Eversong color scheme. Put into ~/.PyCharm20/config/colors
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Eversong" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_SIZE" value="14" />
<option name="CONSOLE_FONT_NAME" value="Ubuntu Mono" />
<option name="CONSOLE_FONT_SIZE" value="16" />
<option name="EDITOR_FONT_NAME" value="Terminus (TTF)" />
<colors>
<option name="CARET_COLOR" value="f8f8f0" />
<option name="CARET_ROW_COLOR" value="1822" />
@Snegovikufa
Snegovikufa / timezones.py
Created February 20, 2013 03:58
How to operate with datetime and timezones
# -*- coding: utf-8 -*-
from pytz import timezone
from datetime import datetime, timedelta
tz1 = timezone("Asia/Yekaterinburg")
tz2 = timezone("America/New_York")
dst1 = datetime(2013, 3, 9, tzinfo=tz2)
dst2 = datetime(2013, 3, 10, tzinfo=tz2)
dst3 = datetime(2013, 3, 11, tzinfo=tz2)
@Snegovikufa
Snegovikufa / lcd.c
Created March 13, 2013 15:32
LCD Keypad Shield for Arduino
/*
The circuit:
* LCD RS pin to digital pin 8
* LCD Enable pin to digital pin 9
* LCD D4 pin to digital pin 4
* LCD D5 pin to digital pin 5
* LCD D6 pin to digital pin 6
* LCD D7 pin to digital pin 7
* LCD BL pin to digital pin 10
* KEY pin to analogl pin 0
@Snegovikufa
Snegovikufa / m2crypto_example.py
Last active December 8, 2021 14:33
m2crypto examle
# Since I ask this of people before using their code samples, anyone can
# use this under BSD.
import os
import M2Crypto
def empty_callback():
return
# Seed the random number generator with 1024 random bytes (8192 bits)
@Snegovikufa
Snegovikufa / encrypter.py
Created March 25, 2013 05:14
Encrypt file with AES and RSA private key
# -*- coding: utf-8 -*-
__author__ = 'Rustam Safin'
import base64
from M2Crypto.RSA import (load_key, pkcs1_padding, gen_key)
from Crypto.Cipher import AES
from Crypto import Random
from sys import getfilesystemencoding
@Snegovikufa
Snegovikufa / listmodel.py
Last active December 17, 2015 00:39
In Archlinux prints None (PyQt4 version 4.10.1)
# -*- coding: utf-8 -*-
import logging
import sys
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
logger = logging.getLogger("TestModel")
import sip
sip.setapi("QString", 2)
sip.setapi("QVariant", 2)