Skip to content

Instantly share code, notes, and snippets.

@denitram
denitram / regex
Last active August 28, 2016 22:47
8 Regular Expressions You Should Know
http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/
# insert a new line with '<null\>' as content every 6th line between lines 100 and 2000
100,2000s/\v(.*\n){6}/\0\<null\/\>\r/g
see http://stackoverflow.com/questions/10413906/how-to-add-a-line-after-every-few-lines-in-vim
# delete blank lines
:g/^$/d
# join all lines
@dastanko
dastanko / djvu2pdf
Created August 17, 2013 16:55
bash:convertToPDF
#!/bin/bash
# convert DjVu -> PDF
# usage: djvu2pdf.sh <file.djvu>
# depends on ddjvulibre package, To install package run `sudo apt-get install ddjvulibre`
i="$1"
echo "------------ converting $i to PDF ----------------";
o="`basename $i .djvu`"
o="$o".pdf
@ninux
ninux / gist:5713741
Created June 5, 2013 13:12
Merge PDFs with Ghostscript
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf
found at https://bbs.archlinux.org/viewtopic.php?id=65036
def process(input)
commands = {
'q' => 'Goodbye',
'tweet' => 'tweeting',
'dm' => 'direct messaging',
'help' => 'helping'
}
if command = commands[input]
puts command
@egonSchiele
egonSchiele / Main.hs
Created April 17, 2013 00:03
Read and write from a database using persistent and Scotty
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@magnetikonline
magnetikonline / README.md
Last active February 7, 2025 07:27
IE 7/8/9/10/11 Virtual machines from Microsoft - Linux w/VirtualBox installation notes.
@taviso
taviso / ScaleWindow.c
Last active May 9, 2016 12:51
Apparently win32k is not Chuck Norris.
#ifndef WIN32_NO_STATUS
# define WIN32_NO_STATUS
#endif
#include <windows.h>
#include <assert.h>
#include <stdio.h>
#include <winerror.h>
#include <stddef.h>
#include <winnt.h>
#include <limits.h>
@rblaze
rblaze / bf.c
Last active December 11, 2015 07:08
Специальная олимпиада-2: Bellman-Ford algorithm как первый шаг Johnson algorithm Изначальная версия: haskell - 60 минут, C - две минуты. Данные для обработки: http://spark-public.s3.amazonaws.com/algo2/datasets/large.txt
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const int infinity = 2147483647;
struct edge_t {
int v1;
int v2;
int cost;
@nh2
nh2 / Hopfield-mini.hs
Created October 16, 2012 05:36
Hopfield networks - minimal Haskell implementation
import Data.Vector ((!))
import qualified Data.Vector as V
import Data.Vector.Generic.Mutable (write)
step ws state = case updatable of [] -> state
(i,_):_ -> V.modify (\v -> write v i (o i)) state
where
n = V.length state
w i j = ws ! i ! j
@hiroyuki
hiroyuki / gist:3781210
Last active January 18, 2019 08:26
cartesian<>Polar
/**
* converts cartesion to polar coordinates
* result:
* [0] = length
* [1] = angle z-axis rotation [-PI, PI](range) Z軸回転
* [2] = angle of projection into x,y, plane with x-axis [-PI, PI](range)
*/
static ofVec3f cartesianToPolar(const ofVec3f &v)
{
ofVec3f polar;