Skip to content

Instantly share code, notes, and snippets.

View alexeypegov's full-sized avatar
🖖

Alexey Pegov alexeypegov

🖖
View GitHub Profile
@alexeypegov
alexeypegov / ini.clj
Created January 7, 2018 15:17
Simple INI-file parser
(ns ini.core
(:use [clojure.string :only [index-of last-index-of trim split-lines]]
[slingshot.slingshot :only [throw+]]))
(defn- section?
"Whatever the given string is a section or not"
[s]
(and
(= (first s) \[)
(= (last s) \])))
@alexeypegov
alexeypegov / proto.msg
Last active April 27, 2022 23:36
ProtoBuffers debug with CURL. ProtoBuffers should be installed first: "yum install protobuf" or "brew install protobuf".
key:"string value"
int_key:22
@alexeypegov
alexeypegov / git-pr
Created October 16, 2013 16:46
Quick Github Pull Request for current branch. Place this script somewhere in PATH and call it like "git pr"
#!/bin/sh
function pr() {
local repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
if [ -n "$repo" ]; then
local branch=`git name-rev --name-only HEAD`
echo "... creating pull request for branch \"$branch\" in \"$repo\""
open https://github.com/$repo/pull/new/$branch
fi
}
@alexeypegov
alexeypegov / kbd.jquery.js
Created April 14, 2012 09:28
jquery human keyboard handling
// usage: $.initinput(); $.inputmap("pressed LEFT", function() { alert('pressed LEFT') }, null);
// or: $('div').inputmap("pressed ESCAPE", function() { alert('pressed ESCAPE') });
// with $.install_esc_handler() you popups will be closed by ESCAPE. Popups are elements with 'popup' class and 'z-index' > 0
$.extend({
keyCodes:{8:'BACKSPACE', 9:'TAB', 13:'ENTER', 16:'SHIFT', 17:'CONTROL', 18:'ALT', 27:'ESCAPE',
33:'PG_UP', 34:'PG_DN', 35:'END', 36:'HOME', 37:'LEFT', 38:'UP', 39:'RIGHT', 40:'DOWN',
46:'DELETE', 91:'META', 0:'UNKNOWN'},
repeatKeys:[ 37, 38, 39, 40 ],
@alexeypegov
alexeypegov / disposed.jquery.js
Created April 14, 2012 09:20
jquery disposed event to execute some code before element removal
(function ($) {
/**
* Disposer jQuery plugin.
*
* Adds 'disposed' event so you may execute some code _before_ element is somehow removed:
*
* $('.remove').bind('disposed', function() {
* // code to be executed
* });
*
@alexeypegov
alexeypegov / copy_to_itunes.scpt
Created September 10, 2010 14:33
Folder action to copy files from this folder to "Automatically Add to iTunes" folder
property extension_list : {"mp3"}
property destination_folder : (path to music folder as text) & "iTunes:iTunes Music:Automatically Add to iTunes:"
property this_action_path : (path to home folder as text) & "Library:Scripts:Folder Action Scripts:copy_to_itunes.scpt"
on adding folder items to this_folder after receiving added_items
set number_of_items to 0
repeat with i from 1 to number of items in added_items
set this_file to item i of added_items
if folder of (info for this_file) is true then
tell application "System Events"
@alexeypegov
alexeypegov / avi2m4v.scpt
Created September 4, 2010 17:18
Convert AVI files to M4V (iPhone) one by one using QuickTime Player X
--
-- simple AppleScript to convert chosen AVI files to iPhone video format one by one using QuickTime Player X
--
property outputFolder : (path to movies folder as Unicode text)
on check_exists(fileToCheck)
repeat
tell application "Finder"
if exists file fileToCheck then
exit repeat