Skip to content

Instantly share code, notes, and snippets.

@aslpavel
aslpavel / csi.py
Created September 3, 2012 07:39
Control Sequence Initiator
# -*- coding: utf-8 -*-
__all__ = ('Color', 'ColorStack', 'MoveUp', 'MoveDown', 'MoveColumn', 'Delete', 'Insert',
'Erase', 'Save', 'Restore', 'ScrollUp', 'ScrollDown', 'CursorVisible',
'COLOR_NONE', 'COLOR_BLACK', 'COLOR_RED', 'COLOR_GREEN', 'COLOR_YELLOW',
'COLOR_BLUE', 'COLOR_MAGENTA', 'COLOR_CYAN','COLOR_WHITE', 'COLOR_DEFAULT',
'ATTR_NONE', 'ATTR_NORMAL', 'ATTR_BOLD', 'ATTR_ITALIC', 'ATTR_UNDERLINE',
'ATTR_BLINK', 'ATTR_NEGATIVE', 'ATTR_FORCE',)
#------------------------------------------------------------------------------#
@aslpavel
aslpavel / pretzel_echo.py
Last active December 17, 2015 15:59
Simple echo server (with pretzel framework)
"""Simple echo server
pretzel framework: https://github.com/aslpavel/pretzel
"""
from __future__ import print_function
import sys
import socket
from pretzel.app import app
from pretzel.monad import async
from pretzel.uniform import BrokenPipeError
@aslpavel
aslpavel / pretzel_cat.py
Last active December 17, 2015 15:59
Cat remote file over ssh (with pretzel framework)
"""Cat remote file over ssh
pretzel framework: https://github.com/aslpavel/pretzel
"""
from __future__ import print_function
import os
import sys
from pretzel.app import app
from pretzel.monad import async
from pretzel.remoting import SSHConnection
@aslpavel
aslpavel / bashrc
Last active October 6, 2022 16:49
Simple bashrc with nice prompt
# simple bashrc with nice prompt
# link: https://gist.github.com/aslpavel/5925739
# install: wget --no-check-certificate -q -O - https://gist.github.com/aslpavel/5925739/download | tar -xzO -f- --strip-components=1 > "$HOME/.bashrc"
[ -z "$PS1" ] && return
### PROMPT
case $TERM in
linux|rxvt)
col_user=3
@aslpavel
aslpavel / config.fish
Last active December 19, 2015 10:19
Simple config.fish with nice prompt
# Simple config.fish with nice prompt (requires patched powerline font)
# link: https://gist.github.com/aslpavel/5939845
# install: wget --no-check-certificate -q -O - https://gist.github.com/aslpavel/5939845/download | tar -xzO -f- --strip-components=1 > "$HOME/.config/fish/config.fish"
### PROMPT
switch "$TERM"
case "linux" "rxvt"
set _prompt_sep ""
set _prompt_col_user 3
set _prompt_col_host 3
#! /usr/bin/env python3
import os
import re
import sys
import subprocess
def error(msg, code=1):
sys.stderr.write('[error] {}\n'.format(msg))
sys.exit(code)
@aslpavel
aslpavel / .ctags
Last active May 24, 2018 16:17
building ctags for mononoke
--langdef=Rust
--langmap=Rust:.rs
--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub(\(crate\))?[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\7/f,functions,function definitions/
--regex-Rust=/^[ \t]*(pub(\(crate\))?[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\3/T,types,type definitions/
--regex-Rust=/^[ \t]*(pub(\(crate\))?[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\3/g,enum,enumeration names/
--regex-Rust=/^[ \t]*(pub(\(crate\))?[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\3/s,structure names/
--regex-Rust=/^[ \t]*(pub(\(crate\))?[ \t]+)?(static|const)[ \t]+(mut[ \t]+)?([a-zA-Z0-9_]+)/\5/c,consts,static constants/
--regex-Rust=/^[ \t]*(pub(\(crate\))?[ \t]+)?(unsafe[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\4/t,traits,traits/
--regex-Rust=/^[ \t]*(pub(\(crate\))?[ \t]+)?(unsafe[ \t]+)?impl([ \t\n]*<[^>]*>)?[ \t]+(([a-zA-Z0-9_:]+)[ \t]*(<[^>]*>)?[ \t]+)?(for[ \t]+)?([a-zA-Z0-9_]+)/\9/i,impls,trait implemented for/
--regex-Rust=/^[ \t]*(pub(\(crate\))?[ \t]+)?(unsafe[ \t]+)?impl([ \t\n]*<[^>]*>)?[ \t]+(([a-zA-Z0-9_:]
@aslpavel
aslpavel / list.rs
Last active October 9, 2020 11:07 — forked from rust-play/playground.rs
List abstracted over Rc/Arc
// https://play.rust-lang.org/?gist=6f69dfefc6dd93d941cabb9a1634dcee
use std::fmt;
use std::iter::FromIterator;
use std::rc::Rc;
use std::sync::Arc;
use std::ops::Deref;
// pub trait HKT<U> where U: ?Sized {
// type C; // Current type
// type T; // Type with C swapped with U
@aslpavel
aslpavel / ad.py
Last active December 16, 2018 18:55
Simple implementation of automatic differentiation and SVM in python
"""Simple implementation of atomatic differentiation
"""
import math
import inspect
import numpy as np
def apply(fn, *args, **kwargs):
return fn(*args, **kwargs)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.