This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
ob_start(); | |
/** | |
* Template Library | |
* | |
* @package Template | |
* @category Libraries | |
* @author Mark Watson | |
* @link http://markedup.org | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// error logging function that saves arrays, objects - anything. | |
// easier to type then always typing "error_log(print_r($var,1)); | |
function e($var, $mess=null) | |
{ | |
error_log($mess.': '.print_r($var,1)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The global model! All hail potentate MY_Controller! | |
* It provides some great default queries... | |
*/ | |
class MY_Model extends Model | |
{ | |
var $default_table; | |
function get_all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Intelligent News Parser Library | |
* | |
* @package Parse_news | |
* @category Libraries | |
* @author Mark Watson | |
* @link http://markwatson.us | |
* | |
* A simple library that parses the html from news articles to pull out metadata. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The first is to use the object oriented way: | |
$config = array( | |
'indent' => true, | |
'output-xml' => true, | |
'wrap' => 200); | |
// Tidy | |
$tidy = new tidy; | |
$tidy->parseString($xml, $config, 'utf8'); | |
$tidy->cleanRepair(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
double my_ceil(double x) { | |
double y = (double) ((long long) x); | |
if (x - y == 0) { | |
return x; | |
} else { | |
if (x > 0) { | |
return y + 1; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdjacencyMatrix[T: Manifest](size: Int) { | |
// initialize it | |
// (It's in column vector format) | |
val matrix = Array.ofDim[T](size, size) | |
// helper functions | |
// takes a list of 3-tuples in the form: (from, to, weight) | |
def setConnections(connections: List[(Int, Int, T)]) = { | |
for (x <- connections) { | |
// make matrix[to][from] = weight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mechanize | |
from BeautifulSoup import BeautifulSoup | |
class Dmoz(object): | |
def __init__(self): | |
self.br = mechanize.Browser() | |
def get_page_urls(self, term): | |
result = self.br.open("http://www.dmoz.org/search?q="+term) | |
result_html = result.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def super_split(string, delim): | |
segment = '' | |
for c in string: | |
if c in delim: | |
yield segment | |
segment = '' | |
else: | |
segment += c | |
yield segment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tested on Windows 7 and Python 2.7 | |
# the code | |
def lagrangian_interpolate(samples): | |
""" | |
Takes some samples as a list of tuples and returns a function that's | |
a lagrangian interpolation of all the samples. | |
""" | |
X = 0 # the tuple index of the X variable in the samples | |
Y = 1 # the tuple index of the Y variable in the samples |
OlderNewer