Skip to content

Instantly share code, notes, and snippets.

@kostyll
kostyll / .gitignore
Last active October 22, 2015 12:57 — forked from kstep/html.py
*.pyc
# -*- coding: utf-8 -*-
"""
codegen
~~~~~~~
Extension to ast that allow ast -> python code generation.
:copyright: Copyright 2008 by Armin Ronacher.
:license: BSD.
"""
@kostyll
kostyll / .gitignore
Last active August 29, 2015 14:06 — forked from reusee/py2php.py
test.py
from subprocess import Popen, PIPE
from docx import opendocx, getdocumenttext
#http://stackoverflow.com/questions/5725278/python-help-using-pdfminer-as-a-library
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from cStringIO import StringIO
@kostyll
kostyll / ishare.sh
Created December 13, 2014 12:00
share inet in linux
#!/bin/bash
## Internet connection shating script
sysctl -w net.ipv4.ip_forward=1
sysctl -p
iptables -X
iptables -F
iptables -t nat -X
iptables -t nat -F
@kostyll
kostyll / db.coffee
Last active August 29, 2015 14:15 — forked from jaigouk/db.coffee
DB = (key) ->
store = window.localStorage
get: ->
JSON.parse store[key] or "{}"
put: (data) ->
store[key] = JSON.stringify(data)
#!/usr/bin/env python
class Segment(object):
def __init__(self,item,getter):
self.index,self._data = getter(item)
self.len = len(self._data)
def __repr__(self):
return "<<Segment[%s:%s]['%s']>>" % (self.index, self.len,self.data)
import json
import urllib
import requests
req = urllib.unquote('https://api.import.io/store/data/784a3159-a7c1-411b-8b9b-7c65743f23eb/_query?input/webpage/url=http%3A%2F%2Fmoz.com%2Ftop500&_user=44223ee8-63a2-45f2-9f3c-0e7aad8c38c9&_apikey=')+urllib.quote('BN2ukOiuoM4u9qIlrTt7TsPFe8RSQ7QgpaZLP/qUS1onqBx1aOsv4NgpRj0h03fpU02zAC+vQ6vIscKlcA2cSg==')
resp = requests.get(req)
resp.content
data = json.loads (resp.content )
@kostyll
kostyll / crime.py
Last active August 29, 2015 14:19 — forked from stamparm/crime.py
# This is supposedly what CRIME by Juliano Rizzo and Thai Duong will do
# Algorithm by Thomas Pornin, coding by xorninja, improved by @kkotowicz
# http://security.blogoverflow.com/2012/09/how-can-you-protect-yourself-from-crime-beasts-successor/
import string
import zlib
import sys
import random
charset = string.letters + string.digits + "%/+="
@kostyll
kostyll / utils.py
Created April 20, 2015 15:54
test gist
from datetime import datetime
def yearsago(years, from_date=None):
if from_date is None:
from_date = datetime.now()
try:
return from_date.replace(year=from_date.year - years)
except:
# Must be 2/29!
assert from_date.month == 2 and from_date.day == 29 # can be removed
return from_date.replace(month=2, day=28,