Skip to content

Instantly share code, notes, and snippets.

Avatar

Ondřej Mirtes ondrejmirtes

View GitHub Profile
View mb_str_split.php
<?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 {
View WebSocketWrapper.js
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));
}
View BooleanInBooleanAndRule.php
<?php declare(strict_types = 1);
namespace Slevomat\PHPStan\Rules;
class BooleanInBooleanAndRule implements \PHPStan\Rules\Rule
{
public function getNodeType(): string
{
return \PhpParser\Node\Expr\BinaryOp\BooleanAnd::class;
View keybase.md

Keybase proof

I hereby claim:

  • I am ondrejmirtes on github.
  • I am ondrejmirtes (https://keybase.io/ondrejmirtes) on keybase.
  • I have a public key whose fingerprint is 19AB 1FB8 9EF5 88C9 6EF0 A00B 8E73 0BA2 5823 D8B5

To claim this, I am signing this object:

View relaycon.md

RelayCon 2016

I came to my first WWDC for two reasons: to experience the event first-hand and to meet my favourite blogging and podcaster heroes. I've been following the Apple community for about five years now so I finally decided it will be worth it to fly across the globe from Prague, Czech Republic to San Francisco.

I looked forward to RelayCon a lot and managed to get a ticket. It was great to meet all of the people I let talk to my ears so many hours every week!

I met Russell Ivanovic and talked to him for quite a while. I found our conversation so immersive that it almost felt like we're doing a podcast together. I also made a couple of friends who are not celebrities in this community.

I also introduced myself and talked to: David Smith, David Sparks, Daniel Jalkut, Ben Brooks, Craig Hockenberry and Federico Viticci. But I was looking forward the most to meet the hosts of my favo(u)rite podcast: ATP.

View PromiseTimer.php
<?php declare(strict_types = 1);
class PromiseTimer
{
/** @var \React\EventLoop\LoopInterface */
private $loop;
public function __construct(\React\EventLoop\LoopInterface $loop)
{
@ondrejmirtes
ondrejmirtes / AnimateSequence.h
Created Dec 26, 2013
Animate sequence of animations
View AnimateSequence.h
#import <Foundation/Foundation.h>
@interface AnimateSequence : NSObject
+ (void)animate:(NSArray*)blocks duration:(NSTimeInterval)duration;
@end
View AffiliatePartner.php
/**
* @SuppressWarnings(PHPMD.UnusedPrivateField) using GetSet
* @Entity
*/
class AffiliatePartner extends User
{
/**
* @var string
* @Column
@ondrejmirtes
ondrejmirtes / gist:3941235
Created Oct 23, 2012
textField: shouldChangeCharactersInRange: for decimal keyboard
View gist:3941235
-(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 / gist:3129530
Created Jul 17, 2012
Array contains item starting with X
View gist:3129530
<?php
$array = array_filter(array('yx', 'y', 'z'));
$exists = count(array_filter($array, function($item) {
return substr($item, 0, 1) === 'x';
})) > 0;