Skip to content

Instantly share code, notes, and snippets.

View astyagun's full-sized avatar

Anton Styagun astyagun

  • Russia
View GitHub Profile
@astyagun
astyagun / Launch StarCraft II.applescript
Last active December 18, 2015 05:29
AppleScript StarCraft 2 launcher that enables Function keys before the game starts and disables them again after the game quits.
to enableFunctionKeys(functionKeys)
tell application "System Preferences" to activate
tell application "System Preferences"
activate
reveal pane id "com.apple.preference.keyboard"
tell application "System Events"
tell application "System Preferences"
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
tell checkbox 1 of tab group 1 of window 1 of application process "System Preferences"
@astyagun
astyagun / .gitignore
Last active June 25, 2020 17:50
.gitignore
# Local configuration
/.docker.env
/.env
/.haml-lint.yml
/.yardoc
/coffeelint.json
/config/database.yml
/config/master.key
/config/secrets.yml.key
/config/settings.local.yml
@astyagun
astyagun / list_locks.sql
Last active September 29, 2017 17:25
PG list locks
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS blocking_statement,
blocking_activity.query_start AS blocking_start
FROM pg_catalog.pg_locks blocked_locks
JOIN pg_catalog.pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pid
JOIN pg_catalog.pg_locks blocking_locks
@astyagun
astyagun / .psqlrc
Created April 13, 2015 12:18
.psqlrc
-- display how long query takes
\timing
-- how to show NULLs
\pset null null
-- disable page
\pset pager off
-- automatic extended output based on the width of the table
@astyagun
astyagun / VK album photo links.js
Created April 18, 2015 15:16
VK album photo links
@astyagun
astyagun / Flag Project.applescript
Created January 18, 2017 18:49
Flags or unflags project of selected action(s) in OmniFocus
(*
# DESCRIPTION #
Based on: http://bylr.net/3/2015/05/omnifocus-view-project-in-new-window/
Flags or unflags project of selected action.
# LICENSE #
Copyright © 2015 Dan Byler (contact: [email protected])
@astyagun
astyagun / slack-count-links
Created February 14, 2017 15:53
Counts the number of occurrences of links to most popular domains
@astyagun
astyagun / com.exclude-code-subdirectories-from-backups.plist
Created March 16, 2017 09:39
Exclude some Rails projects subdirectories from Time Machine backups to save space. Command runs on load and daily.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.exclude-code-subdirectories-from-backups</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
@astyagun
astyagun / export_code_example
Created April 6, 2017 11:24
Extract and export code example into an archive
#!/usr/bin/env ruby
require 'fileutils'
SOURCE_DIRECTORY = File.expand_path raise 'Path to source directory is not set'
Dir.chdir SOURCE_DIRECTORY
TARGET_NAME = raise 'Target name is not set'
ARCHIVE_NAME = "#{TARGET_NAME}.zip"
TARGET_DIRECTORY = File.expand_path "../#{TARGET_NAME}"
ARCHIVE_TAGET_DIRECTORY = raise 'Archive target directory is not set'
@astyagun
astyagun / tmux-shell
Last active June 9, 2019 19:52
tmux shell for macOS Terminal application
#!/bin/bash -l
# tmux shell for macOS Terminal application
#
# Starts tmux taking current directory and open tmux sessions into account
#
# When Terminal starts, it's $PWD always equals $HOME. Except cases when Terminal application was told to open
# some particular directory (`open ~/Code -a Terminal` for instance).
#
# In the first case we want to attach to existing tmux session if one exists. If there is more than one
# session open, the script will ask user which session to attach to.