Skip to content

Instantly share code, notes, and snippets.

View uda's full-sized avatar

Yehuda Deutsch uda

View GitHub Profile
@uda
uda / tzdata-up
Last active December 22, 2015 13:59
#!/bin/bash
DB=tzdata2013d
TZ=Asia/Jerusalem
ZI=/usr/share/zoneinfo/
wget -q http://www.iana.org/time-zones/repository/releases/${DB}.tar.gz
mkdir ${DB}
cd ${DB}
tar xzf ../${DB}.tar.gz
zic -d zoneinfo asia
@uda
uda / .bashrc
Last active February 24, 2017 14:07
This provides colorful bash interface for debian / ubuntu, tested on Ubuntu Server 12.04.x.Based on http://jbs.io/article/enabling-colorful-bash-debian-squeeze and the actual /etc/bash.bashrc on Ubuntu Server 12.04.2
# System-wide .bashrc file for interactive bash(1) shells.
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
#!/bin/bash
cd /opt
sudo git clone git@github.com:xypiie/gritz.git
sudo echo <<'EOF' > /usr/local/bin/gritz
#!/bin/bash
cd /opt/gritz
./gritz.pl &>/dev/null &
EOF
@uda
uda / port-nat.sh
Last active August 29, 2015 14:01
port-nat - allows you to trap all available ports to the web server.
#!/bin/bash
set -e
case "$1" in
start)
iptables -t nat -F
iptables -t nat -X
PORTS=(22 80 443)
@uda
uda / xively_mem_usage.sh
Last active August 29, 2015 14:03
Add mem_usage values to your xively.com stream from cron
#!/bin/bash
curl --request PUT \
"https://api.xively.com/v2/feeds/FEED_ID_GOES_HERE.json" \
--data '{"version":"1.0.0","datastreams":[{"id":"mem_usage","current_value":"'$((`grep MemTotal /proc/meminfo | awk '{print $2}'`-`grep MemFree /proc/meminfo | awk '{print $2}'`))'"}]}' \
--header "X-ApiKey: API_KEY_GOES_HERE"
@uda
uda / router.php
Last active August 29, 2015 14:06
PHP built-in server router
<?php
// router.php
if (PHP_SAPI == 'cli-server') {
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
if ($path[0] == '/') {
$path = substr($path, 1);
}
if (!is_file($path) && !is_dir($path)) {
// Fixes include issues when running from another directory than the router
chdir(__DIR__);
@uda
uda / wget-dir.sh
Created September 18, 2014 12:14
wget tools
#!/bin/bash
URL=$1
DOMAIN=$2
WAIT=$3
if [ "${URL}" == "" ] || [ "${DOMAIN}" == "" ]
then
echo "Usage: $0 URL DOMAIN"
exit 1
fi
@uda
uda / OpenLaw.Knesset.meta.js
Created November 2, 2014 12:09
Page through the knesset law proposals and accepted amendments with modern browsers
// ==UserScript==
// @name OpenLaw - Knesset version
// @namespace http://www.knesset.gov.il/
// @version 0.2
// @description Make the forms on knesset.gov.il work w/o M$ products
// @match http://www.knesset.gov.il/laws/heb/template.asp*
// @match http://knesset.gov.il/laws/heb/template.asp*
// @author uda
// @license MIT; http://opensource.org/licenses/MIT
// @copyright 2014, Yehuda Deutsch (http://0x59.net/)
@uda
uda / radix.js
Last active November 26, 2015 14:12
JavaScript base conversion that provides up to 64 base conversion. Based on http://www.javascripter.net/faq/convert3.htm, read more: http://en.wikipedia.org/wiki/Radix
/**
* Examples:
* var R = Radix(2);
* R.to(10); will result in "1010"
* R.from("1010"); sill result in 10
* var R = Radix(16);
* R.to(10); will result in "a"
* R.from("a"); sill result in 10
*
* Notice:
@uda
uda / transcode.sh
Last active August 29, 2015 14:16
Transcode, translate UTF-8 string with chars from windows encoding to another windows encoding
#!/usr/bin/env php
<?php
function transCode($sourceStringArray, $sourceMap, $targetMap) {
$newString = [];
foreach ($sourceStringArray as $index => $char) {
if ($char == ' ') {
$newString[] = $char;
continue;