Skip to content

Instantly share code, notes, and snippets.

.bashrc
source ~/.profile
.profile
#!/bin/bash
#Changing directory with alias
alias front='cd ~/Development/OLX/plutus-frontend/'
@khamiltonuk
khamiltonuk / .zshrc
Last active November 27, 2017 10:26
zsh config file
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/kristian.hamilton/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="agnoster"
@khamiltonuk
khamiltonuk / .gitconfig
Last active November 22, 2017 08:55
Git alias for the perfect workflow (file stored in your home directory)
[alias]
addr = noaddr
st = status
flg = !git fetch && git lg
lg = log --graph --decorate --branches --oneline --remotes --tags --all --color
ci = commit
co = checkout
cdiff = diff --cached
subup = submodule update --init --recursive
ff = merge --ff-only origin/master
{
"id": 97045,
"sellerId": 56578,
"title": "Buick Tageszulassung Nr. 4402029343513687345",
"makeId": 4400,
"makeKey": "Buick",
"modelKey": "Skylark",
"images": [{
"uri": "i.ebayimg.com/00/s/NjgyWDEwMjQ=/z/znIAAOxynwlTcg-F/$",
"set": "fe4cfedffdffffffff"
@khamiltonuk
khamiltonuk / mongodbClass.java
Created November 29, 2015 22:54
Enabling MongoDB replica set
import org.springframework.data.mongodb.config;
public final class ServerAddressPropertyEditorRegistrar implements PropertyEditorRegistrar {
@Override
public void registerCustomEditors(PropertyEditorRegistry registry) {
registry.registerCustomEditor(ServerAddress[].class, new ServerAddressPropertyEditor());
}
}
@khamiltonuk
khamiltonuk / javaConfig.java
Created November 29, 2015 22:53
Enabling MongoDB replica set
@Configuration
@EnableMongoRepositories({"com.foo.repository"})
public class MongoRepositoryConfig{
@Value("localhost:27017, localhost:27018")
private ServerAddress[] serverAddressList;
@Bean
@Override
public Mongo mongo() throws Exception {
@khamiltonuk
khamiltonuk / XMLConfiguration.xml
Created November 29, 2015 22:51
Enabling MongoDB replica set
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd">
@khamiltonuk
khamiltonuk / index.html
Created November 29, 2015 22:48
Simple CSRF Protection with Spring MVC - putting token in the page
<form action="..." method="post">
...
<input type="hidden" name="secureToken" value="${secureToken}"/>
</form>
@khamiltonuk
khamiltonuk / controllerMethods.java
Created November 29, 2015 22:46
Simple CSRF Protection with Spring MVC
@Controller
@RequestMapping(PAGE_PATH)
public final class DangerousPageController {
@SecureToken(value = VIEW_NAME)
@RequestMapping(method = RequestMethod.GET)
public String showPage() {
// Show the page…
}
@SecureToken(value = VIEW_NAME)
@khamiltonuk
khamiltonuk / springConfig.java
Created November 29, 2015 22:42
Simple CSRF Protection with Spring MVC
@Configuration
public class SellerWebsiteInterceptorsConfig
extends WebMvcConfigurerAdapter {
@Autowired
private SecureTokenService secureTokenService;
@Override
public void addInterceptors(InterceptorRegistry registry) {
// Put your other interceptors here too ….
registry.addInterceptor(secureTokenInterceptor());