Skip to content

Instantly share code, notes, and snippets.

View marcustallberg's full-sized avatar

Marcus Tallberg marcustallberg

View GitHub Profile
@marcustallberg
marcustallberg / terminal_commands.md
Created September 28, 2017 19:15
terminal commands cheatsheet

Free memory free-m

List processes with details ps -eo pid,cmd,lstart

Details on certain process ps -p $PID -o pid,vsz=MEMORY -o user,group=GROUP -o comm,args=ARGS

@marcustallberg
marcustallberg / gist:d1bae55dd408f964579f1012b2b2e659
Created February 8, 2017 17:55
Stress testing a file-upload with Apache Bench
$ab -n 10 -c 2 -p /Users/post_file.txt -T "multipart/form-data; boundary=1234567890" http://localhost/upload
post_file.txt (use CRLF line-endings):
--1234567890
Content-Disposition: form-data; filename="file.png"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
<base64 encoded file>
@marcustallberg
marcustallberg / stripWhitespaces
Created May 26, 2015 18:33
Small JavaScript Helpers
function stripWhitespaces(str){
return str.split("").filter(function(character){
return character !==" ";
}).join("");
};
var x = stripWhitespaces("A B C") // x is ABC
@marcustallberg
marcustallberg / localstorage_workaround_ios_privacybrowsing.js
Last active August 29, 2015 14:06
Workaround for iOS private browsing bug where localStorage is available but the storage quota is 0.
/*
Problem: http://stackoverflow.com/questions/14555347/html5-localstorage-error-with-safari-quota-exceeded-err-dom-exception-22-an
Solution: Workaround stores the same key/value pair with jquery.cookie and overrides the original get/set methods of localStorage.
Dependency: https://github.com/carhartl/jquery-cookie
*/
function hasTrueLocalStorage(){
try {
localStorage.setItem("foo", true);
localStorage.removeItem("foo");