JQuery for Web Design using JQuery Web Broswer API
bind and unbind events with colored button.
function ClickMe() {
$("div").show().fadeOut("slow");
}
$("#bind").click(function () {
$("jejeje").live("click", ClickMe)
.text("Can Click!");
});
$("#unbind").click(function () {
$("jejeje").die("click", ClickMe)
.text("Does nothing...");
});
Tuesday, July 13, 2010
Using the Datastore for Google App Engine
import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
class Greeting(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
class MainPage(webapp.RequestHandler):
def get(self):
self.response.out.write('')
greetings = db.GqlQuery("SELECT * FROM JPDBinfo ORDER BY date DESC LIMIT 10")
for greeting in greetings:
if greeting.author:
self.response.out.write('%s wrote:' % greeting.author.nickname())
else:
self.response.out.write('An anonymous person wrote:')
self.response.out.write('
cgi.escape(greeting.content))
self.response.out.write("""
//* YOUR OWN HTML CODE
class Guestbook(webapp.RequestHandler):
def post(self):
greets = Pagabati()
if users.get_current_user():
greets.author = users.get_current_user()
greets.content = self.request.get('content')
greets.put()
self.redirect('/')
application = webapp.WSGIApplication(
[('/', UnangPahina),
('/sign', Lakdaan)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
Note:
After compile the code and save do the following:
Go -> Application - Terminal
Type the command
/* compile the python file that you created and compile by Google App Engine
chmod u+x progname.py
run the script
./programko.py
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
class Greeting(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
class MainPage(webapp.RequestHandler):
def get(self):
self.response.out.write('')
greetings = db.GqlQuery("SELECT * FROM JPDBinfo ORDER BY date DESC LIMIT 10")
for greeting in greetings:
if greeting.author:
self.response.out.write('%s wrote:' % greeting.author.nickname())
else:
self.response.out.write('An anonymous person wrote:')
self.response.out.write('
%s' %
cgi.escape(greeting.content))
self.response.out.write("""
//* YOUR OWN HTML CODE
class Guestbook(webapp.RequestHandler):
def post(self):
greets = Pagabati()
if users.get_current_user():
greets.author = users.get_current_user()
greets.content = self.request.get('content')
greets.put()
self.redirect('/')
application = webapp.WSGIApplication(
[('/', UnangPahina),
('/sign', Lakdaan)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
Note:
After compile the code and save do the following:
Go -> Application - Terminal
Type the command
/* compile the python file that you created and compile by Google App Engine
chmod u+x progname.py
run the script
./programko.py
Linux Iptables block all network traffic in your ISP
Linux Iptables block all network traffic in your ISP
# iptable -F
# iptables -P INPUT DROP
# iptables -P OUTPUT DROP
# iptables -P FORWARD DROP
Note:
You can create bash script and execute this command.
Types of Scipt in Linux
1. bash Script
2. bourne script
3. Shell script
4. C shell
# iptable -F
# iptables -P INPUT DROP
# iptables -P OUTPUT DROP
# iptables -P FORWARD DROP
Note:
You can create bash script and execute this command.
Types of Scipt in Linux
1. bash Script
2. bourne script
3. Shell script
4. C shell
Struts 2 Java Framework Using Selection in Form for Web Page
Struts 2 Java Framework Using Selection in Form for Web Page
package ActionForm;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
public class MyTagActionForm extends org.apache.struts.action.ActionForm{
private String MySelection;
public String getMySelection() {
return singleSelect;
}
public void setMySelection(String string) {
MySelection = string;
}
public MyTagActionForm() {
super();
}
}
package ActionForm;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
public class MyTagActionForm extends org.apache.struts.action.ActionForm{
private String MySelection;
public String getMySelection() {
return singleSelect;
}
public void setMySelection(String string) {
MySelection = string;
}
public MyTagActionForm() {
super();
}
}
Monday, July 12, 2010
Programming with Asterisk Elastic in Linux ^_^
#!/usr/bin/php -q
set_time_limit(30);
require('include/phpagi.php');
error_reporting(E_ALL);
$agi = new AGI();
$agi->answer();
$agi->stream_file("congrats you are connected to the VOIP line","#");
do
{
$agi->stream_file("enter-digits-call-number","#");
$result = $agi->get_data('beep', 3000, 20);
$keys = $result['result'];
$agi->stream_file("you entered nubmer:","#");
$agi->say_digits($keys);
} while($keys != '111');
$agi->hangup();
?>
set_time_limit(30);
require('include/phpagi.php');
error_reporting(E_ALL);
$agi = new AGI();
$agi->answer();
$agi->stream_file("congrats you are connected to the VOIP line","#");
do
{
$agi->stream_file("enter-digits-call-number","#");
$result = $agi->get_data('beep', 3000, 20);
$keys = $result['result'];
$agi->stream_file("you entered nubmer:","#");
$agi->say_digits($keys);
} while($keys != '111');
$agi->hangup();
?>
Tuesday, July 6, 2010
Build Android application in Windows and Linux ^_^
Step 1: Generate Resource java code and packaged Resources
aapt package -f -M ${manifest.file} -F ${packaged.resource.file} -I ${path.to.android-jar.library} -S ${android-resource-directory} [-m -J ${folder.to.output.the.R.java}]
Step 2: Compile java source codes + R.java
use javac
Step 3: Convert classes to clear bytecodes
use dx.bat
dx.bat –dex –output=${output.dex.file} ${compiled.classes.directory} ${jar files..}
Step 4: Create unsigned APK
use apkbuilder
apkbuilder ${output.apk.file} -u -z ${packagedresource.file} -f ${dex.file}
or
apkbuilder ${output.apk.file} -u -z ${packagedresource.file} -f ${dex.file} -rf ${source.dir} -rj ${libraries.dir}
-rf = resources required for compiled source files?
-rj = resources required for jar files
Step 6: Generate a key
use keytool
Step 7: Sign APK
use jarsigner
jarsigner -keystore ${keystore} -storepass ${keystore.password} -keypass ${keypass} -signedjar ${signed.apkfile} ${unsigned.apkfile} ${keyalias}
Step 8: Publish
use adb
adb -d install -r ${signed.apk}
Inspecting your APK file:
aapt list -v latest.apk
aapt package -f -M ${manifest.file} -F ${packaged.resource.file} -I ${path.to.android-jar.library} -S ${android-resource-directory} [-m -J ${folder.to.output.the.R.java}]
Step 2: Compile java source codes + R.java
use javac
Step 3: Convert classes to clear bytecodes
use dx.bat
dx.bat –dex –output=${output.dex.file} ${compiled.classes.directory} ${jar files..}
Step 4: Create unsigned APK
use apkbuilder
apkbuilder ${output.apk.file} -u -z ${packagedresource.file} -f ${dex.file}
or
apkbuilder ${output.apk.file} -u -z ${packagedresource.file} -f ${dex.file} -rf ${source.dir} -rj ${libraries.dir}
-rf = resources required for compiled source files?
-rj = resources required for jar files
Step 6: Generate a key
use keytool
Step 7: Sign APK
use jarsigner
jarsigner -keystore ${keystore} -storepass ${keystore.password} -keypass ${keypass} -signedjar ${signed.apkfile} ${unsigned.apkfile} ${keyalias}
Step 8: Publish
use adb
adb -d install -r ${signed.apk}
Inspecting your APK file:
aapt list -v latest.apk
Friday, July 2, 2010
Locking a mailbox file in SHELL Programming on Linux
Locking a mailbox file in SHELL Programming on Linux
function my_lockfile ()
{
TEMPFILE="$1.$$"
LOCKFILE="$1.lock"
{ echo $$ > $TEMPFILE } >& /dev/null || {
echo "No permission to access the directory `dirname $TEMPFILE`"
return 1
}
ln $TEMPFILE $LOCKFILE >& /dev/null && {
rm -f $TEMPFILE
return 0
}
kill -0 `cat $LOCKFILE` >& /dev/null && {
rm -f $TEMPFILE
return 1
}
echo "Removing stale lock file"
rm -f $LOCKFILE
ln $TEMPFILE $LOCKFILE >& /dev/null && {
rm -f $TEMPFILE
return 0
}
rm -f $TEMPFILE
return 1
}
lock any kind of file
wait for a lock
until my_lockfile /etc/passwd ; do
sleep 1
done
# The body of the program might go here
# [...]
# Then to remove the lock,
rm -f /etc/passwd.lock
function my_lockfile ()
{
TEMPFILE="$1.$$"
LOCKFILE="$1.lock"
{ echo $$ > $TEMPFILE } >& /dev/null || {
echo "No permission to access the directory `dirname $TEMPFILE`"
return 1
}
ln $TEMPFILE $LOCKFILE >& /dev/null && {
rm -f $TEMPFILE
return 0
}
kill -0 `cat $LOCKFILE` >& /dev/null && {
rm -f $TEMPFILE
return 1
}
echo "Removing stale lock file"
rm -f $LOCKFILE
ln $TEMPFILE $LOCKFILE >& /dev/null && {
rm -f $TEMPFILE
return 0
}
rm -f $TEMPFILE
return 1
}
lock any kind of file
wait for a lock
until my_lockfile /etc/passwd ; do
sleep 1
done
# The body of the program might go here
# [...]
# Then to remove the lock,
rm -f /etc/passwd.lock
Subscribe to:
Comments (Atom)