THIS GIST WAS MOVED TO TERMSTANDARD/COLORS
REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
# | |
# Mac OS-X does not come with the delightfully useful `timeout` program. Thankfully a rough BASH equivalent can be achieved with only 2 perl statements. | |
# | |
# Originally found on SO: http://stackoverflow.com/questions/601543/command-line-command-to-auto-kill-a-command-after-a-certain-amount-of-time | |
# | |
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; } | |
## Example usage: | |
# |
THIS GIST WAS MOVED TO TERMSTANDARD/COLORS
REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns on recent CPU
L2 cache reference ........................... 7 ns 14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns 20x L2 cache, 200x L1 cache
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 4X memory
: ::\ | |
@echo off | |
rem () ( command -v $1 >/dev/null 2>&1; return $? ) | |
rem : "Usage sh: $ sh exists.cmd ls && echo exists " | |
rem : "Usage bat: > exists.cmd notepad " | |
rem : " > echo %ErrorLevel% " | |
rem $1 <<REM | |
:exists |
#!/bin/bash | |
usage() { | |
cat << EOF | |
Usage: $0 [OPTION]... COMMAND | |
Execute the given command in a way that works safely with cron. This should | |
typically be used inside of a cron job definition like so: | |
* * * * * $(which "$0") [OPTION]... COMMAND | |
Arguments: |
Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history. This feature can improve the quality of the commits. It also makes it easy to remove parts of the changes in a file that were only there for debugging purposes - prior to the commit without having to go back to the editor.
It allows you to see the changes (delta) to the code that you are trying to add, and lets you add them (or not) separately from each other using an interactive prompt. Here's how to use it:
from the command line, either use
M[16],X=16,W,k;main(){T(system("stty cbreak") | |
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i | |
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M | |
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<< | |
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k) | |
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d | |
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X] | |
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4; | |
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4|| | |
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2 |
#!/bin/sh | |
# Copyright 2014 Vivien Didelot <vivien@didelot.org> | |
# Licensed under the terms of the GNU GPL v3, or any later version. | |
NICK=irccat42 | |
SERVER=irc.freenode.net | |
PORT=6667 | |
CHAN="#irccat" | |
{ |
// | |
// Crashed Thread: 0 Dispatch queue: com.apple.main-thread | |
// | |
// Exception Type: EXC_BAD_ACCESS (SIGSEGV) | |
// Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 | |
// | |
// VM Regions Near 0: | |
// --> | |
// __TEXT 000000010d268000-000000010d26a000 [ 8K] r-x/rwx SM=COW /Users/USER/Library/Developer/Xcode/DerivedData/CrashSymbolTest-duwezzdulbkaqtffihfubuglwpki/Build/Products/Debug/CrashSymbolTest | |
// |
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# Python script to find the largest files in a git repository. | |
# The general method is based on the script in this blog post: | |
# http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ | |
# | |
# The above script worked for me, but was very slow on my 11GB repository. This version has a bunch | |
# of changes to speed things up to a more reasonable time. It takes less than a minute on repos with 250K objects. | |
# |