Search This Blog
Popular Posts
-
Let say we have a String something like below. String sample="abc*123"; We want to split this String by '*'. We can...
-
sound -Convert matrix of signal data to sound Syntax sound(y,Fs) sound(y,Fs,bits) Description sound(y,Fs) sends audio signal y to the speak...
-
There are new phones will remove within next few weeks from sony. Sony xperia tipo, sony xperia tipo dual Sony xperia dual has dual sim...
-
When i try to configure mysql with CAS There were lots of problem occurred and i cannot find a good tutorials about this.I followed some tut...
-
PROBLEM 7 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st pr...
-
This delete the file f1 File f1 = new File(file); boolean success = f1.delete(); if (!success){ System.out.println("Deleti...
-
PROBLEM The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. ANSWER 142913828...
-
In this post i will show you how to configure tomcat 7.x for SSL protocol in windows First we want to generate certificate file using jav...
-
samsung smart app challenge 2012 This contest offers $4.08 million in cash prizes and mega marketing support for app promotion to the to...
-
If you did not format your flash drive, then check whether the files are in hidden mode. Then follow these steps: Click on the link below ...
Followers
Wednesday, February 13, 2013
Reorder/Reset auto increment primary key?
Following query can be used for reorder auto increment of a table.In this example reorder the id column of users table. If there are foreign key, make sure the action is cascade.
SET @count = 0;
UPDATE `users` SET `users`.`id` = @count:= @count + 1;
Tuesday, February 12, 2013
locks in python thread
When doing multi threading program in any language, it is a big problem when having shared variables or some shared objects. In this kind of situation, it is required to lock some variables until finish the some process of one thread. In order to do this we can use locks. In python there is a library for import in order to do this.
ex:
from threading import Lock
......
....
#initialize lock
lock=Lock()
.....
#when needed to add lock
lock.acquire()
#do the stuff
#remove lock
lock.release()
ex:
from threading import Lock
......
....
#initialize lock
lock=Lock()
.....
#when needed to add lock
lock.acquire()
#do the stuff
#remove lock
lock.release()
copy object to another object using python
it is really easy to copy object with all attributes to another object in python. All you need to import copy library.
ex:
import copy
class Test:
def __init__(self,name):
self.name=name
def main():
a=Test('madura')
b=copy.deepcopy(a)
This will copy Test class object a, to Test class object b with the attribute values
ex:
import copy
class Test:
def __init__(self,name):
self.name=name
def main():
a=Test('madura')
b=copy.deepcopy(a)
This will copy Test class object a, to Test class object b with the attribute values
Monday, February 11, 2013
Subscribe to:
Comments (Atom)