Skip to content

Instantly share code, notes, and snippets.

View Kein1945's full-sized avatar
:octocat:
Happening some things.

Kein Kein1945

:octocat:
Happening some things.
  • Bali
View GitHub Profile
@Kein1945
Kein1945 / gist:5037697
Created February 26, 2013 11:03
Python mail checker. Проверяет наличие почтового ящика на сервере. Следует учесть что не все сервера отвечают корректно, к примеру mail.ru всегда отвечает успешно, хотя ящика может не быть на сервере
#!/usr/bin/python2.7
import socket
import sys
import DNS
import cgi
arg = cgi.FieldStorage()
if "debug" in arg:
debug = True
@Kein1945
Kein1945 / navigation.html.twig
Created April 15, 2013 10:31
Navigation snippet for #Symfony2 #Twig #Twitter bootstrap
{% set menu = {
'products_dashboard' : 'Products'
} %}
<ul class="nav">
{% for path,label in menu %}
<li{% if path(path) in app.request.RequestUri %} class="active"{% endif %}><a href="{{ path(path) }}">{{ label }}</a></li>
{% endfor %}
</ul>
@Kein1945
Kein1945 / gist:6401324
Created August 31, 2013 23:31
Javascript String format
String.prototype.format = function() {
var i = -1, args = arguments;
return this.replace(/#\{(.*?)\}/g, function(one, two) {
return (typeof args[0] == 'object')?args[0][two]:args[++i];
});
}
var thing = 'world!';
@Kein1945
Kein1945 / gist:6696244
Created September 25, 2013 07:29
Show colors for console: \[\e[0;30;43m\] text \[\e[m\] https://wiki.archlinux.org/index.php/Color_Bash_Prompt
#!/usr/bin/env python
import sys
terse = "-t" in sys.argv[1:] or "--terse" in sys.argv[1:]
for i in range(2 if terse else 10):
for j in range(30, 38):
for k in range(40, 48):
if terse:
print "\33[%d;%d;%dm%d;%d;%d\33[m " % (i, j, k, i, j, k),
else:
@Kein1945
Kein1945 / .gitconfig
Last active January 11, 2017 11:38
Gitconfig
[user]
name = Kein
email =
[alias]
st = status
unstage = rm --cached
hist = log --pretty='format:%h - %an, %ar : %s' --graph
h = log --pretty='format:%Cred%h%Creset %C(yellow)%d%Creset - %s %C(green)%ar%Creset %C(blue)%an%Creset' --graph --all --decorate
ci = commit -m
co = checkout
@Kein1945
Kein1945 / gist:7524410
Created November 18, 2013 08:16
Chrome dev tool snippet for print forms detail info
[].forEach.call(document.querySelectorAll('form'), function (input) {
var table = [];
console.group('HTMLForm "' + input.name + '": ' + input.action);
console.log('Element: ', input, '\nName: ' +
input.name + '\nMethod: ' + input.method.toUpperCase() +
'\nAction: ' + input.action || 'null');
['input', 'textarea', 'select'].forEach(function (control) {
[].forEach.call(input.querySelectorAll(control), function (node) {
@Kein1945
Kein1945 / gist:9111512
Last active July 2, 2023 16:14
Стеммер Портера для русского языка на Python
# -*- coding: utf-8 -*-
# Портирован с Java по мотивам http://www.algorithmist.ru/2010/12/porter-stemmer-russian.html
import re
class Porter:
PERFECTIVEGROUND = re.compile(u"((ив|ивши|ившись|ыв|ывши|ывшись)|((?<=[ая])(в|вши|вшись)))$")
REFLEXIVE = re.compile(u"(с[яь])$")
ADJECTIVE = re.compile(u"(ее|ие|ые|ое|ими|ыми|ей|ий|ый|ой|ем|им|ым|ом|его|ого|ему|ому|их|ых|ую|юю|ая|яя|ою|ею)$")
PARTICIPLE = re.compile(u"((ивш|ывш|ующ)|((?<=[ая])(ем|нн|вш|ющ|щ)))$")
VERB = re.compile(u"((ила|ыла|ена|ейте|уйте|ите|или|ыли|ей|уй|ил|ыл|им|ым|ен|ило|ыло|ено|ят|ует|уют|ит|ыт|ены|ить|ыть|ишь|ую|ю)|((?<=[ая])(ла|на|ете|йте|ли|й|л|ем|н|ло|но|ет|ют|ны|ть|ешь|нно)))$")
@Kein1945
Kein1945 / gist:9546472
Created March 14, 2014 12:05
Javascript console snippet for fast add many url's to pocket. Run from chrome debugger console(ctrl+shift+J)
// formCheck - global variable token from page
// Enter in prompt articles url with new line delemiter
var _add = function (url){
$.ajax({
url: 'http://getpocket.com/a/x/itemAction.php'
,data:{
action: 'add'
,formCheck: formCheck
, url: url
}
@Kein1945
Kein1945 / .bashrc
Last active January 11, 2017 11:37
Bashrc with great fucking advice prompt, git branch, xterm title
ssh_mount_dir='servers/'
export TERM=xterm-256color
export EDITOR="vim"
export CDPATH=:..:~/$ssh_mount_dir:~
if [[ $- != *i* ]] ; then
return
fi
@Kein1945
Kein1945 / home_contorller.rb
Created May 11, 2014 11:39
Send emails in RoR via pdd.yandex.ru
class HomeController < ApplicationController
def contacts
UserMailer.notify_email( params[:text]).deliver
end
end