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 formHandling = function(formSelector) { | |
var onFormSubmit, onButtonClick, onQuantityChange; | |
jQuery(formSelector).bind('submit', onFormSubmit).end() | |
.find('button').bind('click', onButtonClick).end() | |
.find('input[name="quantity"]').bind('change', onQuantityChange); | |
onFormSubmit = function() { ... }; | |
onButtonClick = function() { ... }; | |
onQuantityChange = function() { ... }; |
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 | |
$array1 = array( | |
array('code' => 1, 'quantity' => 2) | |
); | |
$array2 = array( | |
array('code' => 1, 'quantity' => 2) | |
); |
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
{% for address in customer.getAddresses %} | |
{% if loop.index % 3 == 1 %} | |
<div class="row"> | |
{% endif %} | |
{# display item #} | |
{% if loop.index % 3 == 0 or loop.last %} | |
</div> | |
{% endif %} | |
{% endfor %} |
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 | |
/** | |
* Converts elements divided by newline characters to list items | |
* @param String $text | |
* @param Array $htmlAttrs | |
*/ | |
function nl2li($text, array $htmlAttrs = null) { | |
if (!empty($htmlAttrs)) { | |
$attributes = array_walk($htmlAttrs, function($key, $value) { |
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
Soldier = function() { | |
var shot, reload, runAway, | |
ammo = 10, | |
clips = 2; | |
shot = function() { | |
if(ammo == 0 && reload() === false) { | |
runAway(); | |
} else { | |
ammmo -= 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
# This awk script splits an XML file and exports each node into separate file | |
# It doesn't work if the main node has an attribute | |
# It doesn't work if the main node contains a subnode with the same tagname, etc. | |
# Use at your own risk, think before using. | |
# Usage - replace "node" by your tag and run: $ awk -f split-xml.awk my.xml | |
/<node>/ { | |
rfile="node" count ".xml" | |
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > rfile | |
print $0 > rfile | |
getline |
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 os, codecs, unicodedata | |
def cleanup(directory): | |
for root, dirs, files in os.walk(directory): | |
for file in files: | |
if file.endswith('.ktr') or file.endswith('.kjb'): | |
filename = os.path.join(root, file) | |
f = codecs.open(filename, 'r', 'utf-8') | |
text = f.read() | |
print f |
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
/** | |
* This won't work in newer FF versions as it doesn't handle onbeforeunload properly. | |
* Need another browser oriented hack... | |
*/ | |
window.onbeforeunload = function (e) { | |
var newwindow; | |
e = e || window.event; | |
newwindow=window.open('http://www.google.com','cool-popup','height=800,width=800'); |
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 | |
function rand_str($length, $switch_chars) | |
{ | |
$valid_chars = 'ABCDEFGHIJKLMNOPQRSabcdefghijklmnopqrs0123456789'; | |
if ($switch_chars) { | |
$valid_chars = 'TUVWXYZtuvwxyz'; | |
} | |
$random_string = ""; | |
$num_valid_chars = strlen($valid_chars); |
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 | |
abstract class TableDataFormatter | |
{ | |
protected $columnConfiguration; | |
public function __construct(array $columnConfiguration) | |
{ | |
$this->columnConfiguration = $columnConfiguration; | |
} |
OlderNewer