Skip to content

Instantly share code, notes, and snippets.

@mendhak
mendhak / gist:3369288
Created August 16, 2012 10:59
Extension method to get value from a field in a datarow
public static T GetValue<T>(this DataRow row, string field)
{
if (!row.Table.Columns.Contains(field))
{
return default(T);
}
else
{
return (T)Convert.ChangeType(row[field].ToString(), typeof(T));
@mendhak
mendhak / starhscale.py
Created May 15, 2012 21:10
A custom GTK widget; horizontal slider with stars for rating an item
#!/usr/bin/env python
"""
StarHScale a Horizontal slider that uses stars
Copyright (C) 2006 Mark Mruss <selsine@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@mendhak
mendhak / gist:1297742
Created October 19, 2011 08:37
Get a URL in Java
public static String GetUrl(String url) throws Exception
{
URL serverAddress = null;
HttpURLConnection connection = null;
// OutputStreamWriter wr = null;
BufferedReader rd = null;
StringBuilder sb = null;
String line = null;
try