2012-05-31

HowTo Create Debian Packages (FOSDEM 2012): 


Some Notes from this Video: http://www.youtube.com/watch?v=LVeHlhJXa7E




$ mkdir debian
$ dch --create
$ dch --append
$ dch -v1.2
$ dch -r


$ vim debian/control

Source: pony
Maintainer: Sascha Dewald <sdewald (at) googlemail.com>
Architecture: any

Package: pony

$ cp /usr/share/debhelper/dh_make/debians/rules.dh7    debian/rules


$ vim debian/rules


$ mkdir debian/source
$ vim debian/source/format

3.0

$ lintian pony_1.0_amd64.changes


$ lintian -I pony_1.0_amd64.changes

2012-04-01

F#  Common Hash Functions

TODO:  at the moment it didn't work well with streams.


module HashSum =
    open System
    open System.IO
    open System.Security.Cryptography
    open System.Text


    let encode (s: string) = UTF8Encoding().GetBytes(s)


    let toHexDigit n =
        if n < 10uy then char (n + 0x30uy)
        else char (n + 0x37uy)


    let toHex b =
        let strArr =
            [|for n in b do
                  let ln = (n &&& 0xF0uy) >>> 4
                  let rn =  n &&& 0x0Fuy
                  yield ln |> toHexDigit
                  yield rn |> toHexDigit|]
        new String(strArr)


    let md5sum s =            
        use hashProvider = new MD5CryptoServiceProvider()
        let hash = hashProvider.ComputeHash(encode s)
        hash |> toHex


    let sha1sum s =
        use hashProvider = new SHA1CryptoServiceProvider()
        let hash = hashProvider.ComputeHash(encode s)
        hash |> toHex


    let sha256sum s =
        use hashProvider = new SHA256Managed()
        let hash = hashProvider.ComputeHash(encode s)
        hash |> toHex


    let sha512sum s =
        use hashProvider = new SHA512Managed()
        let hash = hashProvider.ComputeHash(encode s)
        hash |> toHex




open System
open HashSum 
Console.WriteLine(md5sum "Hello World")
Console.WriteLine(sha1sum "Hello World")
Console.WriteLine(sha256sum "Hello World")
Console.WriteLine(sha512sum "Hello World")

2012-03-31

Some Security Linux Kernel Settings 

(/etc/sysctl.conf  or   /etc/sysctl.d/*):




#### ipv4 networking ####


## TCP SYN cookie protection
## helps protect against SYN flood attacks
## only kicks in when net.ipv4.tcp_max_syn_backlog is reached
net.ipv4.tcp_syncookies = 1


## protect against tcp time-wait assassination hazards
## drop RST packets for sockets in the time-wait state
## (not widely supported outside of linux, but conforms to RFC)
net.ipv4.tcp_rfc1337 = 1


## tcp timestamps
## + protect against wrapping sequence numbers (at gigabit speeds)
## + round trip time calculation implemented in TCP
## - causes extra overhead and allows uptime detection by scanners like nmap
## enable @ gigabit speeds
net.ipv4.tcp_timestamps = 0
#net.ipv4.tcp_timestamps = 1


## source address verification (sanity checking)
## helps protect against spoofing attacks
net.ipv4.conf.all.rp_filter = 1


## disable ALL packet forwarding (not a router, disable it)
net.ipv4.ip_forward = 0


## log martian packets
net.ipv4.conf.all.log_martians = 1


## ignore echo broadcast requests to prevent being part of smurf attacks
net.ipv4.icmp_echo_ignore_broadcasts = 1


## optionally, ignore all echo requests
#net.ipv4.icmp_echo_ignore_all = 1


## ignore bogus icmp errors
net.ipv4.icmp_ignore_bogus_error_responses = 1


## IP source routing (insecure, disable it)
net.ipv4.conf.all.accept_source_route = 0


## send redirects (not a router, disable it)
net.ipv4.conf.all.send_redirects = 0


## ICMP routing redirects (only secure)
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 1


Reload this settings with the following command:

sysctl -p


2012-03-26

Git Workflow for Humans

*Nice Project*:   http://www.git-legit.org/



$ git switch <branch>
# Switches to branch. Stashes and restores unstaged changes.



$ git sync
# Syncronizes current branch. Auto-merge/rebase, un/stash.


$ git publish <branch>
# Publishes branch to remote server.


$ git unpublish <branch>
# Removes branch from remote server.


$ git harvest <branch>
# Auto-merge/rebase commits from given branch.


$ git sprout <branch>
# Sprout a new branch from the current branch.


$ git graft <branch>
# Merge unpublished branch into current branch, then remove it.


$ git branches
# Nice & pretty list of branches + publication status.


2012-03-25

F# - Convert Sequence of Chars to String


  type System.String with
    static member ofSeq s = new String(s |> Seq.toArray)
    static member ofReversedSeq s = new String(s |> Seq.toArray |> Array.rev)
A Blog over Code Snippets and other Things.


Mostly about OpenSource (4 a better World)



Sway - as a snap reaches alpha state