Skip to content

Instantly share code, notes, and snippets.


Daniele Orru' danydev

View GitHub Profile
danydev / ssh
Last active Nov 16, 2019
Update iTerm Badge with hostname of the server used to ssh
View ssh
# Script that updates the iTerm Badge with the hostname of the server that you are
# connecting to with ssh.
# Instructions:
# - Put this script in ~/bin/ssh (this will override the default ssh binary)
# - Run 'chmod +x ~/bin/ssh' to give execution permission to the script
# - Open iTerm\Preferences\Profiles, select your profile and put '\(user.current_ssh_host)' in the Badge text box
# - Enjoy!
ddoomm / Node-gyp compiling with xcode 10+ and osx
Last active May 17, 2019
Node-gyp compiling with xcode 10+ and osx 10.7+
View Node-gyp compiling with xcode 10+ and osx

Node-gyp compiling with xcode 10+ and osx 10.7+

The problem

On OSX 10.7+ and xcode 10+ I'm not able to install some project dependencies using npm.

NODE and NODE-GYP versions:

dom:~workspace/my_project$ nvm use 0.10.36
Now using node v0.10.36 (npm v2.15.1)
dom:~workspace/my_project$ node-gyp -v
juanca / github_load_all_diffs.js
Created Mar 2, 2017
Github PR bookmarklet: Load all file diffs
View github_load_all_diffs.js
document.querySelectorAll('.load-diff-button').forEach(node =>
forairan /
Last active Oct 22, 2020
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
class PhpJava {
static function main() {
"Hello World!");
paulirish /
Last active Oct 26, 2020
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
steipete / CallOncePerRunloopHelper.m
Last active Feb 2, 2018
To work around rdar://19810773, I need a helper that can filter multiple calls to the same method during the same runloop. This is my first attempt on it.
View CallOncePerRunloopHelper.m
/// Performs `block` immediately and ignores subsequent calls during the same runloop.
#define pspdf_ensureCalledOnlyOncePerRunloop(block) do { \
static const char __onceKey; _pspdf_ensureCalledOnlyOncePerRunloop(self, &__onceKey, block); } while(0)
extern void _pspdf_ensureCalledOnlyOncePerRunloop(id self, const void *key, dispatch_block_t block);
void _pspdf_ensureCalledOnlyOncePerRunloop(id self, const void *key, dispatch_block_t block) {
PSPDFAssertOnMainThread(); // run loop needs the main thread.
trusktr / DefaultKeyBinding.dict
Last active Oct 17, 2020
My DefaultKeyBinding.dict for Mac OS X
View DefaultKeyBinding.dict
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
steipete / Warnings.xcconfig
Last active Feb 1, 2020
The warnings configuration we use in the PSPDFKit iOS framework -
View Warnings.xcconfig
// Warnings.xcconfig
// The list of warnings we (don’t) use, and the reasons why.
// :MARK: Warnings in use:
// :MARK: -everything
// We want the best possible diagnostics, so we simply enable everything that exists, and then opt–out of what doesn’t make sense for us.
// :MARK: - Warnings not to be promoted:
staltz /
Last active Oct 26, 2020
The introduction to Reactive Programming you've been missing
You can’t perform that action at this time.