Skip to content

Instantly share code, notes, and snippets.

View viruthagiri's full-sized avatar

Viruthagiri Thirumavalavan viruthagiri

  • Bangalore, India
View GitHub Profile
@viruthagiri
viruthagiri / largenums.py
Created February 7, 2015 18:19
Write Unspeakably Large Numbers in English
z20 = ['zero','one','two','three','four',
'five','six','seven','eight','nine',
'ten','eleven','twelve','thirteen',
'fourteen','fifteen','sixteen',
'seventeen','eighteen','nineteen']
zTens = ['twenty','thirty','fourty','fifty',
'sixty','seventy','eighty','ninety']
zPlaces = ['thousand','million','billion','trillion',
{
"code": "OK",
"results": [
{
"cat_id": "11932",
"name": "Video Games",
"parent_cat_id": "1",
"parent_name": "Home"
},
{
<?php
function get_ip() {
//Just get the headers if we can or else use the SERVER global
if ( function_exists( 'apache_request_headers' ) ) {
$headers = apache_request_headers();
} else {

Howto use ListFields in Django's admin

Problem

Consider this blog post model:

models.py

class Product(models.Model):
name = models.CharField(max_length=256, unique=True)
def __unicode__(self):
return self.name
class Topic(models.Model):
name = models.CharField(max_length=256)
product = models.ForeignKey('Product', related_name='topics')
<?php
//license limit
function pw_edd_sl_license_at_limit( $ret = false, $license_id = 0, $limit = 0, $download_id = 0 ) {
$purchase_id = get_post_meta( $license_id, '_edd_sl_payment_id', true );
$purchase_date = new DateTime( get_post_field( 'post_date', $purchase_id ) );
$limit_date = new DateTime( '2013-01-01' );
if( $purchase_date < $limit_date ) {
// licenses purchased before January 1, 2013 are unlimited
@media (max-width: 479px) {
.miss_billboard {
width: auto !important;
padding: 0 20px !important;
text-align: center !important;
}
}
@media (max-width: 767px) {
body {
padding-right: 0 !important;
padding-left: 0 !important;
}
}
@media only screen and (max-width: 750px) {
.header-widget {
width: 98% !important;
padding: 1%;
}
}
@viruthagiri
viruthagiri / django-console.py
Last active September 28, 2017 16:23
Auto import Django models into Pycharm Console
#Pycharm settings -> Project settings -> Console -> Django console
from django.db.models.loading import get_models
for m in get_models():
exec "from %s import %s" % (m.__module__, m.__name__)