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 | |
const INT_COUNT = 1000000; | |
// Fill an array with random ints | |
$ints = []; | |
for ($i = 0; $i < INT_COUNT; $i++){ | |
$ints[] = rand(0, 255); | |
} | |
// Sort the ints |
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
ZEND_API int zend_hash_rehash(HashTable *ht) | |
{ | |
Bucket *p; | |
uint nIndex; | |
IS_CONSISTENT(ht); | |
if (UNEXPECTED(ht->nNumOfElements == 0)) { | |
return SUCCESS; | |
} |
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 | |
class SayDate extends DateTime { | |
public function say(){ | |
$now = new DateTime(); | |
$now->setTime(0, 0, 0); | |
$interval = (int) $now->diff($this)->format('%r%a'); | |
if ($interval < 0){ | |
return $this->format('Y-m-d'); |
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
package main | |
import ( | |
"log" | |
"fmt" | |
"encoding/json" | |
) | |
func main() { | |
b := []byte(`{"name": "tom", "favNum": 6, "interests": ["knives", "computers"], "usernames": {"github": "TomNomNom", "twitter": "@TomNomNom"}}`) |
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 | |
// Change me | |
const ADDRESS_ID = 'Gold|StringOfAlphas|MY|HouseNumber'; // You can find your Address ID using this: https://gist.github.com/TomNomNom/7875919 | |
const TO_EMAIL = 'me@example.com'; | |
const FROM_EMAIL = 'server@example.com'; | |
// Don't change me | |
const SERVICE_URL = 'http://www.productsandservices.bt.com/consumerProducts/v1/productAvailability.do'; |
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 | |
const HOUSE_NUMBER = 2; | |
const POSTCODE = 'LS1 4AP'; | |
const SERVICE_URL = 'http://www.productsandservices.bt.com/consumerProducts/v1/addressSearch.do'; | |
$query = http_build_query(array( | |
'postcode' => POSTCODE, |
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 array_extract(array $input, array $keys){ | |
$output = []; | |
foreach ($keys as $key){ | |
if (!array_key_exists($key, $input)) continue; | |
$output[$key] = $input[$key]; | |
} | |
return $output; | |
} |
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
#!/bin/bash | |
DATE_FMT="%Y-%m-%dT%H:%M:%S" | |
BACKUP_PREFIX="backup" | |
E_ARGS=1 | |
E_NO_SOURCE_DIR=2 | |
E_NO_DEST_DIR=3 | |
E_RSYNC_FAIL=4 |
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 http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
}).listen(1337, '0.0.0.0'); | |
console.log('Server running at http://0.0.0.0:1337/'); |
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
alert(1); |