Wednesday, August 10th, 2011
So after struggling for hours trying to get OpenVPN working and routing traffic correctly, I finally managed to get it working.
Step 1: Follow the guide at https://wiki.archlinux.org/index.php/OpenVPN
Step 2: Instead of running
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
run
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j SNAT --to (venet0 ip)
This should correctly route traffic using the venet0 interface.
Thursday, April 7th, 2011
Copy .apk files to any folder in sdcard, for example “new-apps”
Type these following commands in console:
-
adb shell
-
su
-
cd /sdcard/new-apps
-
for app in *.apk; do pm install -r $app; done
This PHP function generates a SQL query that updates a single column in multiple records with different values based on a list of conditions. Executing a single UPDATE query for a small number of records may be okay but for a large number of records, it may seriously affect the performance of your script/application. Here’s a way to quickly update a column in multiple records using a single query. This method is tested for updating 10,000+ records and it has worked without a hiccup so far.
Basic syntax for updating multiple records using a list of conditions:
-
UPDATE `table_name` SET `column_1` = CASE `condition`
-
WHEN 1 THEN ’1st value’
-
WHEN 2 THEN ’2nd value’
-
END
-
WHERE `condition` IN (1, 2);
PHP function to generate multi update query:
-
function make_multi_query( $table_name, $column_name, $condition_name, $condition_values ) {
-
$query = "UPDATE `" . $table_name . "` SET `" . $column_name . "` = CASE `" . $condition_name . "`";
-
foreach($condition_values as $id => $value) {
-
$query .= " WHEN ‘" . $id . "’ THEN ‘" . $value . "’";
-
}
-
$query .=
" END WHERE `" .
$condition_name .
"` IN (‘" .
implode( "’,'" ,
array_keys( $condition_values ) ) .
"’ );";
-
return $query;
-
}
PHP function example usage:
-
$table_name = "users";
-
$column_name = "active";
-
$condition_name = "username";
-
$condition_values =
array("user1" =>
"Y",
"user2" =>
"N");
-
echo make_multi_query
($table_name,
$column_name,
$condition_name,
$condition_values);
Above example will return the following query:
-
UPDATE `users`
-
SET `active` = CASE `username`
-
WHEN ‘user1′ THEN ‘Y’
-
WHEN ‘user2′ THEN ‘N’
-
END
-
WHERE `username` IN (‘user1′,‘user2′ );
Wednesday, May 19th, 2010
Manual Nvidia driver install instructions: http://ubuntuforums.org/showthread.php?t=1467074
Additional Note: Remove xserver-xorg-video-nouveau before starting install.
Very basic UDP chat.
For Point-to-Point, enter IP and Port
For Broadcasting mode set the last byte of IP address to 255. i.e. 192.168.0.255
Port number is HEX, remove the base 16 to make it decimal. Continue reading “UDP Chat in Python” »