-
Archives
- February 2012
- January 2012
- December 2011
- September 2011
- August 2011
- June 2011
- January 2011
- December 2010
- November 2010
- October 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- January 2009
- November 2008
- September 2008
- August 2008
- July 2008
- March 2008
- February 2008
- January 2008
-
Meta
Author Archives: Raymond
sed edit in place deleting matching lines
This command deletes the line that contains “remove-matching-line” in files that matches *.txt wildcard. $ ls -1 *.txt | xargs -I ‘{}’ sed -i ‘/^.*remove-matching-line.*$/d’ ‘{}’ A hacker inserted eval(base64_decode(“obfuscated_code”)) on a client’s PHP files. I used this command to … Continue reading
Remove duplicates from MySQL Table
ALTER IGNORE TABLE categories ADD PRIMARY KEY(categories_id);
Create Linux RAID Level 1 from 4 TB Harddisk
Partition the disk into two equal parts. # parted /dev/sda GNU Parted 2.3 Using /dev/sda Welcome to GNU Parted! Type ‘help’ to view a list of commands. (parted) mklabel gpt (parted) print Model: Areca ARC-1212-VOL#000 (scsi) Disk /dev/sda: 4,00TB Sector … Continue reading
Posted in Uncategorized
Leave a comment
Vim set file encoding
:set bomb :set fileencoding=utf-8
MySQL regex update
Simple solution: UPDATE table SET words = REPLACE(words, ‘brown’, ‘green’) WHERE words REGEXP ‘brown ‘ OR words REGEXP ‘ brown’ Better solution from http://techras.wordpress.com/2011/06/02/regex-replace-for-mysql/: SET sql_mode=’NO_BACKSLASH_ESCAPES’; DELIMITER $$ CREATE FUNCTION `regex_replace`(pattern VARCHAR(1000),replacement VARCHAR(1000),original VARCHAR(1000)) RETURNS VARCHAR(1000) DETERMINISTIC BEGIN DECLARE temp … Continue reading
Posted in MySQL
Leave a comment
Number format by country
Source: International Number Formats Format Country 1,234.56 – Invariant Language (Invariant Country) ar-SA – Arabic (Saudi Arabia) zh-TW – Chinese (Taiwan) en-US – English (United States) he-IL – Hebrew (Israel) ja-JP – Japanese (Japan) ko-KR – Korean (Korea) th-TH – … Continue reading
Bash: getting confirmation to continue or exit
#!/bin/bash while true do read -r -p ‘Are you sure? ‘ choice case “$choice” in y|Y) echo “Processing…” break ;; n|N) echo “Canceled.” exit ;; esac done echo “Complete.”
Currency Internationalization (i18n), Multiple Currencies and Foreign Exchange (FX)
Currency Internationalization (i18n), Multiple Currencies and Foreign Exchange (FX)
Multibyte PHP Functions
Source: Using Multi-Byte Character Sets in PHP (Unicode, UTF-8, etc) The following list details the PHP string functions which could cause problems when handling multi-byte strings. The multi-byte safe alternative is given when available: mail() Try mb_send_mail() instead. strlen() Try mb_strlen() instead. strpos() Try mb_strpos() instead. … Continue reading
Force secure browsing https
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} dir RewriteRule ^(.*)$ https://www.example.com/dir/$1 [R,L]