Skip to content

Instantly share code, notes, and snippets.

View obradovic's full-sized avatar
🏠
Working from home

Zo Obradovic obradovic

🏠
Working from home
View GitHub Profile
@obradovic
obradovic / gist:3e9b285d8208e55f2ecb
Created August 17, 2014 07:29
find deleted file handles
lsof | grep '(deleted)$'
@obradovic
obradovic / gist:965fdafc64117ad3eb44
Created August 15, 2014 00:55
digitalocean images list
curl "https://api.digitalocean.com/images/?client_id=$DO_CLIENT_ID&api_key=$DO_API_KEY&filter=global" | js
@obradovic
obradovic / exceptions.php
Created January 24, 2014 19:01
Performance test of PHP exception throw/catching
<?php
$time = microtime(TRUE);
$mem = memory_get_usage();
$arr = array();
foreach (range(1, 1000000) as $i) {
try {
$arr[$i] = $i;
// throw new Exception("foo");
@obradovic
obradovic / jenkins-update.sh
Created December 22, 2013 05:10
Force Jenkins to update its list of plugins
wget -O default.js http://updates.jenkins-ci.org/update-center.json
sed '1d;$d' default.js > default.json
curl -X POST -H "Accept: application/json" -d @default.json http://localhost:8080/updateCenter/byId/default/postBack --verbose
@obradovic
obradovic / sitemedia.js
Last active December 31, 2015 04:59
mongo sitemedia.js
function printResult (r) {
print(tojson(r))
}
db.sitemedia.find().forEach(printResult)
db.getCollectionNames().forEach(printResult)
@obradovic
obradovic / lowercase.java
Created October 12, 2013 18:16
Is toLowerCase() mildly optimized? Yes. Yes it is.
public class lowercase {
public static void main (String [] args) {
String x = "foobar";
System.out.println(x == x.toLowerCase());
x = "Foobar";
System.out.println(x == x.toLowerCase());
}
}
@obradovic
obradovic / Concat.java
Created October 3, 2013 18:16
Java - performance of String concatenation vs String format:
public class Concat {
public static void main(String[] args) throws Exception {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
String s = "Yo " + i + ". Yo Adrian " + i*2;
}
long end = System.currentTimeMillis();
System.out.println("String Concatenation: " + ((end - start)) + " ms") ;
@obradovic
obradovic / loadspeed.js
Created September 12, 2013 20:20
Phantom loadspeed
var page = require('webpage').create(),
system = require('system'),
t, address;
if (system.args.length === 1) {
console.log('Usage: loadspeed.js <some URL>');
phantom.exit();
}
t = Date.now();
¯\_(ツ)_/¯
@obradovic
obradovic / final_exam.txt
Last active June 25, 2024 09:20
Humane Interfaces with Jef Raskin, final exam
QUESTION:
1. Among the topics mentioned in class are
a. Modelessness
b. Monotony
c. Habituation
d. Attention and Locus of Attention
Why can proper use or recognition of each be important for usability and
what is the relationship among them. In your answer, define these terms.
When appropriate, express your answer in terms of gestures.