Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
It's Complicated

Dmitry Sabanin dsabanin

💭
It's Complicated
View GitHub Profile
@dsabanin
dsabanin / enable-xcode-debug-menu.sh
Last active Jul 9, 2021
Enable internal Xcode debug menu in Xcode 11
View enable-xcode-debug-menu.sh
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool YES
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode
sudo touch /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode/AppleInternal.plist
# Don't forget to restart Xcode
@dsabanin
dsabanin / start.ts
Last active Feb 12, 2019
Electron auto-update startup fix
View start.ts
// The idea here is to make sure that ShipIt process that copies the updated app exits
// before we launch the new version. The code below checks if the update is still in progress,
// which means that we are running the old app still, it keeps checking until ShipIt exits and restarts
// the app hoping that a new version will start up at that time.
//
// "find-process": "~1.2.1",
import findProcess from 'find-process';
const BUNDLE_NAME = 'com.myorganization.bundleName';
const SHIP_IT_BINARY = 'ShipIt';
View keybase.md

Keybase proof

I hereby claim:

  • I am dsabanin on github.
  • I am dsabanin (https://keybase.io/dsabanin) on keybase.
  • I have a public key ASCR4oyyMHmDzrg6nI3aHvWXodl8NimeCb3qxTnv7qscywo

To claim this, I am signing this object:

@dsabanin
dsabanin / deploy.sh
Last active Aug 29, 2015
Tiny capistrano-like script for dploy.io
View deploy.sh
# Execute as ./deploy.sh /data/project 19851203123502
# It will deploy final release as a symlink from /data/project/current to /data/project/releases/19851203123502
BASE=$1
TIMESTAMP=$2
RELEASE=$BASE/releases/$TIMESTAMP
mkdir -p $BASE/releases $BASE/shared $BASE/logs
cp -al $BASE/deploy-cache $RELEASE
@dsabanin
dsabanin / port_redirect.sh
Created May 23, 2014
Script for setting up redirect for a local port to a remote host's port (root or sudo needed)
View port_redirect.sh
#!/bin/sh
TARGET_HOST=9.9.9.9
TARGET_PORT=22
PROXY_PORT=23
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport $PROXY_PORT -j DNAT --to $TARGET_HOST:$TARGET_PORT
iptables -t nat -A PREROUTING -p tcp --dport $PROXY_PORT -j DNAT --to $TARGET_HOST:$TARGET_PORT
View raise-on-match.clj
(defmacro raise-on-match
[matches & body]
(loop [matches (->> matches (partition-all 2) (reverse))
res `(do ~@body)]
(when matches
(recur (rest matches)
`(raise-on ~(first matches) ~res)))
res))
;; Usage
View method-chaining.rb
def diffs(repo, from, to)
repo.call_git("diff ?..?", from, to).stdout.
strip.
split(/diff --git.*?$/).
map(&:strip).
uniq.
map { |d| d.blank? ? nil : d }.
compact.
map { |d| [diff_head(d), d] }
end
View lambda-calc.clj
(def first (fn [first]
(fn [second] first)))
(def second (fn [first]
(fn [second] second)))
(def make-pair (fn [first] (fn [second] (fn [func] ((func first) second)))))
(def TRUE first)
(def FALSE second)
@dsabanin
dsabanin / gist:5860527
Created Jun 25, 2013
Useful strace command
View gist:5860527
strace -qfFxv -s 1024 -p PROCESS-PID
View gist:4595299
(use 'ring.adapter.simpleweb)
;; Define a basic ring handler
(defn handler [req]
{:status 200
:headers {"Content-Type" "text/html"}
:body "Hello world from SimpleWeb"})
;; Start the server on the specified port, returning a connection
(def connection (run-simpleweb handler {:port 8080}))