Skip to content

Instantly share code, notes, and snippets.

@Enricoza
Enricoza / DisaptchForestPremise.md
Last active April 26, 2024 10:15
[iOS - Swift] Organize serial DispatchQueue (Trees) in a small DispatchForest to improve performance and avoid Thread explosion

This code is my opinionated interpretation of an idea expressed by eskimo on this swift forum thread, to which I briefly partecipated. I'll try to summarize his viewpoint in this premise, as well as some of the suggestions from this gist.

  1. You should virtually never create a queue with DispatchQueue.global() nor with the concurrent flag.
  2. You should create a limited number (a small Forest) of SERIAL queues (the Trees), one for each subsystem in your program.
  3. Apart from those base queues (the Trees), you should never create any more queues without specifying the target queue.
  4. You can, instead, create as many queues (the Branches) as you want, as long as they are targeting those base queues (the Trees).
  5. You should dispatch large chunks of code, in order to reduce the overhead of the dispatch operations.
  6. Therefore, you should mov
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 26, 2024 10:15
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@saitamanodoruji
saitamanodoruji / SearchTweetsOnGoogle.user.js
Last active April 26, 2024 10:15
Google search + twitter search mashup
// ==UserScript==
// @name SearchTweetsOnGoogle
// @namespace saitamanodoruji
// @description Google search + twitter search mashup
// @include http://*.google.*/search?*
// @include https://*.google.*/search?*
// @version 0.0.2.5
// @update 2013-09-10
// @author saitamanodoruji
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active April 26, 2024 10:15
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@saitamanodoruji
saitamanodoruji / unbindCallbacksOnFlatscrollOnTumblrDashboard.user.js
Last active April 26, 2024 10:14
Tumblr Dashboard でスクロールイベントにバインドされてる callback を全部切る
// ==UserScript==
// @name Unbind Callbacks on Flatscroll on Tumblr Dashboard
// @namespace http://saitamanodoruji.tumblr.com/
// @description Tumblr Dashboard でスクロールイベントにバインドされてる callback を全部切る
// @include http://www.tumblr.com/dashboard*
// @include http://www.tumblr.com/likes*
// @include http://www.tumblr.com/liked/by/*
// @include http://www.tumblr.com/tagged/*
// @include http://www.tumblr.com/blog/*
// @exclude http://www.tumblr.com/dashboard/iframe*
// ==UserScript==
// @id laborious spin
// @name laborious spin
// @version 1.1
// @namespace saitamanodoruji
// @author saitamanodoruji
// @description spin it the hard way
// @include *
// @run-at document-end
// @update 2014-12-05
@bakavets
bakavets / kubernetes-certifications.md
Last active April 26, 2024 10:14
How I passed Kubernetes KCNA, CKAD, CKA, and CKS exams. My experience. Exam tips and tricks.
@tobywf
tobywf / build-dvisvgm.sh
Last active April 26, 2024 10:14
Build dvisvgm and kpathsea on macOS
#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
PREFIX="${1:-/usr/local/dvisvgm}"
TEX="$(kpsewhich -var SELFAUTOLOC)"
echo "$PREFIX, $TEX"
brew install automake freetype ghostscript potrace
// ==UserScript==
// @name Share2chOnTumblr
// @namespace http://saitamanodoruji.tumblr.com/
// @description Share 2ch conversation on Tumblr as Quote
// @include http://*.2ch.net/test/read.cgi/*
// @include http://*.2ch.net/*/kako/*
// @include http://*.bbspink.com/test/read.cgi/*
// @include http://jbbs.livedoor.jp/bbs/read.cgi/*
// @include http://jbbs.livedoor.jp/*/*/*/*.html
// @include http://p2.chbox.jp/read.php?url=http://*.2ch.net/test/read.cgi/*
@rahularity
rahularity / work-with-multiple-github-accounts.md
Last active April 26, 2024 10:11
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent