Skip to content

Instantly share code, notes, and snippets.

View slavama's full-sized avatar

Slava slavama

  • Asia/Krasnoyarsk
View GitHub Profile
@anteo
anteo / ay_player.ino
Created February 19, 2018 08:06
Arduino UNO + AY player
#include <SPI.h>
#include "SdFat.h"
#include <LiquidCrystal.h>
const byte pinClock = 3; // AY38910 clock
const byte pinReset = 2; // AY38910 reset
const byte pinBC1 = 8; // AY38910 BC1
const byte pinBDIR = 9; // AY38910 BDIR
const byte pinSHCP = 4; // 74HC595 clock
const byte pinSTCP = 5; // 74HC595 latch
@MaslennikovYV
MaslennikovYV / inn.js
Created February 18, 2016 11:34
Валидация ИНН (Идентификационный Номер Налогоплательщика) для jQuery Validation http://jqueryvalidation.org/
$.validator.addMethod("inn", function (value, element) {
var multipliers = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8],
inn = value.split(''), i, j, ch = [0, 0, 0];
for (i = 0; i < 12; i++)
for (j = 0; j < 3; j++)
if (multipliers[i + j])
ch[j] = ch[j] + inn[i] * multipliers[i + j];
if (inn.length == 10)
return inn[9] == ch[2] % 11 % 10;
else if (inn.length == 12)
@thiagoeliasr
thiagoeliasr / swiper-magnific-popup.js
Created August 13, 2015 13:27
Adding swipe support to Magnific Popup galleries. (touchSwipe is required: http://labs.rampinteractive.co.uk/touchSwipe/demos/)
(function() {
/* Define a variável que dá swipe no lightbox */
var magnificPopup = $.magnificPopup.instance;
/* Carrega a função quando clica no lightbox (senão não pega a classe utilizada) */
$("a.image-lightbox").click(function(e) {
/* Espera carregar o lightbox */
setTimeout(function() {
/* Swipe para a esquerda - Próximo */
@charettes
charettes / django-mutant-usecase.rst
Last active March 26, 2019 09:33
django-mutant use case.

Django mutant use cases

Model creation

Reproducing an existing model setup

@davesque
davesque / vassal.ini
Created January 7, 2013 18:33
Uwsgi ini file for django
[uwsgi]
socket = /tmp/example.com.sock
; Worker processes
master = 1
processes = 4
; Virtualenv and home directory
virtualenv = /var/virtualenvs/example.com
chdir = /var/www/example.com
@mindlace
mindlace / middleware.py
Created October 19, 2012 13:43
Add user created/modified to every model
"""Add user created_by and modified_by foreign key refs to any model automatically.
Almost entirely taken from https://github.com/Atomidata/django-audit-log/blob/master/audit_log/middleware.py"""
from django.db.models import signals
from django.utils.functional import curry
class WhodidMiddleware(object):
def process_request(self, request):
if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'):
if hasattr(request, 'user') and request.user.is_authenticated():
user = request.user