Skip to content

Instantly share code, notes, and snippets.

@jorgevila
jorgevila / ssl.java
Created October 23, 2017 14:49
Trust every one
private void trustEveryone() {
try {
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new X509TrustManager[]{new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain,
String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain,
String authType) throws CertificateException {
@jorgevila
jorgevila / git-remove-dir.txt
Created October 17, 2017 09:55
Git remove directory in history
# Make a fresh clone of YOUR_REPO
git clone YOUR_REPO
cd YOUR_REPO
# Create tracking branches of all branches
for remote in `git branch -r | grep -v /HEAD`; do git checkout --track $remote ; done
# Remove DIRECTORY_NAME from all commits, then remove the refs to the old commits
# (repeat these two commands for as many directories that you want to remove)
git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch DIRECTORY_NAME/' --prune-empty --tag-name-filter cat -- --all
@jorgevila
jorgevila / Log.kt
Last active August 16, 2017 10:15
kotlin
@file:JvmName("Log")
package ....
import java.text.SimpleDateFormat
import java.util.*
const val TAG = "TAG"
const val FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
private var enabled = true
@jorgevila
jorgevila / MemoizationSingleTransformer
Created June 13, 2017 14:49
Memoization single transformer
class MemoizationSingleTransformer<T : Expirable>(val expiration: Long) : SingleTransformer<T,
T> {
private val TAG: String? = MemoizationSingleTransformer::class.simpleName;
var value: T? = null
override fun apply(upstream: Single<T>): SingleSource<T>? {
val memory = Single.fromCallable {
value ?: Expirable().expire()
@jorgevila
jorgevila / StateMachine
Created February 21, 2017 12:55 — forked from elandau/StateMachine
Rx based state machine
package com.netflix.experiments.rx;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.Observable;
import rx.Observable.OnSubscribe;
@jorgevila
jorgevila / proxy2.py
Created December 5, 2016 16:15
python proxy
# -*- coding: utf-8 -*-
import sys
import os
import socket
import ssl
import select
import httplib
import urlparse
import threading
import gzip
@jorgevila
jorgevila / i18ncontextwrapper
Created October 24, 2016 13:23
i18n context wrapper
package com.pdi.mca.go;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.util.DisplayMetrics;
@jorgevila
jorgevila / Oauth1SigningInterceptor.java
Created June 16, 2016 12:46 — forked from JakeWharton/Oauth1SigningInterceptor.java
An OkHttp interceptor which does OAuth1 signing. Requires Guava and Java 8, although those dependencies wouldn't be too hard to break if you didn't have them.
/*
* Copyright (C) 2015 Jake Wharton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jorgevila
jorgevila / LA_SERVER.py
Last active April 21, 2016 10:44
Get License URL from Manifest
import base64
a=<ProtectionHeader...>
b=a.decode("base64")
b
#Remove 10 first bytes related to size, etc
c=b[10:]
c
#decode as utf-16
d=c.decode("utf-16")
d
@jorgevila
jorgevila / genymotionwithplay.txt
Created April 4, 2016 13:47 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)