Skip to content

Instantly share code, notes, and snippets.

View dulichan's full-sized avatar

Dulitha Wijewantha (Chan) dulichan

View GitHub Profile
@dulichan
dulichan / orabackup.sh
Created December 10, 2012 10:02
Oracle backup for current date and time
# Callable script from an application. The directory is predefined in the backup folder.
echo "Starting the export at "`date`
# su - oracle
#/home/oracle
#cd /DSSNEXP/
cd /u01/app/oracle/product/11.2.0/xe/bin
ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe; export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH; export PATH
mkdir /home/backup
DATE=`date +%Y-%m-%d-%r`
@dulichan
dulichan / cam.sh
Created December 10, 2012 10:18
Take a webcam pic from linux script
# For this script to work following commands should be executed first
# yum install -y mplayer-gui
# yum install -y xine
# yum install -y vlc
# yum install -y mplayer
mplayer -tv driver=v4l2:fps=1 -vo jpeg -vf framestep=5 -frames 5 tv://
if [ ! -d "right" ]; then
mkdir right
fi
fileName=0
@dulichan
dulichan / backup.py
Created December 10, 2012 10:28
Create a backup zip of a folder
import zipfile
import sys
import os, datetime
def zip_folder(folder_path, output_path):
"""Zip the contents of an entire folder (with that folder included
in the archive). Empty subfolders will be included in the archive
as well.
"""
parent_folder = os.path.dirname(folder_path)
@dulichan
dulichan / tweetSong
Created March 17, 2013 01:08
A small script to tweet the now listening song
tell application "iTunes"
if player state is playing then
set myTrack to current track
copy name of myTrack to nameOfTrack
copy artist of myTrack to artistOfTrack
tell application "System Events"
tell process "Notification Center"
click menu bar item 1 of menu bar 1
click button 1 of UI element 1 of row 2 of table 1 of scroll area 1 of window "window"
#display dialog nameOfTrack
@dulichan
dulichan / HbHelperAbstract.java
Created March 24, 2013 17:54
Part of my Hibernate Helper library.
package org.dchan.orm;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.hibernate.Hibernate;
@dulichan
dulichan / AsyncExecuter.java
Created March 24, 2013 18:02
Asynchronous task executer that uses an ongoing thread to monitor the tasks.
package org.dchan.concurrent;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
/**
* Copyright (c) 2013 Dulitha Wijewantha (http://www.dulithawijewantha.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@dulichan
dulichan / AwesomeApp.scala
Created March 29, 2013 02:34
A small scala app with Swing interface that interact with MongoDB
package com.dchan.awesomebank
import scala.swing.SimpleSwingApplication
import scala.swing.MainFrame
import scala.swing.Button
import javax.swing.JPanel
import java.awt.BorderLayout
import scala.swing.FlowPanel
import scala.swing.TextField
import scala.swing.Label
@dulichan
dulichan / ActionHelper.java
Created March 29, 2013 04:28
Swing action component framework
/**
* Copyright (c) 2013 Dulitha Wijewantha (http://www.dulithawijewantha.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@dulichan
dulichan / ios_profile.hbs
Created July 21, 2013 09:33
Enterprise App Deployment for iOS plist template
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
@dulichan
dulichan / gist:6170926
Created August 7, 2013 03:24
Synchronous issue with GenericArtifactManager
am = new carbon.registry.ArtifactManager(registry, "mobileapp");
var attributes ={
overview_status: "PENDING-REVIEW",
overview_name: ctx.name,
overview_platform:t,
overview_version: ctx.version,
overview_url: ctx.url,
overview_provider: ctx.provider,
overview_description: ctx.description,
overview_market:ctx.markettype,