Skip to content

Instantly share code, notes, and snippets.

@danydev
danydev / ssh
Last active August 3, 2023 09:33
Update iTerm Badge with hostname of the server used to ssh
#!/bin/bash
# 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
ddoomm / Node-gyp compiling with xcode 10+ and osx 10.7+.md
Last active May 17, 2019 13:48
Node-gyp compiling with xcode 10+ and osx 10.7+

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
juanca / github_load_all_diffs.js
Created March 2, 2017 18:42
Github PR bookmarklet: Load all file diffs
javascript:
document.querySelectorAll('.load-diff-button').forEach(node => node.click())
@avafloww
avafloww / PhpJava.java
Last active October 16, 2022 18:50
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@paulirish
paulirish / what-forces-layout.md
Last active April 14, 2024 08:07
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
steipete / CallOncePerRunloopHelper.m
Last active February 2, 2018 07:32
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.
/// 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) {
NSCParameterAssert(block);
NSCParameterAssert(self);
PSPDFAssertOnMainThread(); // run loop needs the main thread.
@trusktr
trusktr / DefaultKeyBinding.dict
Last active April 9, 2024 12:48
My DefaultKeyBinding.dict for Mac OS X
/* ~/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
steipete / Warnings.xcconfig
Last active February 1, 2020 15:06
The warnings configuration we use in the PSPDFKit iOS framework - http://pspdfkit.com
//
// 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
staltz / introrx.md
Last active April 15, 2024 10:24
The introduction to Reactive Programming you've been missing