This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
# http://interactivepython.org/runestone/static/pythonds/Recursion/pythondsConvertinganIntegertoaStringinAnyBase.html | |
class AbcNumCoverter: | |
chars = string.digits + string.ascii_lowercase | |
base = len(chars) | |
@classmethod | |
def to_str(cls, n): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requests.put('http://localhost:9200/site/', data=json.dumps({ | |
'settings': { | |
'analysis': { | |
'analyzer': { | |
'ru': { | |
'type': 'custom', | |
'tokenizer': 'standard', | |
"filter": ['lowercase', 'russian_morphology', 'english_morphology', 'ru_stopwords'], | |
}, | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import socket, sys | |
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | |
addr,path = sys.argv[1].split(":") | |
sock.connect(addr) | |
sock.send("""GET {} HTTP/1.1 | |
host: test.ru |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// https://github.com/dps/go-xml-parse/blob/master/go-xml-parse.go | |
import ( | |
"fmt" | |
"os" | |
"encoding/xml" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"gopkg.in/olivere/elastic.v2" | |
"strconv" | |
) | |
type Tweet struct { | |
User string `json:"user"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# save it to "/etc/init.d/vagrant-boxes" | |
# sudo update-rc.d vagrant-boxes defaults 99 01 | |
RETVAL=0 | |
USER='ilya' | |
stop() { | |
LIST=`sudo -u $USER vagrant global-status | grep running | awk '{print $1}'` | |
for i in `echo $LIST`; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import readline | |
texts = ['hello', 'world', 'readline'] | |
def completer(text, state): | |
options = [x for x in texts if x.startswith(text)] | |
try: | |
return options[state] | |
except IndexError: | |
return None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pathspec.match_files(map(pathspec.GitIgnorePattern, ["*.css", "!*.ie.css"]), ["styles.css", "styles.ie.css", ".tmp"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set list | |
set expandtab | |
retab 4 | |
set shiftwidth=4 | |
set tabstop=4 | |
syntax on | |
set nu | |
set ai |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import os | |
import django | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") | |
django.setup() | |
# write your code here |