Skip to content

Instantly share code, notes, and snippets.

@bacher09
bacher09 / flask_app.py
Created September 20, 2014 11:00
jinja do example
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def hello_world():
return render_template('test.txt')
if __name__ == '__main__':
app.jinja_env.add_extension('jinja2.ext.do')
app.run(debug=True)
@bacher09
bacher09 / func_index.py
Last active August 29, 2015 14:10
demonstration of functional index dynamic creation
import sys
from sqlalchemy import create_engine, Column, Integer, Index, event
from sqlalchemy.ext.declarative import declarative_base, declared_attr
engine = create_engine('postgresql://slava:slavapw@localhost:5432/test', echo=True)
Base = declarative_base()
class BaseModel(Base):
package main
import (
"encoding/binary"
"flag"
"fmt"
"log"
"net"
"sync"
"time"
module Utf8 where
import qualified Data.ByteString as B
import Control.Applicative
import Data.Word
import Data.Bits
import Data.Char
import Debug.Trace
utf8SeqInfo :: Word8 -> Maybe (Word8, Word8)
>>> a = "realylongstringwithmanychars"
>>> b = "realylongstringwithmanychars"
>>> a is b
True
>>> a = "a b c"
>>> b = "a b c"
>>> a is b
False
function string_ends(text, ends)
return ends == "" or string.sub(text, -string.len(ends)) == ends
end
function vlc_format(filename)
-- https://wiki.videolan.org/VLC_Features_Formats#Format.2FContainer.2FMuxers
local formats = {
"3gp", "asf", "wmv", "au", "avi", "mka", "mkv", "flv", "mov", "mp4",
"ogg", "ogm", "ts", "mpg", "mp3", "mp2", "msc", "msv", "nut", "ra",
#!/bin/bash
XONOTIC_LINUX=xonotic-glx
XONOTIC_OSX="open $HOME/Downloads/Xonotic/Xonotic.app -W --args"
XONOTIC_DATA_LINUX=$HOME/.xonotic/data
XONOTIC_DATA_OSX="$HOME/Library/Application Support/xonotic/data"
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
module Main where
import Data.Array.IArray
import Data.Tuple (swap)
import System.Random
import Data.List (foldl')
data CoinType = Gold
| Silver
deriving(Show, Read, Eq, Ord, Bounded, Enum)
@bacher09
bacher09 / aliases.sh
Last active February 5, 2017 13:58
Useful aliases
myip() {
curl -4 "http://icanhazip.com/"
}
myip6() {
curl -6 "http://icanhazip.com/"
}
reverse_ipv4() {
local ip="$1"
@bacher09
bacher09 / Makefile
Created December 2, 2015 18:31
simple http service
CC=gcc
LIBS=-lpthread -lfcgi -lGeoIP
CFLAGS=-Wall --std=c11 -O2 -D_POSIX_C_SOURCE=200809L
DEPS=geoip_api.h http_utils.h
TARGET=ip_api
.PHONY: all
all: $(TARGET)