Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active April 6, 2023 11:58
Epicyclic Gearing
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/epicyclic-gearing
@jasny
jasny / mysql_splitdump.sh
Last active February 15, 2024 16:13
Split MySQL dump SQL file into one file per table or extract a single table
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit
@mbostock
mbostock / .block
Last active June 11, 2018 03:00
Asynchronous Queue
license: gpl-3.0
@olimortimer
olimortimer / gist:3032672
Created July 2, 2012 10:48
JS: jQuery Replace HREF Query String
// www.website.com/page?id=100
$('#pageLink').attr('href', $('#pageLink').attr('href').replace(/((\?|&)id\=)[0-9]*/, '$1' + '123'));
// www.website.com/page?id=123
@RichardSlater
RichardSlater / underwater.js
Created October 9, 2012 18:16
Unity3d Underwater Effect
//This script enables underwater effects. Attach to main camera.
//Define variables
var underwaterLevel = 7;
//The scene's default fog settings
private var defaultFog;
private var defaultFogColor;
private var defaultFogDensity;
private var defaultSkybox;
@mattratleph
mattratleph / vimdiff.md
Last active March 27, 2024 10:04 — forked from roothybrid7/vimdiff_cheet.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@NKjoep
NKjoep / myprompt-bash.sh
Last active September 27, 2016 16:58
My Bash Prompt
# Color Reset
Color_Off="\033[0m" # Text Reset
# Regular Colors
Black="\033[0;30m" # Black
Red="\033[0;31m" # Red
Green="\033[0;32m" # Green
Yellow="\033[0;33m" # Yellow
Blue="\033[0;34m" # Blue
Purple="\033[0;35m" # Purple
@mbostock
mbostock / .block
Last active November 7, 2023 07:54
Collapsible Tree
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-collapsible-tree
@nasirkhan
nasirkhan / git command.markdown
Last active May 12, 2022 03:17
`git` discard all local changes/commits and pull from upstream

git discard all local changes/commits and pull from upstream

git reset --hard origin/master

git pull origin master

@mbostock
mbostock / README.md
Last active November 5, 2017 17:51
Infinite Queue

A little demo of an infinitely long-living queue with 6 parallel slots for tasks. The sentinel task that never invokes the callback prevents the queue from ending, even if there are not any currently-active tasks.

There is a downside to this approach, however, which is that the queue’s internal task results array increases in length by one with each task, even though in this case the queue’s results are never triggered. Thus, be careful using this pattern if you really expect the queue to live indefinitely. Alternatively, it might be worth extending Queue’s minimal API to allow tasks to be processed without tracking their return value.