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 re | |
import unittest | |
class CsvReader(object): | |
""" | |
Reads CSV files while handling all types of edge cases. | |
""" | |
def __init__(self, lines): | |
""" | |
A new CSV reader with the given lines. |
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
function countCSSRules() { | |
var results = '', | |
log = ''; | |
if (!document.styleSheets) { | |
return; | |
} | |
for (var i = 0; i < document.styleSheets.length; i++) { | |
countSheet(document.styleSheets[i]); | |
} | |
function countSheet(sheet) { |
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
var createEl = function(type, props, children) { | |
var el = document.createElement(type); | |
if (props) { | |
for (var key in props) { | |
if (props.hasOwnProperty(key)) { | |
if (key == "css") { | |
if (props[key].length > 0) { | |
el.style.cssText = props[key].join(';') + ";"; | |
} | |
} 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
$.fn.mwOnChange = function(callback, timeout) { | |
return $(this).each(function() { | |
if (timeout === undefined) { | |
timeout = 500; | |
} | |
var eventNames = 'keydown paste input'; | |
var timeoutId = null; | |
$(this).on(eventNames, function(e) { | |
var self = this; |
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 { |
OlderNewer