This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIPasteboard* pasteBoard = [UIPasteboard generalPasteboard]; | |
[pasteBoard setString:@"any NSString"]; | |
NSString* clipboard = [pasteBoard string]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_once('Mail/mimeDecode.php'); | |
$mail = file_get_contents($filename); | |
$params['include_bodies'] = true; | |
$params['decode_bodies'] = true; | |
$params['decode_headers'] = true; | |
$decoder = new Mail_mimeDecode($mail); | |
$structure = $decoder->decode($params); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%s/\([^.?!]\)\n/\1 /g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method takes in one argument, a filename, and looks up its extension in the dictionary. | |
// If you want to do this in another language, use the bookmarklet below to regenerate a dictionary or array in whatever format you want. | |
// | |
// Written 2012 by Joshua Gross for SpanDeX, Inc. Do whatever you want with this. | |
// | |
// I used a bookmarklet to generate this mimeTypes dictionary | |
// Navigate to http://www.webmaster-toolkit.com/mime-types.shtml | |
// and use this bookmarklet: | |
// javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.3.2",function($,L){ var mimeTypes = {}; $('div.content > div > table > tbody > tr').each(function (i, el) { var children |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl -L https://www.npmjs.org/install.sh | sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node -e "var client; (client = new require('net').Socket()).connect(7000, \"0.0.0.0\", function () { console.log(\"connected\"); client.on(\"data\", function (data) { console.log(\"Received:\" + data); client.destroy(); }); client.write(\"holla\"); });" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install: | |
npm install -g sort-json | |
# Put this in your ~/.profile, and then: | |
# cat something.json | normalize_json | |
alias normalize_json="node -e 'var s = \"\"; process.stdin.on(\"data\", function (d) { s += d.toString(); }); process.stdin.resume(); process.on(\"exit\", function() { console.log(JSON.stringify(require(\"sort-json\")(JSON.parse(s)), null, 2)); });'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/JoshuaGross/ad146e15c80ba7424ede | |
# Open vim to a certain file, line, and (optionally) column | |
function vimline { | |
col=$(echo $1 | awk '{split($0,a,":"); print a[3]}') | |
line=$(echo $1 | awk '{split($0,a,":"); print a[2]}') | |
file=$(echo $1 | awk '{split($0,a,":"); print a[1]}') | |
if [ -z "$col" ]; then | |
linecol="+$line" | |
else | |
linecol="+call cursor($line, $col)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
relname as "Table", | |
pg_size_pretty(pg_total_relation_size(relid)) As "Size", | |
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size" | |
FROM | |
pg_catalog.pg_statio_user_tables | |
ORDER BY pg_total_relation_size(relid) DESC; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
relname AS objectname, | |
relkind AS objecttype, | |
reltuples AS "#entries", | |
pg_size_pretty(relpages::bigint*8*1024) AS size | |
FROM pg_class | |
WHERE relpages >= 8 | |
ORDER BY relpages DESC; |
OlderNewer