Skip to content

Instantly share code, notes, and snippets.

View ondrejmirtes's full-sized avatar

Ondřej Mirtes ondrejmirtes

View GitHub Profile
@ondrejmirtes
ondrejmirtes / github.pub
Created September 5, 2011 07:35
Public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1HU7tOnkxGkEG417gQUGBpIudcaRHRNIymYwRLaYdjYLmgC5ds0aMO1i71Qh/p/AT9877DaDmXZKHQgesypc9Zjcrlz4mTA4WI8oMu14yXU8uoMJg4IJ7VM4ig5ywADUf452y/HDdxRh1XEpAp8tbCGtFYJIUj6KV7sCRl/yTIwzEr29bSQKOh8qJrY2NcCZmwEyP2p8SqZsGQBmZWdWzeVvtxDZRZWOjcUixLvJAsPAIAWL3Bgjonb/TKj+YyIOfjbEZ+ZXceucgjvTnqEaCxeCx/OgKM+bjPjNYwjjxtBRqmHzrZcE7LeLUFCSC9z8dj6SW5MGNcGN4zlQIZr+N ondrej@eduroam-95.felk.cvut.cz
@ondrejmirtes
ondrejmirtes / .bash_profile
Created September 12, 2011 08:18
Git configuration
export PS1="\u:\W $ "
#GIT bash by HABR (modified by Dundee)
export PSORIG="$PS1"
function GITBRANCH() {
BRANCH="$(git branch 2>/dev/null | grep '*' | cut -d" " -f2-)"
if [ -n "$BRANCH" ] ; then
export PS1="\u:\W "
export PS1=$PS1$(echo -en "\[\033[00;37m\]$BRANCH \[\033[00m\]")
<?php
function mb_str_split($string,$string_length=1) {
if(mb_strlen($string) > $string_length || !$string_length) {
do {
$c = mb_strlen($string);
$parts[] = mb_substr($string,0,$string_length);
$string = mb_substr($string,$string_length);
}while(!empty($string));
} else {
@ondrejmirtes
ondrejmirtes / in_array.php
Created May 24, 2012 10:47
PHP WTFs - in_array()
<?php
$keys = array(
'scheme',
'user',
'pass',
'host',
'port',
'path',
'query',
@ondrejmirtes
ondrejmirtes / gist:3129530
Created July 17, 2012 13:59
Array contains item starting with X
<?php
$array = array_filter(array('yx', 'y', 'z'));
$exists = count(array_filter($array, function($item) {
return substr($item, 0, 1) === 'x';
})) > 0;
@ondrejmirtes
ondrejmirtes / gist:3941235
Created October 23, 2012 20:12
textField: shouldChangeCharactersInRange: for decimal keyboard
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (textField == self.amountInput) {
if (string.length == 0) {
return YES; // backspace
}
NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior: NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
@ondrejmirtes
ondrejmirtes / AffiliatePartner.php
Created August 30, 2013 10:20
Doctrine bugreport
/**
* @SuppressWarnings(PHPMD.UnusedPrivateField) using GetSet
* @Entity
*/
class AffiliatePartner extends User
{
/**
* @var string
* @Column
@ondrejmirtes
ondrejmirtes / AnimateSequence.h
Created December 26, 2013 14:02
Animate sequence of animations
#import <Foundation/Foundation.h>
@interface AnimateSequence : NSObject
+ (void)animate:(NSArray*)blocks duration:(NSTimeInterval)duration;
@end
var WebSocketWrapper = function(url) {
this.url = url;
this.registeredFunctions = {};
this.ws = null;
this.retry = true;
};
WebSocketWrapper.prototype.send = function(message) {
this.ws.send(JSON.stringify(message));
}
<?php
use Guzzle\Http\Url;
use Nette\Diagnostics\Debugger;
use Nette\Utils\Strings;
use React\Http\Request;
use React\Http\Response;
use React\SocketClient\ConnectionManager;
use React\Stream\Stream;