Monday, May 14, 2012
Positioning Properties
Thursday, May 10, 2012
Buttoning
Triangleling
Wednesday, May 9, 2012
Query Suggestion
<input type="text" id="text" onkeyup="show(event)"/>
<p id="view"></p>
<script>
var data = ["apple","banana","mango",
function show(event){
var text = document.getElementById('text').value;
var view = document.getElementById('view');
var len = text.length;
var plot = "";
if (len==0){
view.innerHTML = "";
return;
}
// we iterate all the available data to match on
for(i=0;i<data.length;i++){
// we just take the query that match
// for each length of the string.
// we compare if the query from the user
if(text==data[i].substr(0,len)){
plot = plot+"<br/>"+data[i];
}
}
view.innerHTML = plot;
}
</script>
Query Suggestion
Monday, May 30, 2011
Function Pointer As Struct Member
struct aritmathic{
int a;
int b;
int (*add)(int, int);
int (*subtract)(int, int);
int (*multiply)(int, int);
};
int Add(int a, int b){
return (a+b);
}
int Subtract(int a, int b){
return (a-b);
}
int Multiply(int a, int b){
return (a*b);
}
int main(){
struct aritmathic ar;
ar.a = 4;
ar.b = 5;
ar.add = Add;
ar.subtract = Subtract;
ar.multiply = Multiply;
int a = ar.add(ar.a, ar.b);
int b = ar.subtract(ar.a, ar.b);
int c = ar.multiply(ar.a, ar.b);
printf("%d\n%d\n%d", a, b, c);
return 0;
}
struct aritmathic{
int a;
int b;
int (*add) (struct aritmathic*);
int (*subtract) (struct aritmathic*);
int (*multiply) (struct aritmathic*);
};
int Add(struct aritmathic* ar){
return (ar->a + ar->b);
}
int Subtract(struct aritmathic* ar){
return (ar->a - ar->b);
}
int Multiply(struct aritmathic* ar){
return (ar->a * ar->b);
}
int main(){
struct aritmathic ar;
ar.a = 4;
ar.b = 5;
ar.add = Add;
ar.subtract = Subtract;
ar.multiply = Multiply;
int a = ar.add(&ar);
int b = ar.subtract(&ar);
int c = ar.multiply(&ar);
printf("%d\n%d\n%d", a, b, c);
return 0;
}
Function Pointer As Struct Member
struct data{
void(*hello)();
};
void hello(){
puts("Hello comes from C");
}
int main(){
struct data d;
d.hello = hello;
d.hello();
struct data dd;
struct data* ptr = ⅆ
ptr->hello = *hello;
ptr->hello();
return 0;
}
Friday, May 20, 2011
Better Looking Search Box
<form>
<input type="text" id="text"/>
<input type="submit" id="submit" value="Search"/>
</form>
</div>
<style>
border: 1px solid #ccc;
max-width: -moz-fit-content;
padding: 1px;
-moz-border-radius: 5px;
}
#text{
border: 0px solid #ccc;
-moz-border-radius: 5px 0px 0px 5px;
padding-left: 10px;
}
#submit{
background: #88f;
color: #fff;
font: 14px arial;
font-weight: bold;
border: 0px solid #000;
padding: 1px 5px;
-moz-border-radius: 0px 5px 5px 0px;
cursor: pointer;
}
#submit:hover{
background: #55f;
}
form{
margin: 0px;
padding: 0px;
}
The result:
Better Looking Search Box
Tuesday, May 17, 2011
SSL - Generate RSA Key
To generate public RSA key, use
OpenSSL> rsa -in mykey.pem -pubout
Read more on here
SSL - Generate RSA Key
OpenSSL Introduction
OpenSSL> enc -base64 -in myfile.txt -out myfile.txt.enc
or just a test using pipe
D:\git\bin>echo "Hello World" | openssl enc -base64
To decrypt, use
OpenSSL> enc -base64 -d -in myfile.txt.enc
To decrypt from pipe, use
D:\git\bin>echo "encrypted" | openssl enc -base64 -d
Learn more on here
OpenSSL Introduction
Sunday, May 15, 2011
YUI - Starting
Introduction
Here's a sample for how to start using YUI framework.
First, linking for the API
Code:
Code:
Code:
YUI.use('autocomplete', function(Y){
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, {
source: ['apple','amazon','air','america']
});
});
</script>
YUI - Starting
Saturday, May 14, 2011
CSS - Advanced
Introduction
Here's some code that show some advanced of CSS that is practical for use.
Rounded Box
It's easy to make a rounded box. Even you don't need use image for it.
Code
<style>
div{
border: 1px solid #af0;
padding: 5px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
</style>
CSS - Advanced
Tuesday, May 10, 2011
GAE - Template
Introduction
Template makes your life easier. it separating between code logic of your program to what should display on the browser. Here's I just show up what the crucial template case that not handled by Django documentation.
Displaying List of Articles
It's really some often occurance for us to display item list. It's like blog post that consits of title, date, and content. Or it like personal data that consists of name, email, address and more. Here's for example we has some blog post:
Data Content
| Title | Content |
|---|---|
| GAE Template | GAE Template is use Django template system. So when you are accustomed for using Django, it's good for you. |
| GAE Runtime | There are two available runtime for you. The first is Java and the second is Python. Whatever you choose, it should based on your preference for the language and your current skills. |
| GAE Datastore | In GAE, your data is saved in database, but you never handle it directly, because Google Datastore that handles it, and in all your time, you handle the datastore. The operation for data in datastore is like in native sql, but it's more abstract than it that is called GQL - Google Query Language. |
Program code: main.py
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.ext.webapp import template
class Blog(db.Model): title = db.StringProperty()
content = db.TextProperty()
class MainPage(webapp.RequestHandler):
blog = Blog()
query = db.GqlQuery("SELECT * FROM Blog")
data = []
for row in query:
mapp = {}
mapp['title'] = row.title
mapp['content'] = row.content
data.append(mapp)
GAE - Template
GAE - Introduction
Introduction
Google App Engine is the platform for building web application. There's a built-in framework and already hosting servince provided by Google. The application environtment is two: Java and Python. Whenever you choose one, it's up to you.
How To
To starting development, you can download it first from code.google.com. Here we use Python version environment. After finishing for downloading, please install it.
The first is create directory, named "Hello" in whatever you want to place it - for example in "D:\\Hello". The second, is create two files: app.yaml and main.py, and then write this code.
GAE - Introduction
Monday, May 9, 2011
JS -- AJAX
Introduction
AJAX is a mechenisme for communicating with server through background. It enables your client web site to load and sending data from and to server respectively without reloading the page.Sending Data To Server
Here's a simple example on how to use ajax.
Program Code: Client Side
<input type="button" value="Send" onclick="sending()"/>
<script>
function sending(){
var name = document.getElementById('name').value;
var ajax = new XMLHttpRequest();
ajax.open("GET", "hello.php?name="+name, false);
ajax.send();
}
</script>
And on the server side, you need to write the code to handle it. Here's a code on PHP.
Program Code: hello.php
JS -- AJAX
JS - JSON
Sunday, May 8, 2011
Python - File Reading And Writing
Introduction
File operation is necessary in every programming.In Python, file handling is comparatively easier than the other language.
Reading A File
For reading a file, you can use open built-in method with or without "r" mode as a second arguments.
Program Code
print finput
data = finput.read()
print data
Output
Welcome to Python world. Python is a nice language. It's fun to learn. And it's easy to use.
Python - File Reading And Writing
Python - Dictionary
Introduction
Python dictionary data structure is like a map in another language like java or associative array in php. It's use a name value pairs.
How To
You use bracket for declaring and defining it. Here's a code.
Program Code
print data
Output
Python - Dictionary
Python - Tuple
Introduction
Tuple is like a list. That is it's a container of data. It also can contain different type of data. But the difference of tupple and list is that the tuple data cannot be modified after it's defined. You cannot modify or delete an element in the tuple. There's some data structure that suitable used tuple than list. For example the day names in a week, the month names in a year, the songs of lady gaga monster ball album. The different things a gain for tuple than list is that tuple definition is using ( and ). Other is same as list.
Program Code
print days
print "The length of the days: ", len(days)
Python - Tuple
Python - List
Introduction
List is a data structure in Python. It's like an array in other programming languages. But list in Python is more powerful, because it can contain different data type.
Program Code
print name
Output
Python - List