Skip to content

Instantly share code, notes, and snippets.

View MartinSadovy's full-sized avatar

Martin Sadovy MartinSadovy

View GitHub Profile
<?php
/**
* @see api: https://github.com/bahbka/pebble-my-data/blob/master/README.md
* @author Martin Sadový
*/
class Pebble
{
/**
* Font
<?php
require 'Nette/loader.php';
require 'stringFluent.php';
$string = string("ahoj já jsem petr")->capitalize();
echo $string."\n";
echo $string->webalize();
@MartinSadovy
MartinSadovy / live-form-validation.js
Created August 8, 2012 12:18 — forked from redhead/live-form-validation.js
Live Form Validation for Nette 2.0
/**
* Live Form Validation for Nette 2.0
*
* @author Radek Ježdík, MartyIX, David Grudl, Martin Sadový
*/
var LiveForm = {
options: {
controlErrorClass: 'form-control-error',
errorMessageClass: 'form-error-message',
validMessageClass: 'form-valid-message',
<?php
// Happy birthday Tom
class Tom extends Person{
public function runBirthday(){
$this->age++;
if($this->age == 18){
$this->acl->allow('doing own decisions');
@MartinSadovy
MartinSadovy / localEncoding.php
Last active December 12, 2015 12:28
Windows uses the local character encoding (cp125*) for file and directory name.
<?php
function utf8ToLocalEncoding($s) {
if (substr(PHP_OS, 0, 3) === 'WIN') {
$tmp = explode(".", setlocale(LC_CTYPE, 0));
if (isset($tmp[1]) && is_numeric($tmp[1]))
$s = @iconv("UTF-8", "cp" . $tmp[1] . "//TRANSLIT", $s);
}
return $s;
}
@MartinSadovy
MartinSadovy / gist:6760392
Created September 30, 2013 07:25
google chrome - win8 mode to desktop
Remove this registr:
HKLM\Software\Classes\ChromeHTML\open\command\DelegateExecute
HKLM\Software\Classes\Chrome
@MartinSadovy
MartinSadovy / blebeacon.sh
Last active October 9, 2016 16:57 — forked from gbirke/ibeacon.sh
Init script for iBeacon
#!/bin/sh
### BEGIN INIT INFO
# Provides: blebeacon
# Required-Start: $bluetooth
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop Bluetooth iBeacon
### END INIT INFO
#!/bin/sh
# pacman -Sy easy-rsa
# EasyRSA 3.0 + http://www.stj.me/2016/02/17/openvpn-ddwrt.html
# run as ROOT!
echo "set_var EASYRSA_DN \"org\"" >> vars
CLIENT_OUT_DIR="/home/sodae/keys-openvpn/"
@MartinSadovy
MartinSadovy / README.md
Last active September 1, 2017 18:22
lpass: search in show

Interactive console LastPass

Usage: lps [keyword]

Then it asks you to copy or show password:

  • if you want to copy, write that number before name of entry
  • if you want show the password, show [number] (or s [number], or s[number])
@MartinSadovy
MartinSadovy / RecursiveWatchService.kt
Last active October 23, 2017 15:46
Using Java WatchService in recursive. Classic WatchService provides only file name without path, this provides absolute path
package cz.sodae.utils
import java.nio.file.*
import java.nio.file.attribute.BasicFileAttributes
import java.util.concurrent.ConcurrentHashMap
interface RecursiveWatchServiceListener {
fun onCreate(path: Path)
fun onModify(path: Path)