Skip to content

Instantly share code, notes, and snippets.

View kibao's full-sized avatar

Przemysław Piechota kibao

View GitHub Profile
@kibao
kibao / keybase.md
Created March 19, 2019 09:04
keybase.md

Keybase proof

I hereby claim:

  • I am kibao on github.
  • I am kibao (https://keybase.io/kibao) on keybase.
  • I have a public key ASBSEDGosgtEcZUVY8RwdVa-4qK7gu_yqzWjogsI5j3sNAo

To claim this, I am signing this object:

@kibao
kibao / Helper.java
Created March 16, 2017 09:35
Is Application Foreground?
class Helper {
public static boolean isAppForeground(Context context) {
KeyguardManager keyguardManager =
(KeyguardManager) context.getSystemService(KEYGUARD_SERVICE);
if (keyguardManager.inKeyguardRestrictedInputMode()) {
return false;
}
int myPid = Process.myPid();
List<RunningAppProcessInfo> runningAppProcesses =
@kibao
kibao / PageContainer.java
Created November 13, 2016 09:14
PageContainer - Container for fragments based on TabHost & FragmentTabHost. Designed for use with BottomNavigationView
import android.content.Context;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.AttributeSet;
@kibao
kibao / gist:f12ec038a061072c3597
Created January 11, 2016 12:10
Verifying that +kibao is my blockchain ID. https://onename.com/kibao
Verifying that +kibao is my blockchain ID. https://onename.com/kibao
@kibao
kibao / benchmark.php
Last active August 29, 2015 14:01
Compare explode with in_array vs mb_strpos
<?php
define('ITERATIONS', 1000 * 1000);
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
@kibao
kibao / JsonHandler.php
Created October 31, 2013 09:58
JsonHandler for KnpPaginatiorBundle
<?php
namespace Serializer\Handler;
use FOS\RestBundle\View\ViewHandler;
use FOS\RestBundle\View\View;
use Knp\Bundle\PaginatorBundle\Pagination\SlidingPagination;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RouterInterface;
@kibao
kibao / ApiUploadedFile.php
Last active February 22, 2022 15:14
Symfony2 Form Component. Support upload file through API call (e.g. in json, xml, etc.) as base64 encoded content .
<?php
namespace Infun\HttpFoundation\File;
use Symfony\Component\HttpFoundation\File\File;
class ApiUploadedFile extends File
{
public function __construct($base64Content)
@kibao
kibao / README.md
Last active December 20, 2015 20:39
Toogle xdebug command.

Install

cd /usr/bin/local
sudo wget https://gist.github.com/kibao/6192063/raw/529ca3eccda769b3111db42fb28eb4993482875b/xdebug-toggle
sudo chmod +x xdebug-toggle

Usage

sudo xdebug-toggle

@kibao
kibao / gist:5747029
Created June 10, 2013 07:12
InputStream to String
InputStream response;
ByteArrayOutputStream buf = new ByteArrayOutputStream();
int result = response.read();
while(result != -1) {
byte b = (byte)result;
buf.write(b);
result = response.read();
}
System.out.println(buf.toString());
namespace.views.MyWizard = Backbone.Views.extend({
initialize: function() {
_.bindAll(this, 'render', 'wizardMethod');
}
render: function() {
this.wizardMethod();
return this;
},