Skip to content

Instantly share code, notes, and snippets.

@hG3n
hG3n / main.py
Last active November 26, 2015 21:53
bachelor snippet
#!/usr/bin/env python
import sys
import numpy as np
import cv2 as cv
class Subimage:
def __init__(self, TL, BR):
self.tl = TL
self.br = BR
@hG3n
hG3n / process_timer.cpp
Last active January 16, 2016 14:18
this is a short snippet to remind how one can calculate time needed by one process
#include <iostream>
#include <ctime>
#include <vector>
#include <algorithm>
int main() {
// create vector for storing the calculated times needed for a piece of code to finish
std::vector<float> times;
int counter = 0;
@hG3n
hG3n / python_color
Created February 28, 2016 16:28
print colorful in python
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
@hG3n
hG3n / notification.swift
Created May 27, 2016 10:17 — forked from ericdke/notification.swift
Deliver an OSX notification with Swift
func showNotification() -> Void {
var notification = NSUserNotification()
notification.title = "Test from Swift"
notification.informativeText = "The body of this Swift notification"
notification.soundName = NSUserNotificationDefaultSoundName
NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(notification)
}
//showNotification()
@hG3n
hG3n / segment_texture_atlas.py
Created April 11, 2017 12:39
image segmentation
# load image atlas as greyscale
print("loading image: %s" % self.file)
atlas = io.imread(self.file, as_grey=True)
# check atlas size
rows = atlas.shape[0]
cols = atlas.shape[1]
if rows % self.slice_size != 0 or cols % self.slice_size != 0:
print("ERROR: wrong image dimensions, should be multiple of 200")
return
@hG3n
hG3n / include-html.directive.ts
Last active February 27, 2018 12:56
directive to include an external html file into an existing dom-element
import {Directive, ElementRef, Input, OnChanges, OnInit} from '@angular/core';
import 'rxjs/add/operator/map';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
@Directive({
selector: '[includeHtml]'
})
export class IncludeHtmlDirective implements OnInit, OnChanges {
@hG3n
hG3n / .vimrc_qt
Created September 16, 2018 12:39
"""""""""""""""""""""""""""
"--- GENERAL SETTINGS ---"
"""""""""""""""""""""""""""
scriptencoding utf-8
set enc=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf8,prc
set tabstop=4
set shiftwidth=4
@hG3n
hG3n / groupBy
Created November 22, 2018 13:08
Group Elements by several matching attributes
function groupBy(array: any[], f): any {
const groups = {};
array.forEach(function (o) {
const group = JSON.stringify(f(o));
groups[group] = groups[group] || [];
groups[group].push(o);
});
return Object.keys(groups).map(function (group) {
return groups[group];
});
@hG3n
hG3n / lirc-pi3.txt
Created December 5, 2018 20:39 — forked from prasanthj/lirc-pi3.txt
Getting lirc to work with Raspberry Pi 3 (Raspbian Stretch)
Notes to make IR shield (made by LinkSprite) work in Raspberry Pi 3 (bought from Amazon [1]).
The vendor has some documentation [2] but that is not complete and sufficient for Raspbian Stretch.
Following are the changes that I made to make it work.
$ sudo apt-get update
$ sudo apt-get install lirc
# Add the following lines to /etc/modules file
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=17
@hG3n
hG3n / .vimrc
Last active November 19, 2023 14:31
vim config file
"""""""""""""""""""""""
"--- !! VUNDLE !! --- "
"""""""""""""""""""""""
set shell=/bin/bash
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'