Skip to content

Instantly share code, notes, and snippets.

View Witiko's full-sized avatar

Vít Starý Novotný Witiko

  • Masaryk University
  • Brno, Czech Republic
View GitHub Profile
# include <stdio.h>
# include <stdlib.h>
# include <time.h>
void color() {
printf("\033[38;5;%dm", 17 + 6 * (rand() % 35) + rand() % 4);
}
int main() {
int input; srand(time(NULL)); color();
#!/bin/sh
# Raspi FW update tool
sudo apt-get install git-core binutils ca-certificates
sudo wget http://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O /usr/bin/rpi-update
sudo chmod +x /usr/bin/rpi-update
sudo rpi-update
# Clean-up
sudo apt-get purge git-core binutils ca-certificates
sudo rm -rf /usr/bin/rpi-update /root/.rpi-firmware
# Ta-da!
#!/bin/sh
# Time zones
sudo dpkg-reconfigure tzdata
sudo apt-get update
yes | sudo apt-get upgrade
yes | sudo apt-get install console-data locales
# Locales
sudo dpkg-reconfigure locales
# Bloatware away!
yes | sudo apt-get purge x11-common midori lxde python3 python3-minimal
@Witiko
Witiko / DOM.js
Last active December 22, 2015 10:58
An unfinished DOM interfacing library employing an API similar to that of the jQuery library.
/*
DOM(String Query[, DOM Node / Window Context])
DOM(Wrappable1[, Wrappable2[, Wrappable3[, ... WrappableN]]]) -> DOM Object Wrapper
DOM.searchEngine([Function searchEngine]) -> Sets / Resets the search function
DOM.plugins = {};
new DOM[.Prototype].Fragment([Wrapped Node(s) / Node[, Wrapped Node(s) / Node ...]])
new DOM[.Prototype].Element(String Element1Name[, String Element2Name[, String ElementNName]])
@Witiko
Witiko / Math.js
Last active December 22, 2015 10:58
An extension to the standard Math.* javascript library
(function(NaN, Array, Math, Number, undefined) {
var funcPointer = {
log: Math.log,
pow: Math.pow,
rng: Math.random
},
isNumber = Number.isNumber,
isFloat = function(n) {
return /\./.test(n);
@Witiko
Witiko / Overload.js
Created September 6, 2013 10:33
A simple library adding the function overloading capability to javascript
Function.overload = function(f) {
if(!(f instanceof Function)) return;
var _$ = function() {
var $ = [arguments, , this, _$._overloads],
_ = function(type, index) {
if(type instanceof Array) return type.some(function(type) {
return _(type, index);
});
if(!($[0][index] instanceof Object))
$[0][index] = Object($[0][index]);
@Witiko
Witiko / Ecma5.js
Created September 6, 2013 10:44
A library adding support of various ecma5 functions to an ecma3-compliant interpreter
(function(global, isNaN, undefined) {
var arrLikeString = !!"1"[0], has, get;
if(!arrLikeString) {
has = function(arr, item, isStr) {
return isStr?item < arr.length:
item in arr;
};
get = function(arr, item, isStr) {
return isStr?arr.charAt(item):arr[item];
@Witiko
Witiko / Gotten.js
Created September 6, 2013 10:47
An interfacing library for the ecma5 or mozilla getter and setter support - whichever is implemented
var Accessors = (function($, undefined) {
var ECMA5Support =
Object.getOwnPropertyDescriptor instanceof Function &&
Object.defineProperty instanceof Function && (function() {
var o = {}, f = function() {return true};
try {
Object.defineProperty(o, "o", {get: f});
return o.o && Object.getOwnPropertyDescriptor(o, "o").get === f;
} catch(e) {
return false;
@Witiko
Witiko / Points.js
Created September 6, 2013 10:50
A function that calculates the distance, gradient and bearing of a path between two points on the Earth. Requires the Math.js library because of the Number.prototype.* calls.
function Points(lat1, lon1, alt1,
lat2, lon2, alt2) {
alt1 = alt1 / 1000 || 0;
alt2 = alt2 / 1000 || 0;
var dLat = (lat2 - lat1).degToRad(),
dLon = (lon2 - lon1).degToRad(),
dAlt = alt2 - alt1;
lat1 = lat1.degToRad();
lat2 = lat2.degToRad();
lon1 = lon1.degToRad();
@Witiko
Witiko / Object2.js
Last active December 22, 2015 10:59
A user-defined Object2 object adding the support of multiple prototypal inheritance.
function Object2() {
this.prototypes = arguments;
this.attributes = {};
}; Object2.prototype.get = function(key) {
return this.attributes[key] || (function(array) {
for(var i = 0, l = array.length, result; !result && i < l; i++)
result = array[i].get(key); return result;
})(this.prototypes);
}; Object2.prototype.set = function(key, value) {
this.attributes[key] = value;