Skip to content

Instantly share code, notes, and snippets.

Avatar

Mauricio Wolff bitbonsai

View GitHub Profile
View proactive404.php
<?php
$http = str_replace('HTTP/1.1','http://',$_SERVER['SERVER_PROTOCOL']);
$datetime = date('Y-m-d H:i:s');
$to = $config['webmaster'];
$subject = '404 at '. $config['url'];
$headers = 'From: site@'.$config['url']."\r\n";
$message = <<< MAIL
@bitbonsai
bitbonsai / mountain-lion-brew-setup.markdown
Created Oct 3, 2012 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy
View mountain-lion-brew-setup.markdown

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

View readdir.js
var fs = require('fs');
fs.readdir( process.argv[2], function (err, files) {
if (!err)
console.log(files);
else
throw err;
});
console.log("Fired callback.");
@bitbonsai
bitbonsai / phantom_cookie.js
Created Jul 8, 2013
PhantomJs getting cookie value
View phantom_cookie.js
@bitbonsai
bitbonsai / br_whois.php
Created Dec 16, 2013
PHP Script with cURL to query the brazilian whois database
View br_whois.php
<?php
function get_br_whois( $url, $array_fields )
{
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "PHP Whois/Curl script", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
@bitbonsai
bitbonsai / passwordstrenght.js
Last active Aug 29, 2015
Password Strenght JS
View passwordstrenght.js
function scorePassword(pass) {
var score = 0;
if (!pass)
return score;
// award every unique letter until 5 repetitions
var letters = new Object();
for (var i=0; i<pass.length; i++) {
letters[pass[i]] = (letters[pass[i]] || 0) + 1;
score += 5.0 / letters[pass[i]];
View passwordstrenght.php
function scorePassword($password){
$score=0;
if(!$password)
return 0;
// award every unique letter until 5 repetitions
$letters=str_split($password);
$scores=array();
foreach($letters as $letter){
$scores[$letter]=(isset($scores[$letter]))?$scores[$letter]+1:1;
View sm-annotated.html
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
View 1.log
08:35:42.981081+01:00 lb-101 bird: **BGP1: Received: Other configuration change**
08:35:42.981362+01:00 lb-101 bird: BGP1: BGP session closed
08:35:42.981474+01:00 lb-101 bird: BGP1: State changed to stop
08:35:42.991510+01:00 lb-101 bird: BGP1: Down
08:35:42.991775+01:00 lb-101 bird: bfd1: Session to 10.248.16.254 removed
08:35:42.991883+01:00 lb-101 bird: BGP1: State changed to down
08:35:42.991985+01:00 lb-101 bird: BGP1: Starting
08:35:42.992090+01:00 lb-101 bird: BGP1: State changed to start
08:35:42.992191+01:00 lb-101 bird: bfd1: Session to 10.248.16.254 added
08:35:42.992299+01:00 lb-101 bird: BGP1: Started
View 2.sh
#! /bin/bash
#
# hapee_tracing.sh
KILL_FILE="/tmp/kill_hapee_tracing"
BASE_DIR="/var/log/pidstats/"
SOCKET_DIR="/run/lb_engine/"
PROCESS_NUMBER="$1"
PIDS=( $(cat /run/hapee-lb.pid) )
PID_INDEX=$(($PROCESS_NUMBER-1))
PID=${PIDS[${PID_INDEX}]}