Skip to content

Instantly share code, notes, and snippets.

View sohlich's full-sized avatar
🏠
Working from home

Rado Sohlich sohlich

🏠
Working from home
View GitHub Profile
// Restorer holds a function that can be used
// to restore some previous state.
type Restorer func()
// Restore restores some previous state.
func (r Restorer) Restore() {
r()
}
// Patch sets the value pointed to by the given destination to the given
@sohlich
sohlich / decorator.go
Created August 2, 2015 04:20
Example of decorator pattern in GO
package main
import (
"fmt"
"log"
)
//Basic interface to be enriched
type GreetingsBot interface {
DoHail(name string) (string, error)
//Generates variations of elements
//in submissionFiles array without repeating.
//output is array with tuples
for i := 0; i < len(submissionFiles); i++ {
for j := i + 1; j < len(submissionFiles); j++ {
tuple := OutputComparisonResult{
Files: []string{submissionFiles[i], submissionFiles[j]},
}
output = append(output, tuple)
}
#
# Nautilus
#
# Use list view by default
gsettings set org.gnome.nautilus.preferences default-folder-viewer "list-view"
# Sort files by type
gsettings set org.gnome.nautilus.preferences default-sort-order "type"
// with no parameter
() -> System.out.println("Hello, world.")
// with a single parameter (This example is an identity function).
a -> a
// with a single expression
(a, b) -> a + b
// with explicit type information
//Old School
List<Transaction> groceryTransactions = new Arraylist<>();
for(Transaction t: transactions){
if(t.getType() == Transaction.GROCERY){
groceryTransactions.add(t);
}
}
Collections.sort(groceryTransactions, new Comparator(){
public int compare(Transaction t1, Transaction t2){
return t2.getValue().compareTo(t1.getValue());
@sohlich
sohlich / go test coverage
Created November 5, 2015 21:28
Test coverage in html for GO
go test -coverprofile cover.out
go tool cover -html=cover.out -o cover.html
@sohlich
sohlich / jboss-deployment-structure.xml
Last active November 17, 2015 16:41 — forked from akerekes/jboss-deployment-structure.xml
JBoss deployment structure file to disable container provided logging
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.logmanager.log4j" />
<module name="org.slf4j" />
@sohlich
sohlich / Makefile.golang
Last active November 6, 2016 05:24 — forked from dnishimura/Makefile.golang
Makefile for Golang projects
BUILDPATH=$(CURDIR)
GO=$(shell which go)
GOBUILD=$(GO) build
GOCLEAN=$(GO) clean
GOGET=$(GO) get
EXENAME=main
export GOPATH=$(CURDIR)
@sohlich
sohlich / Wildfly: deployment-overlay
Created January 8, 2016 11:56
Wildfly CLI: The deployment overlay command
deployment-overlay add --name=myOverlay --content=/WEB-INF/web.xml=/myFiles/myWeb.xml,/WEB-INF/ejb-jar.xml=/myFiles/myEjbJar.xml --deployments=test.war,*-admin.war --redeploy-affected