Friday, December 28, 2012
Wednesday, December 26, 2012
Variable type hinting in Netbeans (PHP)
/* @var $varName Type_Name */
Monday, December 24, 2012
Mysql Setting Indian TimeZone (Asia/Calcutta)
Friday, December 21, 2012
installing apc
Friday, December 14, 2012
php catching fatal errors
Source
register_shutdown_function('handleShutdown');
function handleShutdown() {
$error = error_get_last();
if($error !== NULL){
$info = "[SHUTDOWN] file:".$error['file']." | ln:".$error['line']." | msg:".$error['message'] .PHP_EOL;
yourPrintOrMailFunction($info);
}
else{
yourPrintOrMailFunction("SHUTDOWN");
}
}
Wednesday, December 12, 2012
Monday, December 10, 2012
FD RD Computation for LIC t.no.75 policy
Friday, November 23, 2012
dropbox centos sync
Dropbox CLI for CentOS 5 the easy way
Dropbox hardly needs any introduction; put files in your Dropbox and they show up everywhere else you have Dropbox installed and dropbox.com. A feature about Dropbox that is probably not as widely known is that free accounts come with 30 days of undo history and Pro accounts can get "Pack Rat" that keeps unlimited history of changes. The history of files, including reverting deleted files, was particularly interesting to me, since I could hook in my latest daily MySQL dumps from AutoMySQLBackup to Dropbox and have 30 days of backups for free available from anywhere dropbox.com is accessible.
The problem is that we use CentOS for our servers and the Dropbox Linux builds are geared for distributions like Ubuntu and Debian that have updated versions of required software like Python, libc, and others, that I did not want to upgrade by hand on my systems and risk the integrity of the system packages. But, I got it to work anyway, read on for how I got Dropbox CLI installed on CentOS without replacing any system files.
- Download http://www.getdropbox.com/download?plat=lnx.x86 orhttp://www.getdropbox.com/download?plat=lnx.x86_64 (Ref)
- Extract tar.gz file downloaded and leave in ~ of desired user
- Run
~/.dropbox-dist/dropboxd
to get Dropbox to provide a URL to go to in your browser to link this computer to your Dropbox account
$ ./dropboxd
This client is not linked to any account...
Please visit https: //www.dropbox.com/cli_link?host_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxx to link this machine. - After visiting the URL in a browser to which you've logged into dropbox.com, you'll see the following output:
/usr/bin/nautilus
cannot open display:
Run 'nautilus --help' to see a full list of available command line options. - If you cannot quit the app, open another a shell, get the PID by running
$ ps -ef|grep dropbox
, and kill PID. The output on your other shell should say:
Terminated - Download the official Dropbox CLI: http://www.dropbox.com/download?dl=packages/dropbox.py (Ref)
- dropbox.py won't work without Python 2.6, but let's not risk messing up our official RHEL packages. Download ActivePython 2.6 (AS Package) fromhttps://www.activestate.com/activepython/downloads (Ref)
- As mentioned in the AP documentation (Ref), run the installer with ./install.sh and install where desired. It defaults to /opt/ActivePython-2.6, which is fine because it does not conflcit with the system default python 2.4 install. For my purposes, I had created a user called dropbox that did not have root privileges, so I installed to /home/dropbox/ActivePython-2.6.
- Edit dropbox.py and change
#!/usr/bin/python
to the path you just installed AP to. For my installation, it's set to#!/home/dropbox/bin/ActivePython-2.6/bin/python
- Run dropbox.py without commands to see your available options.
Monday, November 19, 2012
Generating html drop down options with vim
Friday, November 16, 2012
installing pecl_http on centos
installing apache and php on centos
Friday, November 2, 2012
Thursday, October 11, 2012
Friday, September 28, 2012
JQuery in place editing with autocomplete (with dummy data)
Monday, September 10, 2012
Websockets deployment on a dedicated server
Wednesday, August 29, 2012
Articles with tags queries : HQL/JPQL/MySql
<hibernate-mapping>
<class name=ca.sergiy.model.Tag" table="tag">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<property name="name" column="name"/>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="ca.sergiy.model.Article" table="article">
<cache usage="read-write" />
<id name="id" column="id" type="long">
<generator class="native" />
</id>
<property name="title" column="title" />
<set name="tags" table="article_tag" lazy="false">
<key column="articleid" />
<many-to-many class="ca.sergiy.model.Tag" column="tagid" />
</set>
</class>
</hibernate-mapping>
#1. Find all articles that are tagged with any of tag1, tag2, ..., tagn
SELECT DISTINCT a.*
FROM `article` a
INNER JOIN article_tag at
ON at.articleid = a.id
INNER JOIN tag t
ON t.id = at.tagid
WHERE t.name IN ("Java", "Hibernate")
String[] tags = {"Java", "Hibernate"};
String hql = "select distinct a from Article a " +
"join a.tags t " +
"where t.name in (:tags)";
Query query = session.createQuery(hql);
query.setParameterList("tags", tags);
List<Article> articles = query.list();
#2. Find all articles that have no tags assigned
SELECT a.*
FROM `article` a
LEFT JOIN article_tag at
ON at.articleid = a.id
GROUP BY a.id
HAVING Count(at.tagid) = 0
String hql = "select a from Article a " +
"left join a.tags t " +
"group by a " +
"having count(t)=0";
Query query = session.createQuery(hql);
List<Article> articles = query.list();
LEFT JOIN
.#3. Find all articles that are tagged with at least tag1, tag2, ..., tagn
SELECT a.*
FROM article a
INNER JOIN (SELECT at.articleid
FROM article_tag at
INNER JOIN article a
ON a.id = at.articleid
INNER JOIN tag t
ON t.id = at.tagid
WHERE t.name IN ("Java","Hibernate")
GROUP BY at.articleid
HAVING Count(at.articleid) = 2) aa
ON a.id = aa.articleid
String[] tags = {"Java", "Hibernate"};
String hql = "select a from Article a " +
"join a.tags t " +
"where t.name in (:tags) " +
"group by a " +
"having count(t)=:tag_count";
Query query = session.createQuery(hql);
query.setParameterList("tags", tags);
query.setInteger("tag_count", tags.length);
List<Article> articles = query.list();
#4. Find all articles that are tagged with exactly tag1, tag2, ..., tagn
SELECT a.*
FROM article a
INNER JOIN (SELECT at.articleid
FROM article_tag at
WHERE at.articleid IN (SELECT at2.articleid
FROM article_tag at2
INNER JOIN article a2
ON a2.id = at2.articleid
GROUP BY at2.articleid
HAVING Count(at2.articleid) = 2)
AND at.tagid IN (SELECT id
FROM tag t
WHERE t.name IN ("Java","Hibernate"))
GROUP BY at.articleid
HAVING Count(at.articleid) = 2) aa
ON a.id = aa.articleid
String[] tags = {"Java", "Hibernate"};
String hql = "select a from Article a " +
"join a.tags t " +
"where t.name in (:tags) " +
"and a.id in (" +
"select a2.id " +
"from Article a2 " +
"join a2.tags t2 " +
"group by a2 " +
"having count(t2)=:tag_count) " +
"group by a " +
"having count(t)=:tag_count";
Query query = session.createQuery(hql);
query.setParameterList("tags", tags);
query.setInteger("tag_count", tags.length);
List<Article> articles = query.list();
Friday, August 24, 2012
Saturday, July 21, 2012
Smartvideo extension for managing youtube videos in your browser
For e.g.,
1. to save bandwidth set default video quality to 240 for all videos.
2. have different settings for embedded and youtube videos.
Monday, July 16, 2012
Sunday, July 15, 2012
Search public google docs
* [site:docs.google.com/presentation/d] - find presentations
* [site:docs.google.com/drawings/d] - find drawings
* [site:docs.google.com/file/d] - find files: images, videos, PDF files, Microsoft Office documents and more (you should click "repeat the search with the omitted results included" since there are many files with similar titles)
* [site:docs.google.com/folder/d] - find folders (collections of files and other folders)
* [site:docs.google.com/open] - find other documents, folders and files (the links redirect to other URLs)
Saturday, July 14, 2012
New features in PHP I didn't know about
Monday, July 9, 2012
accessing properties file in jsp/jstl using spring
Thursday, July 5, 2012
hibernate many to many query
1. JPA Sucks.
Tuesday, June 19, 2012
apache access log images average object size, total requests, total B/W used
Wednesday, May 30, 2012
Monday, May 21, 2012
clear recent project list in netbeans
Then go to : c/Users/admin/.netbeans/7.1.1/config/Preferences/org/netbeans/modules
edit file : projectui.properties
remove all lines starting with 'recent'
Thursday, May 10, 2012
NetBeans jvi :w problem (colon w)
Wednesday, May 9, 2012
Tuesday, May 8, 2012
Vim : replacing text with matched text
Thursday, May 3, 2012
C program for printing all permutations
void swap(int* a,int i,int j) {
int tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
void print_array(int* a,int n) {
int i;
for(i = 0; i<= n; ++i) {
printf("%d ",a[i]);
}
printf("\n");
}
void permute(int* a, int i, int n) {
int j;
if(i == n) print_array(a,n);
else {
for(j = i;j <= n; j++) {
swap(a,i,j);
permute(a,i+1,n);
swap(a,i,j);
}
}
}
void main() {
int a[4] = {1,2,3,4};
permute(a,0,3);
}
Wednesday, May 2, 2012
rough sketch for generating all permutations
permute(arrayCollection) {
if has only 2 :
AB
BA
else
for ( ith elem in collection) {
otherThanIth = elems other than ith;
otherThanIthPermed = permute(otherThanIth);
prepend(ith, otherThanIthPermed);
}
}
Printing a BST in level order
queue.addAtEnd(root);
queue.addAtEnd(stopper);
while(queue.hasElems() && currNode = queue.popFront()) {\
if(currNode != stopper) {
print currNode;
queue.addAtEnd(left) if left not null;
queue.addAtEnd(right) if right not null;
} else {
print new line;
if queue.hasElems()
addAtEnd(stopper);
}
}
other solutions from leetcode :
With two queues :
void printLevelOrder(BinaryTree *root) {
if (!root) return;
queue<BinaryTree*> currentLevel, nextLevel;
currentLevel.push(root);
while (!currentLevel.empty()) {
BinaryTree *currNode = currentLevel.front();
currentLevel.pop();
if (currNode) {
cout << currNode->data << " ";
nextLevel.push(currNode->left);
nextLevel.push(currNode->right);
}
if (currentLevel.empty()) {
cout << endl;
swap(currentLevel, nextLevel);
}
}
}
With one queue but counters :
void printLevelOrder(BinaryTree *root) {
if (!root) return;
queue<BinaryTree*> nodesQueue;
int nodesInCurrentLevel = 1;
int nodesInNextLevel = 0;
nodesQueue.push(root);
while (!nodesQueue.empty()) {
BinaryTree *currNode = nodesQueue.front();
nodesQueue.pop();
nodesInCurrentLevel--;
if (currNode) {
cout << currNode->data << " ";
nodesQueue.push(currNode->left);
nodesQueue.push(currNode->right);
nodesInNextLevel += 2;
}
if (nodesInCurrentLevel == 0) {
cout << endl;
nodesInCurrentLevel = nodesInNextLevel;
nodesInNextLevel = 0;
}
}
}
Monday, April 23, 2012
Sunday, April 22, 2012
Friday, April 20, 2012
vtiger Fatal error: Smarty error: unable to write to $compile_dir
Thursday, April 19, 2012
Wednesday, April 18, 2012
Monday, April 16, 2012
xampp older version
Monday, March 19, 2012
Thursday, March 15, 2012
awk print sum of a column and number of rows
Monday, March 5, 2012
Tuesday, February 28, 2012
Clearing AutoFill Form data from Google Chrome
Click the wrench icon on the browser toolbar.
Select Tools.
Select Clear browsing data.
In the dialog that appears, select the "Clear saved Autofill form
data" checkbox.
Use the menu on the top to select the amount of data you want to
delete. Select the beginning of time to clear everything.
Click Clear browsing data.
Wednesday, February 1, 2012
Sunday, January 22, 2012
Jailbreaking and deploying on iphone3gs using ios5
Friday, January 20, 2012
Installing node.js on hostmonster/bluehost
Blog Archive
-
▼
2012
(59)
-
►
July
(12)
- Smartvideo extension for managing youtube videos i...
- Youtube allows face blurring in videos
- Apache Shiro Introduction
- Tracking monetization of Youtube Videos in Google ...
- firebug breakpoints advanced demo
- Search public google docs
- A wonderful jquery plugin - parallax
- New features in PHP I didn't know about
- PHP Dev/Debug Tools
- accessing properties file in jsp/jstl using spring
- vim for eclipse
- hibernate many to many query
-
►
April
(11)
- Creating a PrestaShop Module
- vtiger sales process
- vtiger web services tutorial
- making a field not optional in vtiger
- vtiger Fatal error: Smarty error: unable to write ...
- vtiger API
- vtiger developer guide
- vtiger : where are leads/potentials stored?
- netbeans maching brace
- vtiger lead contacts accounts etc explanation
- xampp older version
-
►
July
(12)