Skip to content

Instantly share code, notes, and snippets.

View erthalion's full-sized avatar

Dmitrii Dolgov erthalion

View GitHub Profile
# $1 - name of file, that contains urls list
# $2 - name of output pdf file
url_list=$1
output=$2
set -- $(cat $url_list); count=0;
pdf_list=""
for arg;
do
@erthalion
erthalion / gist:6582059
Created September 16, 2013 15:19
fast but cryptic implementation of the Levenshtein algorithm)
levenshtein2 sa sb = last $ foldl transform [0..length sa] sb
where
transform xs@(x:xs') c = scanl compute (x+1) (zip3 sa xs xs')
where
compute z (c', x, y) = minimum [y+1, z+1, x + fromEnum (c' /= c)]
module Main where
import System.IO
import Data.Typeable
main :: IO ()
main = do
inh <- openFile "out.dat" ReadMode
outh <- openFile "converted.dat" WriteMode
mainloop inh outh 99
hClose inh
@erthalion
erthalion / test.hs
Last active December 21, 2015 05:19
{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}
import Network.HTTP.Conduit
import Data.Conduit
import Data.Conduit.Binary (sinkFile)
import Data.Text (Text)
import Text.JSON.Generic
import Control.Monad.IO.Class (liftIO)
import Control.Applicative ((<$>), (<*>))
x = np.linspace(0,1,6)
y = np.linspace(0,1,6)
circle = X**2 + Y**2 <= 1**2
distance_X = np.sqrt(np.abs(1**2 - Y**2)) - X
cond = (np.abs(distance_X) < 0.2) & (circle)
X[cond] = (X - distance_X)[cond]
plt.plot(X, Y, 'ro')
plt.show()
xvfb-run --server-args="-screen 0, 1024x768x24" cutycapt --url=http://$1 --out=$2.png
@erthalion
erthalion / gist:5947808
Last active December 19, 2015 11:29
Django debug_toolbar vs handle403
# django.core.handlers.base.py
def get_response(self, request):
"Returns an HttpResponse object for the given HttpRequest"
# debug_toolbar add own middleware that set urlconf for request (it's module)
# so handler403 doesn't work
response = None
# Apply request middleware
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python
# -*- coding: utf8 -*-
import numpy as np
import math
nx = 61
ny = 25
nz = 25
XXkb.mainwindow.enable: yes
XXkb.mainwindow.label.enable: yes
XXkb.mainwindow.type: tray
XXkb.mainwindow.appicon: no
XXkb.mainwindow.geometry: 15x15+0+0
XXkb.mainwindow.label.background: black
XXkb.mainwindow.label.foreground: white
XXkb.mainwindow.label.font: -misc-*-r-*-14-*
XXkb.mainwindow.label.text.1: En
XXkb.mainwindow.label.text.2: Ru