Skip to content

Instantly share code, notes, and snippets.

@ogiba
ogiba / gist:5596756538a9d918bb9d31741c89fab6
Created April 3, 2020 12:46 — forked from khakimov/gist:3558086
Matrix Effect in you terminal
echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|awk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
@ogiba
ogiba / updateUrl.js
Created November 10, 2018 22:29
Simple update url method (still need some improvements)
function updateURL() {
if (history.pushState) {
var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?para=hello';
window.history.pushState({path:newurl},'',newurl);
}
}
@ogiba
ogiba / build.gradle
Created October 29, 2018 21:31
PowerMock-Kotlin-Config
dependencies {
testImplementation "junit:junit:4.12"
testImplementation "org.mockito:mockito-core:2.15.0"
testImplementation "io.kotlintest:kotlintest:2.0.7"
testImplementation 'org.powermock:powermock-module-junit4-rule:2.0.0-beta.5'
testImplementation 'org.powermock:powermock-core:2.0.0-beta.5'
testImplementation 'org.powermock:powermock-module-junit4:2.0.0-beta.5'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.0-beta.5'
}
@ogiba
ogiba / Dockerfile
Created October 9, 2018 21:06 — forked from jcavat/Dockerfile
docker-compose with php/mysql/phpmyadmin/apache
FROM php:7.1.2-apache
RUN docker-php-ext-install mysqli
public class RequestRetryingHelper implements InternetConnectionListener, RetryableRequest.OnRetryCalledListener {
private boolean receiverPaused;
private NetworkConnectionBroadcastReceiver networkConnectionBroadcastReceiver;
private final ArrayList<RetryableRequest> retryables = new ArrayList<>();
private MessageCallback messageCallback;
public void onResume(@Nullable Context context) {
if (networkConnectionBroadcastReceiver != null) {
registerNetworkReceiver(context);
}
@ogiba
ogiba / KeyboardUtils.java
Created October 3, 2018 19:01
Method that allows to listen on show/hide keyboard event
public class KeyboardUtils {
public static Observable<KeyboardStatus> status(Activity activity) {
Observable<KeyboardStatus> observable = Observable.create(emitter -> {
if (emitter.isDisposed()) {
return;
}
View rootView = activity.findViewById(android.R.id.content);
ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener = () -> {
@ogiba
ogiba / ViewController.swift
Created August 13, 2018 21:10
UITableView Endless Scroll
var fetchingMore = false
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offsetY = scrollView.contentOffset.y
let contentHeight = scrollView.contentSize.height
if offsetY > contentHeight - scrollView.frame.height * 4 {
if !fetchingMore {
beginBatchFetch()
}
@ogiba
ogiba / list.html.twig
Created January 9, 2018 19:48 — forked from tentacode/list.html.twig
Twig recursive macro
{% macro recursiveCategory(category) %}
<li>
<h4><a href="{{ path(category.route, category.routeParams) }}">{{ category }}</a></h4>
{% if category.children|length %}
<ul>
{% for child in category.children %}
{{ _self.recursiveCategory(child) }}
{% endfor %}
</ul>
@ogiba
ogiba / http_response_code.php
Created January 9, 2018 19:40 — forked from ewwink/http_response_code.php
PHP Class for HTTP Response Status Codes
<?php
/**
* StatusCodes provides named constants for
* HTTP protocol status codes. Written for the
* Recess Framework (http://www.recessframework.com/)
*
* @author Kris Jordan
* @license MIT
* @package recess.http
*