Skip to content

Instantly share code, notes, and snippets.

@mvasilkov
mvasilkov / cleanup.sh
Created March 15, 2013 12:02
Recursively remove trailing whitespace from all files in the working directory.
#!/bin/bash
LANG=C LC_ALL=C \
find . -not \( -name .git -prune -o -name .hg -prune -o -name .svn -prune \) \
-type f -exec sed -i '' 's/[[:blank:]]*$//' '{}' \;
@mvasilkov
mvasilkov / image.py
Created March 24, 2013 11:34 — forked from homm/image.py
# -*- coding: utf-8 -*-
from PIL import Image, ImageMath
def paste_composite(original, paste):
"""
Вставляет в первое изображение второе, с учетом альфаканала обоих.
Оба изображения должны быть в формате RGBA.
"""
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|
import re
import random
CURLY_RE = re.compile( "\{(.*?)\}" )
def spam( filename, n=1 ):
file = open(filename, "r")
@mvasilkov
mvasilkov / lib.js
Created June 17, 2013 19:03
Sample code for Kiril Vatev
var lib = function() {
/* lib() is the same as lib.a() */
return lib.a.apply(lib, arguments)
}
lib.a = function() {
/* do somethig, e.g. */
console.log('lib.a() called with', arguments)
/* allow chaining */
return lib
#!/bin/bash
# +----------------------------------------------------------------------+
# | |
# | Mount the root file system / with the option noatime |
# | |
# | By Philipp Klaus <http://blog.philippklaus.de> |
# | Tip found on <http://blogs.nullvision.com/?p=275> |
# | |
# +----------------------------------------------------------------------+
{
"apache": {
"process": "/usr/sbin/httpd",
"start": "sudo apachectl start",
"stop": "sudo apachectl stop"
},
"mysql": {
"process": "/usr/local/Cellar/mysql/5.6.12/bin/mysqld",
"start": "mysql.server start > /dev/null",
"stop": "mysql.server stop > /dev/null"
@mvasilkov
mvasilkov / require.py
Last active December 19, 2015 06:48
Helper tool for Box2D-HTML5 conversion. Fucking kill Google, one Closure Library at a time.
import re
import sys
def wrap(filename):
print(filename)
with open(filename) as f:
text = f.read()
ms = re.findall(r"goog\.require\('(.+?)'\)", text)
if not ms:
ms = ['box2d']
@mvasilkov
mvasilkov / rts
Last active December 27, 2015 04:09
RTS: remove trailing spaces
#!/bin/bash
find . -not \( -name CVS -prune -or -name .git -prune \) -type f -print0 \
|xargs -0 sed -Ei '' 's/[[:space:]]{1,}$//'
@mvasilkov
mvasilkov / pcat
Created November 2, 2013 20:38
pcat: patch cat
#!/bin/bash
sed -E 's/[[:<:]]SetXYZ?[[:>:]]/Set/g' "$@"