Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dsabanin's full-sized avatar
💭
It's Complicated

Dmitry Sabanin dsabanin

💭
It's Complicated
View GitHub Profile
@dsabanin
dsabanin / start.ts
Last active April 18, 2023 09:08
Electron auto-update startup fix
// 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';
@dsabanin
dsabanin / enable-xcode-debug-menu.sh
Last active November 7, 2022 16:17
Enable internal Xcode debug menu in Xcode 11
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 / readme.md
Created August 7, 2021 15:32 — forked from nickcernis/readme.md
Exclude node_modules and .git from Backblaze backups on Mac

Exclude node_modules and .git from Backblaze backups on Mac

  1. Edit the file at /Library/Backblaze.bzpkg/bzdata/bzexcluderules_editable.xml.
  2. Add these rules inside the bzexclusions tag:
<!-- Exclude node_modules. -->
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/node_modules/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/.git/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
@dsabanin
dsabanin / keybase.md
Created July 5, 2016 14:28
Keybase proof

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 / raise-on-match.clj
Last active December 24, 2015 00:39
raise-on-match
(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
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
(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 June 25, 2013 17:36
Useful strace command
strace -qfFxv -s 1024 -p PROCESS-PID
(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}))
def benchmark(name, &blk)
t1 = Time.now
ret = blk.call
time = Time.now - t1
$STATSD.timing(name, time)
[ret, time]
end
retvalue, time = benchmark("svn-commit-time") do
`svn command blah`