Skip to content

Instantly share code, notes, and snippets.

View vol4ok's full-sized avatar

Andrew Volkov vol4ok

View GitHub Profile
@vol4ok
vol4ok / gist:5270397
Last active December 15, 2015 13:49
Mac OS X Lion: How to clean up the 'Open With' menu
  1. Execute:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
  1. Relaunch the Finder
@vol4ok
vol4ok / gist:4952077
Created February 14, 2013 11:01
extract mp3 audio from video files
for f in *.mp4
ffmpeg -i "$f" -ab 32k -ac 1 -acodec mp3 -vn "${f%.*}.mp3"
done
@vol4ok
vol4ok / Cakefile
Created December 20, 2012 08:50
Cakefile loader
build = (opt) ->
console.log "build!"
if task?
console.log "task"
task "sbuild", ->
build()
else
console.log "exports"
exports.build = build
@vol4ok
vol4ok / gist:4249910
Created December 10, 2012 10:46
getStartOfWeek
DAY = 86400000
getStartOfWeek = (t) ->
UTC3_OFFSET = 60*60*3
kDays4Years = [0, 365, 2 * 365, 3 * 365 + 1]
kDaysIn4Years = 4 * 365 + 1
kDaysIn100Years = 25 * kDaysIn4Years - 1
kDaysIn400Years = 4 * kDaysIn100Years + 1
kDays1970to2000 = 30 * 365 + 7
kDaysOffset = 1000 * kDaysIn400Years + 5 * kDaysIn400Years - kDays1970to2000
kYearsOffset = 400000
@vol4ok
vol4ok / chain.js
Created October 18, 2012 14:08
chain
$.chain = function() {
var tasks
, args = []
, error = noop;
if(arguments.length === 3) {
args = $.isArray(arguments[0]) ? arguments[0] : [arguments[0]];
tasks = arguments[1];
error = arguments[2];
} else if(arguments.length === 2) {
@vol4ok
vol4ok / ast-walker.coffee
Created October 11, 2012 14:23
AST walker for esprima
Syntax =
AssignmentExpression: 'AssignmentExpression'
ArrayExpression: 'ArrayExpression'
BlockStatement: 'BlockStatement'
BinaryExpression: 'BinaryExpression'
BreakStatement: 'BreakStatement'
CallExpression: 'CallExpression'
CatchClause: 'CatchClause'
ConditionalExpression: 'ConditionalExpression'
ContinueStatement: 'ContinueStatement'
@vol4ok
vol4ok / create_github_repo.sh
Created May 11, 2012 06:52
create github repo from shell
curl -u "YOUR_USERNAME" https://api.github.com/user/repos -d '{"name":"MY NEW REPO","description":"REPO DESCRIPTION", "private": false}'
@vol4ok
vol4ok / gist:2587886
Created May 3, 2012 18:21
Split .ape and .flac and convert to .m4a (ALAC) or .mp3 on MacOS X
brew install flac ffmpeg cuetools # ставим нужные пакеты
# скачиваем cuetag.sh скрипт, например отсюда https://github.com/gumayunov/split-cue/blob/master/cuetag
ffmpeg -i 1.ape 1.flac # конвертируем во flac, так как libmac для APE не ставится на osx
cuebreakpoints 1.cue | shnsplit -o flac 1.flac #нарезаем на треки
cuetag 1.cue split-track*.flac #прописываем тэги (cuetag.sh ставится отдельно отдельно)
#конвертируем в ALAC
for f in split-track*.flac
do
@vol4ok
vol4ok / stylus.tmsyntax
Created February 11, 2012 12:09
My TextMate syntax for stylus
{ scopeName = 'source.stylus';
fileTypes = ( 'styl', 'stylus' );
patterns = (
{ name = 'comment.line.stylus';
match = '(?:^[ \t]+)?(\/\/).*$\n?';
captures = { 1 = { name = 'punctuation.definition.comment.stylus'; }; };
},
{ name = 'comment.block.stylus';
begin = '/\*';
end = '\*/';
@vol4ok
vol4ok / restart.c
Created February 10, 2012 06:44
restart root nginx
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
int result;
setuid( 0 );
result = system("/bin/bash -c 'kill -HUP `cat /usr/local/var/run/nginx.pid`'");