Skip to content

Instantly share code, notes, and snippets.

View aeris's full-sized avatar

aeris aeris

View GitHub Profile
@aeris
aeris / gist:1078590
Created July 12, 2011 18:17
Firewall
### BEGIN INIT INFO
# Provides: iptables
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
#!/bin/sh
@aeris
aeris / Main.java
Created September 14, 2011 20:47
Java interview question
class Foo1 {
String bar = "bar1";
String getBar() {
return this.bar;
}
void setBar(final String bar) {
this.bar = bar;
}
@aeris
aeris / rsync-snapshot.pl
Last active September 27, 2015 06:27
RSync Snapshot
#!/usr/bin/perl
END {
kill 15, -$$
}
`renice 10 $$`;
my $rs_conf = "/etc/rsync-snapshot.conf";
@aeris
aeris / dao.py
Created October 3, 2011 23:24
Possible architecture
# -*- coding: utf-8 -*-
"""
rhodecode.dao
~~~~~~~~~~~~~
Data access layer
:created_on: Oct 4, 2011
:author: nvinot
:copyright: (C) 2011 Nicolas VINOT <[email protected]>
@aeris
aeris / Main.java
Created November 4, 2011 20:59
Héritage et polymorphisme
public class Main {
private static class A {
protected void foo() {
System.out.println("A");
}
}
private static class B extends A {
@Override
protected void foo() {
@aeris
aeris / gist:1872233
Created February 20, 2012 23:22
Debian setup for OVH
# Partitionning
fdisk /dev/sda (n p 1, a 1, t 1 fd, w)
sfdisk -d /dev/sda | sfdisk /dev/sdb
# RAID 1
mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1 --assume-clean
# LVM
pvcreate /dev/md0
vgcreate debian /dev/md0
@aeris
aeris / zshprompt
Created July 7, 2012 16:45
Git prompt for ZSH
autoload -U colors
colors
# Allow for functions in the prompt.
setopt prompt_subst
autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_update_git_vars
add-zsh-hook preexec preexec_update_git_vars
@aeris
aeris / zshprompt.sh
Last active October 7, 2015 02:58
ZSH SCM prompt
autoload -U colors
colors
# Allow for functions in the prompt.
setopt prompt_subst
autoload -U add-zsh-hook
add-zsh-hook chpwd update_scm_vars
add-zsh-hook preexec preexec_update_scm_vars
@aeris
aeris / addNetworkManagerConnection.py
Created August 1, 2012 21:51
Create Network Manager connection from command line
import dbus, struct, socket, uuid
def _ip(ip):
t = socket.inet_aton(ip)
return dbus.UInt32(struct.unpack("I", t)[0])
def _ips(ips):
return dbus.Array([_ip(ip) for ip in ips], signature=dbus.Signature('u'))
def _ip6(ip):
@aeris
aeris / bak.sh
Created August 8, 2012 08:57
Backup utility
#!/bin/bash
backup() {
mv "${1}" "${1}.bak"
}
restore() {
mv "${1}" "${1/%\.bak/}"
}