Skip to content

Instantly share code, notes, and snippets.

View josemigallas's full-sized avatar

Jose Miguel Gallas Olmedo josemigallas

  • Red Hat
  • Málaga, Spain
View GitHub Profile
@josemigallas
josemigallas / ReducedBitmapFactory.java
Last active June 8, 2016 09:43
Class for decoding a bitmap from a file
public class ReducedBitmapFactory {
public static final int MAX_IMAGE_WIDTH = 1200;
public static final int MAX_IMAGE_HEIGHT = 1200;
public static Bitmap decodeFile(String photoPath) {
BitmapFactory.Options bmOptions = new android.graphics.BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(photoPath, bmOptions);
public class CroppableTextureView extends TextureView implements TextureView.SurfaceTextureListener {
private final int videoRes;
private MediaPlayer player;
private int videoHeight;
private int videoWidth;
public CroppableTextureView(Context context, AttributeSet attrs) {
super(context, attrs);
# Create a folder for WireMock stuff
mkdir wiremock;
cd wiremock;
# Download de standalone version
wget http://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.4.1/wiremock-standalone-2.4.1.jar;
# Create mappings
mkdir mappings;
echo '{ "request": { "url": "/", "method": "GET" }, "response": { "status": 200, "fixedDelayMilliseconds": 500, "body": "Hello WireMock!\n" }}' > mappings/hellofi.json;
@josemigallas
josemigallas / git-clone.sh
Last active June 12, 2017 14:40
Script that clones a repository and adds both remotes origin and upstream, renaming origin with a definde username.
#!/bin/bash
# Definitions
GITHUB_USER=josemigallas
# Verify arguments
if [ -z "$1" ] || [ -z "$2"]; then
echo "Missing forked and upstream repos' urls.
Usage: git-clone <origin> <upstream>"
exit 0
@josemigallas
josemigallas / git-clone.py
Last active June 12, 2017 14:49
This script clones a repository from Github, previously forked, and add both remotes origin and upstream, renaming origin with your username.
#!/usr/bin/python
import sys
from os.path import splitext, basename
from os import system
import re
# Verify arguments
try:
urlForked = sys.argv[1]
We can't make this file beautiful and searchable because it's too large.
#VARIANT ID,TOKEN ALIAS,TOKEN ID
57167989-2e1f-47b6-9a14-cd7c6667f057,c69432c1-2eb8-4f12-86da-be59812dc4f1,f6432ef3-dc99-4f1d-a128-f5f44a3e67a7
57167989-2e1f-47b6-9a14-cd7c6667f057,42aacc11-337b-4771-b134-f49888e8af8d,220b1298-ca36-4041-abcf-2d46fafeeccf
57167989-2e1f-47b6-9a14-cd7c6667f057,3773015b-848b-421d-8ace-92950fb0bc3c,5e7ae44c-cb11-4984-bad1-c0cf78202298
57167989-2e1f-47b6-9a14-cd7c6667f057,8231e289-8216-4680-b02e-020e6d9cb5a4,e745ddd0-3e83-4db7-a968-98eadf2ef271
57167989-2e1f-47b6-9a14-cd7c6667f057,e8185ffb-1948-48dc-8bac-1dfff78807cf,851081bd-6939-4400-b745-c5ea875c3603
57167989-2e1f-47b6-9a14-cd7c6667f057,93277b7b-db59-489f-bb54-aa25941192cb,e0fd3643-882f-41a0-87fe-3920d985a1ad
57167989-2e1f-47b6-9a14-cd7c6667f057,3644e018-6af2-4885-ab44-60127431ecf1,285951f1-170f-43ca-a3f4-499663eb44a8
57167989-2e1f-47b6-9a14-cd7c6667f057,aa6d087a-9676-4fe4-8d42-f1f1a146b0ac,6cb5ec8e-6af6-4995-83d4-b14512122a8b
57167989-2e1f-47b6-9a14-cd7c6667f057,7702cd93-4d93-49b2-b09a-7ebc15f9b7de,d46c1882-e45b-4c24-9844-d1181
@josemigallas
josemigallas / LoadingDialog.java
Created October 5, 2017 15:04
Very cool dialog that blocks the screen, to be used during some asynchronous process preventing user from interacting with the screen.
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
public class LoadingDialog extends DialogFragment {
private static final String ARG_TITLE = "TITLE";
@josemigallas
josemigallas / i18n.js (mocked)
Created January 16, 2019 12:31
Gist exemplifying usage of Jest module mocks, with Flow.
// modules/__mocks__/i18n.js
const i18n = {
t: name => `Bye ${name}!`
}
export default i18n