Skip to content

Instantly share code, notes, and snippets.

View ASNInfo.json
{
"AS10006": {
"Name": "SECOM Trust Systems Co.,Ltd.",
"Registry": "jpnic",
"IP Addresses": "58,368",
"Type": "hosting",
"Domains": "6,231",
"Domains IP": 716
},
"AS10010": {
@jrivero
jrivero / UK POSTCODE PATTERN
Created Aug 23, 2016 — forked from spc16670/UK POSTCODE PATTERN
UK Postcode Regex pattern
View UK POSTCODE PATTERN
(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})
@jrivero
jrivero / FizzBuzz.php
Created Mar 17, 2016
FizzBuzz implementation using array_map
View FizzBuzz.php
<?php
$translate = function ($n) {
if ($n % 15 == 0) return 'fizzbuzz';
if ($n % 5 == 0) return 'buzz';
if ($n % 3 == 0) return 'fizz';
return $n;
};
View hello.php
<?php
$hour = date("G");
if ($hour < 12) {
echo "good morning world";
} elseif ($hour < 18) {
echo "good afternoon world";
} else {
echo "good evening world";
}
View tracking_pixel.php
<?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);
*/
View hanoi.php
<!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;
View new_slugify.php
<?php
function slugify($string) {
$string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string);
$string = preg_replace('/[-\s]+/', '-', $string);
return trim($string, '-');
}
echo slugify("Я люблю PHP!");
View slugify.php
<?php
// Credit: http://sourcecookbook.com/en/recipes/8/function-to-slugify-strings-in-php
function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
// trim
$text = trim($text, '-');
@jrivero
jrivero / SimpleHTTPServerWithUpload.py
Created Sep 7, 2015
This module builds on BaseHTTPServer by implementing the standard GET and HEAD requests in a fairly straightforward manner.
View SimpleHTTPServerWithUpload.py
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
View osx-for-hackers.sh
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'