Skip to content

Instantly share code, notes, and snippets.

View skihero's full-sized avatar

Kish skihero

  • Amazon Mechanical Turk
  • Ooty
View GitHub Profile
/*
* Creating classes to learn a bit about java
*/
/**
* Super hero classes
*/
/**
* All our super heros belong to this class
@skihero
skihero / save_file.py
Created February 23, 2011 10:30
Saves a file read from a POST method
#!/usr/bin/python
# File: save_file.py
# Writes the file read from a POST method to
# a specified directory
#
# Use it with
# <form enctype="multipart/form-data" action="../cgi-bin/save_file.py" method="post">
#
# Kish
<html><body>
<form enctype="multipart/form-data" action="../cgi-bin/save_file.py" method="post">
<p>File: <input type="file" name="file"></p>
<p><input type="submit" value="Upload"></p>
</form>
</body></html>
@skihero
skihero / java classpath stupidity
Created February 25, 2011 13:08
This is amazing, just doesn't understand where to find the jar files.
server]# ls
AdminPortalServiceImpl.java commons-configuration-1.6.jar commons-logging-1.1.1.jar ConfReader.java README User.java
commons-collections-3.2.jar commons-lang-2.6.jar ConfReader.class global.xml UCService.java UserService.java
server]# pwd
/root/workspace/Conf_Reader/server
server]# javac ConfReader.java -cp commons-configuration-1.6.jar -cp commons-collections-3.2.jar -cp commons-lang-2.6.jar -cp commons-logging-1.1.1.jar
ConfReader.java:12: package org.apache.commons.configuration does not exist
import org.apache.commons.configuration.*;
^
ConfReader.java:13: package org.apache.commons.lang.exception does not exist
@skihero
skihero / ConfReader.java
Created February 25, 2011 13:19
Read the XML configuration file to obtain extra params
/* Reads the configuration from the settings XML File
* This is for providing the params needed in the
* server side
* Created Tue Feb 15 18:59:31 IST 2011: Kish
* Updated to include Sipx changes Feb 25 2011: Kish
*
*
Needed
commons-collections-3.2.jar
commons-configuration-1.6.jar
List <UCService> list_ucs ;
/* add the subscribed services to a list */
list_ucs.add(ucs) ;
Gives local variable list_ucs may not have been initialized.
List in java needs to be initiallised like
List <UCService> list_ucs = new ArrayList<UCService>(); /** WTF **/
@skihero
skihero / gist:849303
Created March 1, 2011 15:36
Storing password in mysql db
mysql> insert into user values ( 'host' , 'user', PASSWORD('SOMEPASS') ) ;
Query OK, 1 row affected (0.18 sec)
mysql> select * from user;
+------+------+-------------------------------------------+
| Host | User | Password |
+------+------+-------------------------------------------+
| host | user | *E16D008B9B8AD7E8509A5655514EC731A0F9A6A6 |
+------+------+-------------------------------------------+
1 row in set (0.00 sec)
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Adapter class to generate command string suitable for
* SoapCommandUtil class from User Object class
/* Reads the configuration from the settings XML File
* This is for providing the params needed in the
* server side
* Created Tue Feb 15 18:59:31 IST 2011: Kish
* Updated to include Sipx changes Feb 25 2011: Kish
*
*/
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- This conf file will be read to configure the client side -->
<!-- and the set the requried parameters in the server side -->
<!-- First draft: Wed Feb 16 11:19:52 IST 2011 : Kish -->
<!-- Added zimbra params : Mon Feb 28 21:08:01 IST 2011: Kish -->
<!-- Added zimbraMisc : Wed Mar 2 00:24:08 IST 2011 : Kish -->
<default_settings>
<services>