Skip to content

Instantly share code, notes, and snippets.

@nb
nb / class-query-iterator.php
Created November 12, 2012 15:34
WordPress Chunk Query Iterators
<?php
/**
* Iterates over results of a query, split into many queries via LIMIT and OFFSET
*/
class QueryIterator implements Iterator {
var $limit = 500;
var $query = '';
var $global_index = 0;
@nb
nb / bootstrap-sample.php
Created August 5, 2012 19:27
Sample plugin tests config files
<?php
define( 'WP_TESTS_PATH', '<Enter the path to your unit-tests checkout>' );
$GLOBALS['wp_tests_options'] = array(
'active_plugins' => array( '<plugindir/<plugin>.php' ),
);
require rtrim( WP_TESTS_PATH, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . 'bootstrap.php';
@nb
nb / guided-tour-api.php
Created October 4, 2011 12:14
Guided Tour/Pointer API
<?php
/*
Guided Tour/Pointer API
Notes:
- exit button is by default
- next button is there if another pointer is linked to this one via previous-pointer
- if no attach-to, put it in the center if the window
- tour and pointer slugs are used for IDs in HTML and keys in user options
@nb
nb / gist:755736
Created December 26, 2010 23:47
Marketing is not a dirty word

Marketing is not a dirty word

The most unfair criticism of business folks is that they are just “marketers,” which is somewhat of a negative label in the tech sector. I think marketing gets a bad rap. In MBA terms, there are four Ps that define marketing: product, price, placement, and promotion. Defining the product and price is a creative process. The goal is to develop a product idea—sold for a profit—that matches the needs of the targeted customer. Research, analysis, and creative work are necessary in order to succeed. Placement, the third P, regards how customers will obtain the product (through a web site? the supermarket? the trunk of Fred’s car?).

Finally, promotion—what marketing is often stereotyped to mean—is how to spread the positive word about the product to influential people and potential customers. Surprisingly, promotion is a small part of a business analyst or product manager’s time (maybe 10–20%). So, marketing plans define much more than what the ads will

<?php
function redirect_on_bad_login( $redirect_to, $redirect_to_from_request, $user ) {
if ( is_wp_error( $user ) && isset( $_POST['wp-submit'] ) ) {
wp_redirect( 'http://dir.bg/' );
exit();
}
return $redirect_to;
}
@nb
nb / periodic-table.json
Created September 8, 2010 18:06
Structured information about all the elements in the periodic table
[[1, "Hydrogen", "H"], [2, "Helium", "He"], [3, "Lithium", "Li"], [4, "Beryllium", "Be"], [5, "Boron", "B"], [6, "Carbon", "C"], [7, "Nitrogen", "N"], [8, "Oxygen", "O"], [9, "Fluorine", "F"], [10, "Neon", "Ne"], [11, "Sodium", "Na"], [12, "Magnesium", "Mg"], [13, "Aluminium", "Al"], [14, "Silicon", "Si"], [15, "Phosphorus", "P"], [16, "Sulfur", "S"], [17, "Chlorine", "Cl"], [18, "Argon", "Ar"], [19, "Potassium", "K"], [20, "Calcium", "Ca"], [21, "Scandium", "Sc"], [22, "Titanium", "Ti"], [23, "Vanadium", "V"], [24, "Chromium", "Cr"], [25, "Manganese", "Mn"], [26, "Iron", "Fe"], [27, "Cobalt", "Co"], [28, "Nickel", "Ni"], [29, "Copper", "Cu"], [30, "Zinc", "Zn"], [31, "Gallium", "Ga"], [32, "Germanium", "Ge"], [33, "Arsenic", "As"], [34, "Selenium", "Se"], [35, "Bromine", "Br"], [36, "Krypton", "Kr"], [37, "Rubidium", "Rb"], [38, "Strontium", "Sr"], [39, "Yttrium", "Y"], [40, "Zirconium", "Zr"], [41, "Niobium", "Nb"], [42, "Molybdenum", "Mo"], [43, "Technetium", "Tc"], [44, "Ruthenium", "Ru"], [45, "Rhodium",
<?php
/*
Plugin Name: Different theme
Description: Use a different theme on certain conditions
Author: Nikolay Bachiyski
Version: 1.0
*/
class Different_Theme {
function __construct() {
#!/usr/bin/env python
import os
import sys
import time
import random
messages = {
0: "It is Midnight! And that's all",
1: "It's 1 o'clock and the weather outside is fine. Do you wanna go out for a walk?",
6: "A third of the number of the beast o'clock",
}
# coding: utf-8
from xmlrpclib import ServerProxy, Binary
import pickle
import re
server = ServerProxy("http://path-to-not-so-random-wp-installtion/xmlrpc.php")
essays = pickle.load(open('essays'))
for essay in essays:
try:
match = re.search(r'<([^<>]+)>\s*$', essay['from'])
# coding: utf-8
import email, imaplib, chardet, pickle
m = imaplib.IMAP4_SSL('imap.gmail.com', 993)
m.login('[email protected]', 'тринайсетзелениголиорангутанагонятгоркатапеперудка')
m.select('&BD8ENQRCBDA- &BDcEMAQ0BDAERwQw-') # пета задача
typ, data = m.search(None, 'ALL')
essays = []
for num in data[0].split():
print 'Getting %s' % num