Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from os import curdir, sep, stat
PORT_NUMBER = 8080
#This class will handles any incoming request from
#the browser
class myHandler(BaseHTTPRequestHandler):
@ik5
ik5 / cracklib.rb
Last active December 11, 2015 11:28
cracklib ruby ffi support
# -*- ruby -*-
#
# cracklib.rb - ruby bindings for cracklib
#
# Copyright (c) 2010 Kevin R. Bullock
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
@ik5
ik5 / tfpsmap.pas
Created February 7, 2013 23:20
An example on how to properly use TFPSMap of FPC's fgl unit
{$mode objfpc}
uses sysutils, fgl;
type
TMyKey = class
public
Key : String;
constructor Create;
end;
@ik5
ik5 / update.rb
Last active December 15, 2015 15:29
My update script for many repositories under current folder, with different scm
#!/usr/bin/env ruby
#
def update(dir, type)
Dir.chdir(dir)
puts "Going to update #{dir}"
system("#{type.to_s} pull")
Dir.chdir('..')
end
@ik5
ik5 / update.go
Last active December 15, 2015 16:48
My first go program - updating local directories with their scm command
package main
import (
"bytes"
"fmt"
"os"
"os/exec"
)
func isDir(path string) (bool, error) {
@ik5
ik5 / blink.ino
Created April 12, 2013 20:25
Arduino code for "first" project
@ik5
ik5 / traffic1.ino
Last active December 16, 2015 04:19
This is my second Arduino project - Very simple traffic light http://youtu.be/HAurB9fVTWM
/*
Copyright (c) 2013 ik_5 <idokan@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
@ik5
ik5 / exec.rb
Last active December 17, 2015 03:28 — forked from anonymous/exec.rb
Allow to execute commands using Ruby that arrives from gem and using Bundler Gemfile
$BASE_PATH = File.expand_path(File.dirname(__FILE__) + '/..')
# also find your own gem files for the executable
$LOAD_PATH.unshift($BASE_PATH + '/lib')
require 'bundler'
ENV["BUNDLE_GEMFILE"] = $BASE_PATH + '/Gemfile'
Bundler.require(:default)
@ik5
ik5 / time_duration.rb
Last active December 20, 2015 04:39
simple way to calculate time duration based on ruby-duration
# start = Time.now
# sleep 20
# finish = Time.now
# calc(finish - start) => [0, 0, 0, 0, 20]
# [weeks, days, hours, minutes, seconds]
#
def calc(seconds)
# weeks days hours min s
mul = [604800, 86400, 3600, 60, 1]
values = [:weeks, :days, :hours, :minutes, :seconds]
@ik5
ik5 / run_at.sh
Last active December 21, 2015 01:38
random execution in given time
#!/bin/bash
seq=$(seq -s ' ' $[ $RANDOM % 8 +1 ] )
hour=($(shuf --input-range=0-23 -n 8 | tr '\n' ' '))
minutes=($(shuf --input-range=0-59 -n 8 | tr '\n' ' '))
for i in $seq ; do
atime=${hour[$i - 1]}${minutes[$i - 1]}
$(at $atime <<< /usr/bin/runsomething)
done