Skip to content

Instantly share code, notes, and snippets.

View Ikke's full-sized avatar

Kevin Daudt Ikke

  • Netherlands
  • 12:22 (UTC +02:00)
View GitHub Profile
module Golf where
skips :: [a] -> [[a]]
skips xs = map (\i -> takeEvery (fst i) (snd i)) $ createZipList xs
where
createZipList xs = zip [1..] $ take (length xs) $ repeat xs
takeEvery :: Int -> [a] -> [a]
takeEvery n xs =
case drop (n-1) xs of
@Ikke
Ikke / Log.hs
Last active August 29, 2015 14:11
Implementation of the CIS194 homework 2 assignment (see LogAnalysis.hs)
-- CIS 194 Homework 2
module Log where
import Control.Applicative
data MessageType = Info
| Warning
| Error Int
deriving (Show, Eq)
<?php
function get_path($obj, $path, $default=NULL)
{
if(empty($obj)) {
return $default;
}
$parts = explode(".", $path);
bubblesort :: (Ord a) => [a] -> [a]
bubblesort [] = []
bubblesort (x1:x2:xs) =
let sorted = if x2 < x1
then x2 : bubblesort (x1:xs)
else x1 : bubblesort (x2:xs)
in (bubblesort $ init sorted) ++ [last sorted]
bubblesort xs = xs
main = do
@Ikke
Ikke / ipv6_cidr.php
Created June 25, 2014 22:08
Checks if ipv6 address is inside a range.
<?php
function ipv6_cidr($subnet, $range, $ip)
{
$bit_mask = mask_bits(128, $range);
$subnet = inet_pton($subnet) & $bit_mask;
return (inet_pton($ip) & $bit_mask) == $subnet;
}
function mask_bits($total_length, $mask_length)
host git.epinux.com robotns2.second-ns.de. ~
Using domain server:
Name: robotns2.second-ns.de.
Address: 213.133.105.6#53
Aliases:
git.epinux.com is an alias for epinux.com.epinux.com.
epinux.com.epinux.com is an alias for epinux.com.epinux.com.
epinux.com.epinux.com is an alias for epinux.com.epinux.com.
@Ikke
Ikke / state.py
Last active August 29, 2015 14:02
OOP Statemachine
class Context():
def __init__(self):
self.result = []
self.current = {}
self.lastValue = 0
def setBeginValue(self, value):
self.current['beginValue'] = value
def buildResult(self):
server {
index index.php;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
= /^Income:salary$/
; [Accounts:checking] $ -200.00
; [Budget:food] $ 200.00
= /^Expense:food$/
[Budget:food] -1.0
[Accounts:checking] 1.0
2014/04/13 Company Inc
Accounts:checking $ 1000.00
git-test-conflict :: (master*) » git mergetool ~/tmp/git-test-conflict
Merging:
foo
Normal merge conflict for 'foo':
{local}: modified file
{remote}: modified file
Hit return to start merge resolution tool (vimdiff):
4 files to edit