Skip to content

Instantly share code, notes, and snippets.

@bitbybit
bitbybit / barcode-country.js
Created June 17, 2013 14:34
Barcode country detection. Returns country code in ISO 3166-2 from barcode.
// https://github.com/Dremora/barcode-lookup/blob/gh-pages/barcode.js
var barcode_country = function (code) {
code = parseInt(code.substr(0, 3), 10);
if ((0 <= code && code <= 19)) {
return 'US,CA';
} /*else if ((20 <= code && code <= 29)) {
return 'Restricted distribution (MO defined)';
}*/ else if ((30 <= code && code <= 39)) {
return 'US';
@bitbybit
bitbybit / opendns.sh
Last active May 1, 2019 01:29
OpenDNS updater
#!/bin/sh
# Author: bluej774
# http://ubuntuforums.org/showthread.php?t=693788
UNAME=USERNAME # username
PWORD=PASSWORD # password (plaintext, sorry!)
TEMP=`mktemp` # temporary file
ERROR=5 # times to retry
@bitbybit
bitbybit / backup-rotation-from-remote.php
Created June 10, 2013 12:24
Backup rotation from remote server
<?
$dir = '/path/to/local/dir';
if(is_dir($dir)) {
date_default_timezone_set('Europe/Moscow');
$backup = fopen($dir.date("Y_m_d_H-i-s").'.tgz','w');
$archive = curl_init();
@bitbybit
bitbybit / dnsbl-check.php
Created June 10, 2013 12:22
DNSBL IP checking
<?
$email = 'your@email';
$dnsbl_check = array(
"bl.spamcop.net",
"list.dsbl.org",
"sbl.spamhaus.org",
"xbl.spamhaus.org",
"cbl.abuseat.org",
"zen.spamhaus.org",
@bitbybit
bitbybit / openvz-memory-monitoring.sh
Last active December 18, 2015 07:39
Memory usage monitoring for OpenVZ
#!/bin/bash
resources="/proc/bc/$VEID/resources"
LOG="/var/log/vps-highload.log"
uid=(`cat $resources | awk '{print $1}' | grep -o '[0-9]*'`)
used=(`cat $resources | grep privvm | awk '{print $2}'`)
all=(`cat $resources | grep vmguar | awk '{print $4}'`)
for ((i = 0; i < ${#uid[@]}; i++));do
@bitbybit
bitbybit / namedays.php
Last active December 18, 2015 07:39
Russian orthodox namedays array by month and days
<?
$names = array(
array(),
array(
array(),
array("Григорий","Илья"),
array("Иван","Даниил"),
array("Петр"),
array("Анастасия"),
array("Василий","Павел","Ева","Сусанна"),