Skip to content

Instantly share code, notes, and snippets.

@koohz
koohz / gist:0e5d94d0e8534d55edc2
Last active August 29, 2015 14:20
Get Season By Given Day and Month
/*
* 0 = winter
* 1 = spring
* 2 = summer
* 3 = autumn
*/
function get_season(day, month)
{
return parseInt(((month - (+(day < 21))) / 3) % 4);
}
@koohz
koohz / mb-custom-attrs.php
Created January 6, 2015 22:31
Trick: How to add custom html attributes to a wordpress metabox
<?php
add_filter( 'postbox_classes_post_metaboxid', function ($classes) {
// Notice the unmatched <">, this will close the class attribute
// Ex: <" customattribute="Hello World>
array_push($classes, '" custom_attribute="Hello World' );
return $classes;
});
?>
from gi.repository import Gtk, GObject
from gi.repository.GdkPixbuf import Pixbuf
icons = ["gtk-cut", "gtk-paste", "gtk-copy"]
class IconViewWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.set_default_size(200, 200)
@koohz
koohz / PyGObject.TreeView-Multi-Column-Filtering.py
Last active February 10, 2021 14:01
A PyGtk example for filtering multiple columns in a TreeView
#!/usr/bin/python
from gi.repository import Gtk
import random
DUMMY_WORDS = '''Omnisciently sepulture innervating reducate louden fleming
psoatic opinionatedly upington unmistrusted psychognosis
jackfish tutankhamen piled Hyperpotassemia schopenhauerism
venomness grendel bleakly unbungling dolius proempiricist
ableptically siniju woolley giulietta semisentimentalized
tolerably Moultrie prelawful prague mangler gainfulness