Skip to content

Instantly share code, notes, and snippets.

@tluyben
tluyben / gist:867c4af4275a79d97683
Created June 27, 2014 08:00
C# filename/line number logging
View gist:867c4af4275a79d97683
public static void Log(string message, params object[] ps)
{
message = string.Format (message, ps);
var StackTrace = new System.Diagnostics.StackTrace(true);
var StackFrame = StackTrace.GetFrame(1);
string FileName = StackFrame.GetFileName();
string LineNumber = StackFrame.GetFileLineNumber().ToString();
Console.WriteLine("{0} ({1}): {2}", FileName, LineNumber, message);
View gist:67d78152ee092fe60794
public class LastReturned {
Dictionary<Thread, object> Returned = new Dictionary<Thread, object>();
public object Ret(object o) {
if (o != null) {
if (Returned.ContainsKey (Thread.CurrentThread)) {
Returned [Thread.CurrentThread] = o;
@tluyben
tluyben / gist:76ae8c74736fa47b33a4
Created August 1, 2014 11:49
Get crash reports with symbols for iOS
View gist:76ae8c74736fa47b33a4
#!/usr/bin/python
import sys
import os.path
import re
import subprocess
if len(sys.argv) < 4:
print "Usuage: ./getcrash.py AppName AppSymbol crashlog.ips"
print "Where AppName is the iOS app name without .app, AppSymbol the app name in the logs (usually almost the same as the AppName and the crash log file."
View gist:b7777f0f766bddf93d2a
Undefined symbols for architecture x86_64:
"wxTreeListCtrl::DeleteItem(wxTreeListItem)", referenced from:
gd::ChooseVariableDialog::OnvariablesListKeyDown1(wxKeyEvent&) in ChooseVariableDialog.cpp.o
gd::ChooseVariableDialog::OnRemoveSelected(wxCommandEvent&) in ChooseVariableDialog.cpp.o
gd::ChooseVariableDialog::RefreshVariable(wxTreeListItem, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, gd::Variable const&) in ChooseVariableDialog.cpp.o
"wxTreeListCtrl::SetItemData(wxTreeListItem, wxClientData*)", referenced from:
gd::SpriteObjectEditor::RefreshCollisionMasks() in SpriteObjectEditor.cpp.o
"wxTreeListCtrl::SetItemText(wxTreeListItem, unsigned int, wxString const&)", referenced from:
gd::SpriteObjectEditor::RefreshCollisionMasks() in SpriteObjectEditor.cpp.o
gd::ChooseVariableDialog::RefreshVariable(wxTreeListItem, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, gd::Variable
@tluyben
tluyben / gist:4d0973617d388f6b0873
Created January 3, 2015 10:39
Bulk extract mp3 from mkv
View gist:4d0973617d388f6b0873
#!/usr/bin/perl
@x = `find .|grep mkv\$|grep "Season "|more`;
print `mkdir encdir`;
foreach(@x) {
chomp;
$f = $_;
/.*\/(.*).mkv/;
print "$1\n";
$wav = "encdir/$1.wav";
View gist:d03bd370264f03294772
import json
import urllib2
city="bristol"
country="united kingdom"
citry = city.replace(' ', '+')
country = country.replace(' ', '+')
response = urllib2.urlopen("http://nominatim.openstreetmap.org/search?q="+city+"+"+country+"&format=json")
View gist:4afdb170e16ee49fba31
curl --data '{"email":"test7@ola.pt","password":"123456"}' http://iys.pixelly.co.uk/api/users/login/ --happlication/json"|perl -e '$l = <>; chomp($l); $uid=-1; foreach($l=~/\"UserId\"\: (\d+)/isgm) {chomp($_); if ($uid>0 and $_!=$uid){print "$_ is not $uid, AAARGH\n"; exit;}; $uid=$_; }'
@tluyben
tluyben / gist:5194b3fe57b6ee05b0b4
Created February 1, 2015 15:50
replace spaces with newlines
View gist:5194b3fe57b6ee05b0b4
cat x.asc |perl -e '@x=split(/\s/, <>); foreach(@x){print "$_\n";}' > x1.asc
@tluyben
tluyben / prefetch.html
Created March 10, 2015 11:05
Prefetch multiple videos for offline viewing
View prefetch.html
<!doctype html>
<html>
<head>
<title>Prefetch video</title>
</head>
<body>
<h1>Prefetch video</h1>
<p>Prefetch a video and know exactly how much is loaded using XHR.</p>
<video controls style="border:1px solid grey;"></video>
@tluyben
tluyben / prefetch_localstorage.html
Last active August 29, 2015 14:16
Prefetch videos and store in local storage
View prefetch_localstorage.html
<!doctype html>
<html>
<head>
<title>Prefetch video</title>
</head>
<body>
<h1>Prefetch video</h1>
<p>Prefetch a video and know exactly how much is loaded using XHR.</p>
<video controls style="border:1px solid grey;"></video>