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 / imacros-cheatsheet.md
Created July 28, 2016 09:54
iMacros Command, Variable, and function reference
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@viruthagiri
viruthagiri / WordPress Theme Customizer Sample.php
Last active August 29, 2015 14:26 — forked from Abban/WordPress Theme Customizer Sample.php
WordPress Theme Customizer Sample
<?php
function themename_customize_register($wp_customize){
$wp_customize->add_section('themename_color_scheme', array(
'title' => __('Color Scheme', 'themename'),
'priority' => 120,
));
// =============================
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
<?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

# -*- coding:utf-8 -*-
import MySQLdb
import Queue
import re
import requests
import threading
import time
import sys
import re
import sys
with open(sys.argv[1]) as f:
previous = None
for line in f:
match = re.search('^([A-Z0-9-]+) NS', line)
if match:
domain = match.group(1).lower()
if domain != previous:
# config/initializer/active_merchant.rb
if Rails.env.production?
PAYPAL_ACCOUNT = 'production.paypal.account@domain.com'
else
PAYPAL_ACCOUNT = 'test.paypal.account@domain.com'
ActiveMerchant::Billing::Base.mode = :test
end
class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
valid = begin
URI.parse(value).kind_of?(URI::HTTP)
rescue URI::InvalidURIError
false
end
unless valid
record.errors[attribute] << (options[:message] || "is an invalid URL")