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 FizzBuzz($from=1, $to=100) | |
{ | |
$result = []; | |
for($i = $from; $i <= $to; $i++) { | |
if ($i % 15 == 0) { | |
$result[] = 'FizzBuzz'; | |
} elseif ($i % 3 == 0) { |
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
csv_to_xml.py | |
This script coverts a csv file to an XML. | |
The script takes 2 paramenters | |
* filename | |
* row node name |
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_group_by(array $array, callable $key_selector) | |
{ | |
$result = []; | |
foreach ($array as $values) { | |
$key = call_user_func($key_selector, $values); | |
$result[$key][] = $values; | |
} |
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 | |
$hour = date("G"); | |
if ($hour < 12) { | |
echo "good morning world"; | |
} elseif ($hour < 18) { | |
echo "good afternoon world"; | |
} else { | |
echo "good evening world"; | |
} |
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 | |
// http://25labs.com/alternative-for-file_get_contents-using-curl/ | |
function file_get_contents_curl($url, $retries=5) | |
{ | |
$ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36'; | |
if (extension_loaded('curl') === true) | |
{ |
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
{ | |
"AS10006": { | |
"Name": "SECOM Trust Systems Co.,Ltd.", | |
"Registry": "jpnic", | |
"IP Addresses": "58,368", | |
"Type": "hosting", | |
"Domains": "6,231", | |
"Domains IP": 716 | |
}, | |
"AS10010": { |
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
(GIR 0AA) | |
| (((XX[0-9][0-9]?) | |
| ([A-Z-[QVX]][0-9][0-9]?) | |
| (([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?) | |
| (([A-Z-[QVX]][0-9][A-HJKSTUW]) | |
| ([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{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
<?php | |
$translate = function ($n) { | |
if ($n % 15 == 0) return 'fizzbuzz'; | |
if ($n % 5 == 0) return 'buzz'; | |
if ($n % 3 == 0) return 'fizz'; | |
return $n; | |
}; |
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 | |
/* | |
// tracking | |
$date=date("Y-m-d H:i:s"); | |
$ip =$_SERVER['REMOTE_ADDR']; | |
$db = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR); | |
mysql_select_db($database, $db); | |
mysql_query("INSERT INTO tracking (ip, timestamp) VALUES ('$ip','$date')",$db); | |
*/ |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Torres de Hanoi</title> | |
<meta charset="utf-8"> | |
<style> | |
body,pre{ | |
font-family: monospace; | |
font-size: 15px; | |
line-height: 1em; |
OlderNewer