Skip to content

Instantly share code, notes, and snippets.

View gunith's full-sized avatar
🎯
Focusing

Gunith gunith

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am gunith on github.
  • I am gunith (https://keybase.io/gunith) on keybase.
  • I have a public key whose fingerprint is 74C5 3941 376C 56AA 5F15 7E1B 3E11 CFFF 3ABB DF44

To claim this, I am signing this object:

#!/bin/bash
### Setup a wifi Access Point on Ubuntu 12.04 (or its derivatives).
### make sure that this script is executed from root
if [ $(whoami) != 'root' ]
then
echo "
This script should be executed as root or with sudo:
sudo $0
"
@gunith
gunith / file1.sql
Created February 13, 2012 15:27
File Path Using Oracle
SELECT path
FROM
(SELECT ID ,
PARENT_ID ,
FILE_NAME ,
SYS_CONNECT_BY_PATH(FILE_NAME, '/') AS path,
RANK() OVER (ORDER BY LENGTH(SYS_CONNECT_BY_PATH(FILE_NAME, '/')) DESC) AS rank
FROM files
WHERE id=? CONNECT BY PRIOR id = parent_id
)
@gunith
gunith / gist:1683792
Created January 26, 2012 17:00
What if the Map's values are Objects? Then I'd have to cast it to whatever type as well, right?
/**
* Get a value from a {@link Map} or get a default value casted to a particular type
*
* @param <K> Type of Key
* @param <V> Type of Value
* @param <T> Type expected of return (to what we're casting the object)
* @param map The source {@link Map}
* @param key The key in the {@link Map}
* @param defaultValue The default value for the key in the {@link Map}
* @param retType The Class of the return type
@gunith
gunith / gist:1683766
Created January 26, 2012 16:56
Logic is, check for a value in the map... If it is there, get it. Otherwise, get a default.
/**
* Get a value from a {@link Map} or get a default value
*
* @param <K> Type of Key
* @param <V> Type of Value
* @param map The {@link Map}
* @param key The key in the {@link Map}
* @param defaultValue The default value for the key in the {@link Map}
* @return The value from {@link Map}
*/
@gunith
gunith / restartOra.sh
Created January 22, 2012 13:39
How do I restart Oracle service in Linux?
su - oracle # Login as Oracle. Actually, its better to login to the machine as Oracle than this
lsnrctl start # lsnrctl manages the Oracle listener processes. Start it
dbshut $ORACLE_HOME # Shutdown Oracle
dbstart $ORACLE_HOME # Start Oracle
lsnrctl stop # Stop lsnrctl
@gunith
gunith / gist:1486782
Created December 16, 2011 16:39
A Stack depthFirstOrder example
/**
* Returns a {@link Stack} having a Tree ordered in Depth First whose root is passed as the Parameter
*
* @param <T> The implementation of {@link Node}
* @param treeRoot The root of the tree
* @return The {@link Stack} of T
*/
public static <T extends Node> Stack<T> depthFirstOrder(final T treeRoot)
{
// Main stack, where the important stuff go