Skip to content

Instantly share code, notes, and snippets.

View bitbonsai's full-sized avatar

Mauricio Wolff bitbonsai

View GitHub Profile
@bitbonsai
bitbonsai / passwordstrenght.js
Last active August 29, 2015 14:01
Password Strenght 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]];
@bitbonsai
bitbonsai / passwordstrenght.php
Created May 23, 2014 12:15
Password Strenght 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;
<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);
@bitbonsai
bitbonsai / proactive404.php
Created September 7, 2012 08:29
Proactive 404
<?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 October 3, 2012 01:22 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

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.

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 July 8, 2013 22:37
PhantomJs getting cookie value
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
#! /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}]}
12:38:00 PM active/s passive/s iseg/s oseg/s
12:41:18 PM 4403.00 836.00 48416.00 66313.00
12:41:19 PM 4115.00 819.00 48401.00 67910.00
12:41:20 PM 1417.00 786.00 43005.00 57608.00
12:41:21 PM 4225.00 824.00 35247.00 49883.00
12:41:22 PM 1198.00 814.00 21580.00 25604.00
12:41:23 PM 3446.00 768.00 24229.00 33893.00
12:41:24 PM 4269.00 773.00 30462.00 46604.00
12:41:25 PM 2259.00 821.00 24347.00 33772.00
12:41:26 PM 994.06 880.20 13207.92 15813.86