Skip to content

Instantly share code, notes, and snippets.

View tatocaster's full-sized avatar
🇺🇦

Merab Tato Kutalia tatocaster

🇺🇦
View GitHub Profile
@tatocaster
tatocaster / MyApplication.java
Last active April 30, 2017 08:45
MyApplication class for Litho
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, false);
}
}
@tatocaster
tatocaster / app.gradle
Created April 30, 2017 08:41
gradle dependencies for litho
dependencies {
// ...
// Litho
compile 'com.facebook.litho:litho-core:0.2.0'
compile 'com.facebook.litho:litho-widget:0.2.0'
provided 'com.facebook.litho:litho-annotations:0.2.0'
annotationProcessor 'com.facebook.litho:litho-processor:0.2.0'
// SoLoader
@tatocaster
tatocaster / DeCryptor.java
Created February 21, 2017 07:43 — forked from JosiasSena/DeCryptor.java
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/
@tatocaster
tatocaster / troubleshooting.md
Created January 30, 2017 20:50 — forked from adamwathan/troubleshooting.md
Troubleshooting Valet on macOS Sierra

Troubleshooting Valet on Sierra

Common Problems

Problem: I just see "It works!"

Apache is running on port 80 and interfering with Valet.

  1. Stop Apache: sudo /usr/sbin/apachectl stop
  2. Restart Valet: valet restart
@tatocaster
tatocaster / PermissionUtils.java
Created May 15, 2016 11:18
Utility class for access to runtime permissions.
/**
* Utility class for access to runtime permissions.
*/
public abstract class PermissionUtils {
/**
* Requests the fine location permission. If a rationale with an additional explanation should
* be shown to the user, displays a dialog that triggers the request.
*/
public static void requestPermission(AppCompatActivity activity, int requestId,
@tatocaster
tatocaster / http_status_codes.php
Created April 22, 2016 12:25
HTTP status codes as an PHP array
<?php
$http_status_codes = [100 => "Continue", 101 => "Switching Protocols", 102 => "Processing", 200 => "OK", 201 => "Created", 202 => "Accepted", 203 => "Non-Authoritative Information", 204 => "No Content", 205 => "Reset Content", 206 => "Partial Content", 207 => "Multi-Status", 300 => "Multiple Choices", 301 => "Moved Permanently", 302 => "Found", 303 => "See Other", 304 => "Not Modified", 305 => "Use Proxy", 306 => "(Unused)", 307 => "Temporary Redirect", 308 => "Permanent Redirect", 400 => "Bad Request", 401 => "Unauthorized", 402 => "Payment Required", 403 => "Forbidden", 404 => "Not Found", 405 => "Method Not Allowed", 406 => "Not Acceptable", 407 => "Proxy Authentication Required", 408 => "Request Timeout", 409 => "Conflict", 410 => "Gone", 411 => "Length Required", 412 => "Precondition Failed", 413 => "Request Entity Too Large", 414 => "Request-URI Too Long", 415 => "Unsupported Media Type", 416 => "Requested Range Not Satisfiable", 417 => "Expectation Failed", 418 => "I'm a teapot", 419 => "Authenti
@tatocaster
tatocaster / speedtest.js
Created April 8, 2016 21:13
speedtest.js
(function() {
var imageAddr = "https://upload.wikimedia.org/wikipedia/commons/2/2d/Snake_River_%285mb%29.jpg";
var downloadSize = 5245329; //bytes
var oProgress = document.getElementById("speed");
function ShowProgressMessage(msg) {
if (console) {
if (typeof msg == "string") {
console.log(msg);
} else {
@tatocaster
tatocaster / checkSpeed.js
Last active April 22, 2016 12:30
check network speed.
function checkSpeed(){
var start_time = Date.now();
var fileSizeCall = $.ajax({
type: "HEAD",
url: "//tatocaster.me/20MB.zip",
success: function(msg){
// 1sec == 1000ms .
var timeSecs = Math.round((Date.now() - start_time)+3)/100;
//1mbps == 1000kbps
var sizeMB = fileSizeCall.getResponseHeader('Content-Length')/1000000;
@tatocaster
tatocaster / RxBus.java
Created November 13, 2015 11:19
RxBus singleton
public class RxBus {
private static RxBus instance = null;
private final Subject<Object, Object> _bus = new SerializedSubject<>(PublishSubject.create());
private static RxBus getInstance() {
if (instance == null) {
instance = new RxBus();
}
return instance;
}
@tatocaster
tatocaster / RealPathUtil.java
Last active May 5, 2024 16:59
Real Path Utility class for Android, works for all API
public class RealPathUtil {
public static String getRealPath(Context context, Uri fileUri) {
String realPath;
// SDK < API11
if (Build.VERSION.SDK_INT < 11) {
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri);
}
// SDK >= 11 && SDK < 19
else if (Build.VERSION.SDK_INT < 19) {