Skip to content

Instantly share code, notes, and snippets.

View tbaschak's full-sized avatar

Theo Baschak tbaschak

View GitHub Profile
<?php
// needs password_hash from php 5.5 OR compat library from
// https://github.com/ircmaxell/password_compat
require("./password_compat/lib/password.php");
$i = 10;
while($i<20) {
$time_start = microtime(true);
$password = "password001234567890";
$hash = password_hash($password, PASSWORD_BCRYPT, array("cost" => $i));
$time_end = microtime(true);
@tbaschak
tbaschak / gen-iface-names.sh
Last active December 19, 2015 08:19 — forked from oogali/gen-iface-names.sh
Updated gen-iface-names.sh to work on *BSD and OS X
#!/bin/sh
# router name generator
# [ omachonu ogali / oogali at blip dot tv / @oogali ]
#
# README:
# 1. point at your router with a community
# 2. finesse names as needed into your DNS zones
# 3. have a cold beverage of your choosing.
#
@tbaschak
tbaschak / gist:7866668
Created December 9, 2013 02:41
calculate network address given IP & Netmask
<?php
// simple example
$bcast = ip2long("192.168.178.41");
$smask = ip2long("255.255.255.0");
$nmask = $bcast & $smask;
echo long2ip($nmask); // Will give 192.168.178.0
echo "\n";
?>
@tbaschak
tbaschak / inet6
Created December 9, 2013 02:43
php gethostbyname6
<?php
function gethostbyname6($host, $try_a = false) {
// get AAAA record for $host
// if $try_a is true, if AAAA fails, it tries for A
// the first match found is returned
// otherwise returns false
$dns = gethostbynamel6($host, $try_a);
if ($dns == false) { return false; }
  • IPv6
  • HTML5
from ConfigParser import SafeConfigParser
parser = SafeConfigParser()
parser.read('etc/unifi.cfg')
username = parser.get('unifi', 'username')
password = parser.get('unifi', 'password')
#!/bin/bash
function usage ()
{
echo "Usage:"
echo " $0 <IP>"
echo "OR"
echo " $0 <IP> | tee mylog.txt"
}
#!/bin/bash
function usage ()
{
echo "Usage:"
echo " $0 <IP6>"
echo "OR"
echo " $0 <IP6> | tee mylog.txt"
}
#!/bin/bash
function usage ()
{
echo "Usage:"
echo " $0 <IP6 | hostname>"
echo "OR"
echo " $0 <IP6 | hostname> | tee mylog.txt"
}
@tbaschak
tbaschak / create_mysql_user.sh
Created June 21, 2014 21:50
create a mysql user and database, and give all privileges
mysqladmin -uroot -p create DBNAME
mysql -uroot -p -e "GRANT ALL PRIVILEGES ON DBNAME.* To 'USER'@'localhost' IDENTIFIED BY 'PASSWORD';"