Skip to content

Instantly share code, notes, and snippets.

View nskeip's full-sized avatar
🕶️

Nikita Hismatov nskeip

🕶️
View GitHub Profile
@nskeip
nskeip / hrefs.pl
Created August 4, 2013 06:46
Shows all the links from stdin
#!/usr/bin/perl
#
$text = <>;
@links = $text =~ m/href=\"([^\"]+)/g;
print join ("\n", @links), "\n";
@nskeip
nskeip / .vimrc
Created May 30, 2013 05:39
a nice day to post my .vimrc
filetype off
call pathogen#runtime_append_all_bundles()
" making CommandT work...
map <C-t> :CommandT<CR>
syntax enable
set background=light
set t_Co=16
let g:solarized_termcolors=16
colorscheme solarized
sudo apt-get install libsqlite3-dev
gem install sqlite3 -v '1.3.7'
# https://rvm.io/packages/openssl/ - look
sudo apt-get install openssl # do i need this?
rvm pkg install openssl
rvm reinstall all --force
@nskeip
nskeip / parse_target2.py
Created September 21, 2012 10:51
Another way of parsing: what if we have some 'types' of entrieS? We look for type_field_EVENT (or for field_EVENT).
class ParseTarget(object):
TYPES = frozenset(('tire', 'disc', 'oil', 'acc', 'additional',))
def __init__(self):
self.current_tag = None
self.current_type = None
self._depth = 0
@nskeip
nskeip / parser_target.py
Created September 20, 2012 09:15
making an xml-parser more readable: an abstract target that tries to call methods like TAGNAME_start, TAGNAME_end etc.
class AbstractParseTarget(object): # http://lxml.de/parsing.html#the-target-parser-interface
def __init__(self):
self.current_tag = None
def start(self, tag, attrib):
self.current_tag = tag
method = getattr(self, '%s_start' % tag, None)
if method:
@nskeip
nskeip / smsintel.py
Created September 13, 2012 09:37
smsintel.ru django snippet
from django.conf import settings
def send_sms(phone, text):
q = ("<?xml version='1.0' encoding='UTF-8'?><data><login>%(login)s</login>" +
"<password>%(password)s</password><text>%(text)s</text><to number='%(phone)s'></to></data>") % {
'phone': phone.encode('utf-8'),
'text': text.encode('utf-8'),
'login': settings.SMS_INTELL_LOGIN,
'password': settings.SMS_INTELL_PASSWORD,
}
@nskeip
nskeip / yandex_email_for_domain_settings.py
Last active February 23, 2024 15:03
Django SMTP settings for yandex_for_domain mail (pdd.yandex.ru)
EMAIL_HOST = 'smtp.yandex.ru'
EMAIL_HOST_USER = 'login@example.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
@nskeip
nskeip / any_model_htmlfield.py
Created May 31, 2012 12:14
Registering any_model extension for tinymce's HTMLField
import tinymce
from django_any import xunit
from django_any.models import any_model, any_field
@any_field.register(tinymce.models.HTMLField)
def any_tinymce_html_field(*_):
return xunit.any_string(min_length=1, max_length=400)
@nskeip
nskeip / pagination.html
Created May 29, 2012 10:53 — forked from cspanring/pagination.html
linaro django pagination template for Bootstrap framework
{# use in combination with https://github.com/zyga/django-pagination #}
{# and http://twitter.github.com/bootstrap/ #}
{# project-dir/templates/pagination/pagination.html #}
{% if is_paginated %}
{% load i18n %}
<div class="pagination">
<ul>
{% block previouslink %}
{% if page_obj.has_previous %}