Skip to content

Instantly share code, notes, and snippets.

View Ikke's full-sized avatar

Kevin Daudt Ikke

  • Netherlands
  • 11:16 (UTC +02:00)
View GitHub Profile
>>> current = 89
>>> new = 5
>>> while current % 96 != new:
... print("Sending: " + str(current % 96))
... current += 1
...
Sending: 89
Sending: 90
Sending: 91
Sending: 92
@Ikke
Ikke / test.rb
Last active August 29, 2015 13:56
def test_loop(previous_quarter, quarter_index, max_quarter) do
while(previous_quarter % max_quarter != quarter_index) do
puts(quarter_index)
quarter_index += 1
end
end
>>> def test_loop(previous_quarter, quarter_index, max_quarter):
... while previous_quarter % max_quarter != quarter_index:
... print(previous_quarter % max_quarter)
... previous_quarter+=1
...
>>>
>>> test_loop(10,10,20)
>>> test_loop(10,11,20)
10
>>> test_loop(10,12,20)
@Ikke
Ikke / sys
Created March 4, 2014 19:28
Shortcuts for systemctl
#!/bin/bash
sys="sudo /usr/bin/systemctl"
case "$1" in
s) shift 1
$sys status $@
;;
o) shift 1
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
= /^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
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;
@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):
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 / 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)