Skip to content

Instantly share code, notes, and snippets.

View KomanRudden's full-sized avatar

Koman Rudden KomanRudden

  • BMW
  • South Africa
View GitHub Profile
@KomanRudden
KomanRudden / Oracle Sequence - nextval
Created February 23, 2016 12:28
Oracle Sequence - nextval
select <seq_name>.nextval from dual;
@KomanRudden
KomanRudden / Logback
Created February 23, 2016 06:14
Logback
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n</pattern>
</encoder>
</appender>
<appender name="logger" class="ch.qos.logback.core.rolling.RollingFileAppender">
@KomanRudden
KomanRudden / Git commands - add, commit, merge, diff, difftool, stash etc
Last active May 31, 2017 04:42
Git commands - add, commit, merge, diff, difftool, stash etc
git init - [initializes project as a git managed project]
git ls-file - [list all tracked files]
git add . - [adds everything in project to git staging area]
git commit -am "Comment" - [adds and commits all changed files to staging area]
git pull origin master - [updates local branch with changes from repository]
git push origin master - [push local changes to repository]
git branch - [lists all local branches]
git checkout -b branchName - [switch to branch, -b creates the branch]
git merge my-new-branch - [merges my-new-branch into current branch]
git branch -d my-new-branch - [delete branch]
@KomanRudden
KomanRudden / Spring JMS configuration
Created January 21, 2016 05:52
Spring JMS configuration
http://www.stefanalexandru.com/java/spring-4-jms-connection-with-java-config-and-weblogic-as-jms-provider
@KomanRudden
KomanRudden / Parsing from XML to JAXB object
Last active February 11, 2016 09:44
Parsing from XML to JAXB object
JAXBContext jaxbContext = JAXBContext.newInstance(<theObject>.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(<thingToMarshall>);
<theObject> root = (<theObject>) unmarshaller.unmarshal(reader);
@KomanRudden
KomanRudden / Git branch name on command line
Created January 15, 2016 10:59
Git branch name on command line
Add these lines to ~/.bashrc file
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
@KomanRudden
KomanRudden / AngularJS - share variables across controllers
Created January 6, 2016 05:15
AngularJS - share variables across controllers
Simple service example:
angular.module('myApp', [])
.service('sharedProperties', function () {
var property = 'First';
return {
getProperty: function () {
return property;
},
@KomanRudden
KomanRudden / Bubble sort - ASC
Last active June 6, 2016 09:55
Bubble sort example
package com.permgen;
import java.util.Arrays;
public class PermgenBubbleSortAsce {
public static void main(String[] args) {
int arrayList[] = { 5,3,9,7,1,8 };
System.out.println("\nFinal result:"+Arrays.toString(PermgenBubbleSortAsceMethod(arrayList)));
@KomanRudden
KomanRudden / Grep command
Last active January 6, 2016 05:09
Grep to extract text example
grep -no 'name="[^ ]*"' file.html > results.txt
In this line:
The n option will print the lines that matched the pattern. Simply for informative reasons, at first glance. Remove if you don't want it.
The o option prints only the matched text, not the entire line itself.
file.html is the path to your file.
the P option is for look arounds.
Also if you want the results saved to a file, you can pipe them by appending > results.txt:
@KomanRudden
KomanRudden / Mock void
Last active November 13, 2015 11:28
Mocking void return type methods
final ClassToMock spy = Mockito.mock(ClassToMock.class);
Mockito.doNothing().when(spy).voidMethodToMock(...);