Skip to content

Instantly share code, notes, and snippets.

@runozo
runozo / LVM on Ubuntu howto
Last active August 8, 2022 21:06
Using LVM on Linux and resize swap partition
# RESCAN FOR NEWLY ADDED HDS
echo "- - -" > /sys/class/scsi_host/host#/scan
fdisk -l
# NEW LOGICAL VOLUME
sudo fdisk /dev/sdb
# then create a new partition of type 8e (Linux LVM)
# create a phisical volume
sudo pvcreate /dev/sdb1
# create new volume group
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@james-Ballyhoo
james-Ballyhoo / critcss.snippet.js
Created September 18, 2015 08:34
Based off of https://gist.github.com/PaulKinlan/6284142 , but with support for media queries and dumps css to a textarea in a panel stuck to the top of the page. Only tested in Chrome, uses height of window to determine "critical path".
(function(){
if(document.querySelector("#_CRIT_CSS")){return;}
var container = document.createElement("div");
container.id = "_CRIT_CSS";
container.innerHTML = '<textarea cols=80 rows=20></textarea><button id="CRIT_FIND">Find Critical CSS</button><button id="CRIT_CLOSE">Exit</button>';
container.style.position = "fixed";
container.style.top = 0;
container.style.left = 0;
container.style.right = 0;
container.style.backgroundColor = "#FFF";
anonymous
anonymous / partial-application-syntax.md
Created April 9, 2015 07:32
Syntactic Sugar for Partial Application

Partial Application Syntax Sugar Proposal (a.k.a. Placeholders)

Summary

This proposal defines syntactic sugar for doing partial application in JS.

ES5 defined the bind method for function that allows partial application from the left, but bind doesn't quite cut it for a more functional style of programming. One issue is that it always binds the magic this of the function. Another one is that you can't apply from left, nor at arbitrary positions. Manually writing out the cases is also very verbose, which is something libraries attempt to solve, but given the prevalence of the pattern, this could be solved on the language level as well.

Detailed Design

@staltz
staltz / introrx.md
Last active May 24, 2024 07:56
The introduction to Reactive Programming you've been missing
@chrislkeller
chrislkeller / import_json_appsscript.js
Last active March 25, 2024 19:45
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@sspencer
sspencer / transparent-gif.js
Created October 31, 2010 22:27
Serve a transparent GIF from NodeJS
// Two ways to serve transparent GIF
var buf = new Buffer([
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00,
0x80, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x2c,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02,
0x02, 0x44, 0x01, 0x00, 0x3b]);
res.send(buf, { 'Content-Type': 'image/gif' }, 200);
@masaakif
masaakif / grep_menuitem.vim
Last active October 28, 2022 13:28 — forked from scrooloose/grep_menuitem.vim
nerdtree menu plugin to grep under selected directory. : Forked from http://gist.github.com/205807
"shove this in ~/.vim/nerdtree_plugin/grep_menuitem.vim
"
" Add 'g' menu items to grep under selected directory.
" 'g' : prompts the user to type search pattern under selected dir.
" use parent directory if file is selected.
" This uses ':grep'.
"
" For ripgrep user,
" NERDTreeRipGrepDirectory function is much, much faster.
" Requirements: