This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val employeeHandler = new EmployeeHandler with SprayEmployeeServiceComp with EmployeeDbComp { | |
| val employeeDb = new EmployeeDb { | |
| override def createEmployee(employee: Employee) = { | |
| // mocked employee creation | |
| } | |
| override def getEmployee(empId: Int): Employee = { | |
| // mocked employee retrieve | |
| Employee(3, "test", "test") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # connect | |
| psql -h <host> -p <port> -U <user> | |
| psql -h dev.localhost -p 15534 -U postgres | |
| # list databases | |
| \list | |
| # connect to database | |
| \connect <databasename> | |
| \connect senz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # grep prints line below and above(10 lines below and above) | |
| git log | grep -C 10 android | |
| # recurisve grep on current folder | |
| grep -R "createEmployee" . | |
| # recursieve grep on .java files | |
| grep -R "createemployee" *.java | |
| # recursive grep on src/ directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try { | |
| val database = Database.forURL(databaseUrl, databaseUser, databasePassword, null, databaseDriver) | |
| database.createSession() | |
| } catch { | |
| case e: Exception => | |
| log.error(e.toString) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val ds = new ComboPooledDataSource | |
| ds.setDriverClass(driverName) | |
| ds.setJdbcUrl(dbConfig.getString("url")) | |
| ds.setUser(dbConfig.getString("username")) | |
| ds.setPassword(dbConfig.getString("password")) | |
| // most reliable way, but have visible peformance drop | |
| ds.setTestConnectionOnCheckout(true) | |
| // have better peformacne |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # connect to tcp | |
| telnet <host> <post> | |
| telent 10.2.4.110 8080 | |
| >>msg | |
| # exit from telnet session | |
| ctrl ] | |
| quit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # format | |
| rsync <options> <source> <destination> | |
| # most commen optaions | |
| -v : verbose | |
| -r : syncs recursively(used when directory backup) | |
| -a : archive mode(altrenative to -r). syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions | |
| -h : human readable output | |
| -z : comporess files while sync |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ssh-keygen -f ~/.ssh/id_rsa -q -P "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # command | |
| rsunc <options> <remote directory> <local directory> | |
| # usage | |
| rsync -avzh [email protected]:/home/pagero/storage/ /home/eranga/storage/ | |
| # directories | |
| /home/pagero/storage/ : Remote directory | |
| /home/eranga/storage/ : Local directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # edit crontab file | |
| crontab -e | |
| # rsync as a cron job | |
| 30 23 * * * flock -n /tmp/rsync.lock -c "rsync -avzh [email protected]:/home/pagero/storage/ /home/eranga/storage/>/tmp/rsync.log" | |
| # things to notice | |
| 1. 30 23 : Cron job runs everyday 23:30 PM (11.30 PM) | |
| 2. flock -n /tmp/rsync.lock : Will prevents to run duplicate cronjobs(means only one cron job will be running) | |
| 3. >/tmp/rsync.log : Will take the output of rsync job to /tmp/rsyn.log file |