Skip to content

Instantly share code, notes, and snippets.

View zuzkins's full-sized avatar

Jiří Zůna zuzkins

View GitHub Profile
@zuzkins
zuzkins / led.ino
Last active October 2, 2020 14:59
7 segment 4 digit led display test
ub/*
Showing number 0-9 on a Common Anode 7-segment LED display
Displays the numbers 0-9 on the display, with one second inbetween.
A
---
F | | B
| G |
---
E | | C
| |
@zuzkins
zuzkins / osx_setattr_x.swift
Created September 12, 2017 08:15
Simple example to trigger the usage of setattr_x function on a file
let dest = "/tmp/m/a"
let src = "/tmp/m/b"
let fileManager = FileManager();
let targetURL = URL.init(fileURLWithPath: dest)
let srcURL = URL.init(fileURLWithPath: src)
do {
try fileManager.replaceItemAt(targetURL, withItemAt: srcURL)
} catch {
print(error)
@zuzkins
zuzkins / babel-transform-class-properties.js
Created May 25, 2017 20:44
Neutrino 5 react preset + babel-plugin-transform-class-properties
const merge = require('deepmerge')
module.exports = neutrino => {
neutrino.config.module
.rule('compile')
.use('babel')
.tap(options => merge(options, { plugins: ['transform-class-properties'] }))
}
@zuzkins
zuzkins / user_role_component.dart
Created June 2, 2016 07:14
TIL you can put @input() decorator on setter and transform the value. It does not have to be put on property.
@Component( selector: 'user-role',
template: r'''
<span *ngIf="userRole != null && long" >{{ userRole.completeLabel }}</span>
<span *ngIf="userRole != null && !long" >{{ userRole.label}}</span>
''')
class UserRoleComponent {
UserRole userRole;
@Input()
@zuzkins
zuzkins / hash-pwd.sh
Last active February 11, 2016 18:38
wrapper which hashes given password with sha512 and 150k iterations and random salt. The result is suited to be used with glibc crypt function (htpasswd files) on systems, which do not have blowfish patch in glibc (eg. ubuntu)
#! /bin/bash
mkpasswd -m sha-512 -R 150000 -s -S $(openssl rand -hex 32 | cut -b 1-16)
@zuzkins
zuzkins / remove-library.sh
Created January 21, 2016 12:12
Simple script which will pull all tagged images from given docker registry which have in repository name "library". It will remove the "library" part and push the images back to the registry.
#! /bin/bash
CREDENTIALS=""
if [ ! -z "$DOCKER_USER" ] && [ ! -z "$DOCKER_PWD" ]; then
CREDENTIALS="$DOCKER_USER:$DOCKER_PWD@"
fi
if [ ! -z "$CREDENTIALS" ]; then
docker login -u "$DOCKER_USER" -p "$DOCKER_PWD" -e "test@email.my" "$DOCKER_REGISTRY"
fi
@zuzkins
zuzkins / om-tools component
Created February 26, 2015 10:27
Om vs om-tools macro
(defn om-component [data owner]
(om-tools/component
(init-state [_} {:counter 1})
(render-state [_ state] (dom/div nil (str "Hello " (:name data) ": " (:counter state))))
(will-unmount [_] (.log js/console "bye"))))
### Keybase proof
I hereby claim:
* I am zuzkins on github.
* I am zuzkins (https://keybase.io/zuzkins) on keybase.
* I have a public key whose fingerprint is DADA D47C 4F70 37A5 AEB6 B546 0E24 4857 7705 9F04
To claim this, I am signing this object:
@zuzkins
zuzkins / WithContentTypeDirective.scala
Last active December 20, 2015 18:39
spray contentType filtering directive
import spray.http._
import shapeless.HNil
import spray.util.pimpSeq
def withContentType(ctStr: String): Directive0 = {
def isContentType(h: HttpHeader) = h match {
case HttpHeaders.`Content-Type`(ContentType(MediaType(mt), _)) ⇒ Some(mt)
case _ ⇒ None
}
extract(_.request.headers.mapFind(isContentType(_))).flatMap[HNil] {
@zuzkins
zuzkins / wpchanger.sh
Created June 22, 2011 11:06
My once lost now found wallpaper changing script for GNOME like desktops (works in Unity too)
#!/bin/bash
export $(xargs -n 1 -0 echo </proc/$(pidof gnome-session)/environ | grep -Z DBUS_SESSION_BUS_ADDRESS=)
#DISPLAY=:0
WALLPAPERS="BIG_WALLPAPER_COLLECTION_DIR"
ALIST=( `ls -w1 $WALLPAPERS` )
RANGE=${#ALIST[@]}
let "number = $RANDOM"
let LASTNUM="`cat $WALLPAPERS/.last` + $number"
let "number = $LASTNUM % $RANGE"
/usr/bin/gconftool-2 -t string -s "/desktop/gnome/background/picture_filename" "$WALLPAPERS/${ALIST[$number]}"