Skip to content

Instantly share code, notes, and snippets.

View ento's full-sized avatar

ento

View GitHub Profile
@ento
ento / gist:126562
Created June 9, 2009 15:03
Get script's own location in Python
import os
local_dir = os.path.dirname(__file__)
abs_dir = os.path.join(os.getcwd(), local_dir)
if __name__ == "__main__":
print("Hello World!")
@ento
ento / python.py
Created July 14, 2009 09:10
"Am I run as a script?"
if __name__ == '__main__':
main()
@ento
ento / gist:151861
Created July 22, 2009 07:22
How to access a variadic argument in Objective-C
- (void)variadic:(NSString*)strings, ... {
va_list lst;
NSString* each;
va_start(lst, strings);
while (each = va_arg(lst, NSString*)) {
[NSString stringWithString: each];
}
va_end(lst);
}
@ento
ento / Inject Javascript Profiler on document load
Created August 28, 2009 00:31
User script to inject Javascript Profiler on document load
/*
*
* Author: ento
*
* Copyright (c) 2005-2008, Jaidev K Sridhar
* Released under the GPL license
* http://www.gnu.org/copyleft/gpl.html
*/
// ==UserScript==
/* This greasemonkey script automatically BCCs (or CCs) outgoing email from
* a gmail address to a specified email address
*
* Author: Jaidev K Sridhar mail<AT>jaidev<DOT>info
*
* Copyright (c) 2005-2008, Jaidev K Sridhar
* Released under the GPL license
* http://www.gnu.org/copyleft/gpl.html
*/
SLAVE STOP;
CHANGE master to master_log_file=Relay_Master_Log_File,master_log_pos=Exec_Master_Log_Pos;
SLAVE START;
<html>
<head>
<meta id="viewport" name="viewport" content="width=320, height=500" />
</head>
<body>
<div>Here comes an iframe.</div>
<iframe src="../336c3060c233f1662ad7461e0f0514543bc79093/included.html">
</iframe>
<div>End of iframe.</div>
</body>
@ento
ento / py_traceback.py
Created March 31, 2010 09:19
printing traceback info on python
import traceback, StringIO
fp = StringIO.StringIO()
traceback.print_exc(file=fp)
print fp.getvalue()
(println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
@ento
ento / set_exif_datetime_to_ctime.sh
Created February 26, 2011 07:45
Requires exiv2
#!/bin/sh
for f in $@
do
ctime=`stat -f "%SB" -t "%Y:%m:%d %H:%M:%S" "$f"`
exiv2 -k -M"set Exif.Image.DateTime Ascii $ctime" "$f"
done