Skip to content

Instantly share code, notes, and snippets.

View mosladil's full-sized avatar

Miroslav Osladil mosladil

View GitHub Profile
@mosladil
mosladil / ajax-with-promise.ts
Created August 25, 2017 07:22 — forked from floriankraft/ajax-with-promise.ts
HTTP Request with Promises in Typescript
getRequest(url: string): Promise<any> {
return new Promise<any>(
function (resolve, reject) {
const request = new XMLHttpRequest();
request.onload = function () {
if (this.status === 200) {
resolve(this.response);
} else {
reject(new Error(this.statusText));
}
@mosladil
mosladil / dedup.py
Created December 2, 2014 14:29
Remove duplicates
#! /usr/bin/python
import os
import sys
import stat
import md5
filesBySize = {}
def walker(arg, dirname, fnames):
@mosladil
mosladil / FbLogin.java
Created December 2, 2014 12:01
FB Login
package cz.osladil.fblogin;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
import com.gargoylesoftware.htmlunit.util.Cookie;
@mosladil
mosladil / viktorCistic.pl
Created December 1, 2014 13:34
Clean inactive users from Kerio Connect mailing list
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use encoding 'utf8';
use Date::Calc qw(Delta_Days);
my $mailLog = '/data/var/lib/kms/logs/mail.log';
my $dbLog = './log.txt';
@mosladil
mosladil / agentMilan.pl
Created December 1, 2014 13:30
Agent Milan
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use encoding 'utf8';
use LWP::Simple;
use XML::RSS;
use Data::Dumper;
use Encode; #qw/encode decode/;
@mosladil
mosladil / README
Last active August 29, 2015 14:10 — forked from rwest/README
These two files should help you to import passwords from mac OS X keychains to 1password.
Assumptions:
1) You have some experience with scripting/are a power-user. These scripts worked for me
but they haven't been extensively tested and if they don't work, you're on your own!
Please read this whole document before starting this process. If any of it seems
incomprehensible/frightening/over your head please do not use these scripts. You will
probably do something Very Bad and I wouldn't want that.
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they
@mosladil
mosladil / stats.pl
Created December 1, 2014 12:41
access log parser
#!/usr/bin/env perl
# use warnings;
# use strict;
die('File not specified') if not $ARGV[0];
open FILE, $ARGV[0] or die $!;
my %months = ();
my ($firstRecord, $lastRecord);
@mosladil
mosladil / getUserTrafficQuota.php
Last active December 18, 2015 02:48
Kerio Control - Get user traffic quota
<?php
/**
* Kerio Control - Sample Application.
*
* STATUS: In progress, might change in the future
*
* This api is currently under development.
* The api is not intended for stable use yet.
* Functionality might not be fully verified, documented, or even supported.
*
<?php
require_once 'src/KerioControlApi.php';
$api = new KerioControlApi('Create user', 'Miroslav Osladil', '1.0');
try {
$session = $api->login('fw.company.local', 'username', 'password');
/* a new user */
$newUser = array(
<?php
require_once 'src/KerioControlApi.php';
$api = new KerioControlApi('Setup Custom HTTP Rule', 'Miroslav Osladil', '1.0');
try {
$session = $api->login('fw.company.local', 'username', 'password');
/* get current http rules */
$result = $api->sendRequest('HttpPolicy.get');