Skip to content

Instantly share code, notes, and snippets.

View thebestpol's full-sized avatar

Pol Gómez Guerrero thebestpol

  • Barcelona
View GitHub Profile
@thebestpol
thebestpol / 0_reuse_code.js
Created March 7, 2016 13:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@thebestpol
thebestpol / PromotionAlgorithm.java
Last active March 15, 2016 10:33
Algorithm to solve promotion problem
package com.worldline.xcountry.domain.interactor.sale;
import com.worldline.xcountry.domain.model.promotion.Promotion;
import com.worldline.xcountry.domain.model.promotion.PromotionalItem;
import com.worldline.xcountry.domain.model.sale.productdetails.Product;
import com.worldline.xcountry.domain.util.Log;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
@thebestpol
thebestpol / shake.xml
Created March 18, 2016 10:59
Simple accelerated shake animation
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="50"
android:fromXDelta="-5"
android:interpolator="@android:anim/accelerate_interpolator"
android:repeatCount="5"
android:repeatMode="reverse"
android:toXDelta="5" />
@thebestpol
thebestpol / rotate.xml
Created March 18, 2016 11:00
Simple rotate animation
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />
@thebestpol
thebestpol / remove_branches
Created March 21, 2016 14:23
Delete locally already merged branches on develop
$ git checkout develop
$ git branch --merged | grep -v "*" | grep -v -e "[develop|master]" | xargs -n 1 git branch -d
@thebestpol
thebestpol / gifit.sh
Created March 21, 2016 14:28
Pass it a mp4 and you will have a gif
# Description: pass it a mp4 and you will have a gif
# Dependencies: ffmpeg, gifsicle
if [ "$#" -le 1 ]; then
echo "\nUsage: sh gifit.sh <source path to original mp4> <delay between frames>"
echo "Warning! filenames shouldn't contain the extension\n"
exit 1
fi
ffmpeg -i $1.mp4 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=$2 > $1.gif
@thebestpol
thebestpol / KeyInterceptEditText.java
Last active March 22, 2016 10:19
Custom widget, EditText, that intercepts key press events on the IME and calls the method. Provides a function to handle on hide soft input keyboard event.
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.EditText;
/**
* This EditText intercepts key press events on the IME and calls the method.
* <p>
* Provides a function to handle on hide soft input keyboard event.
*/
@thebestpol
thebestpol / Log.java
Created March 22, 2016 10:13
Class to print logs friendly
/**
* Class to print logs friendly
*/
public class Log {
/**
* @return the current thread name and id
*/
public static String getThreadName() {
String name = Thread.currentThread().getName() + "(" + Thread.currentThread().getId() + ")";
@thebestpol
thebestpol / source_code_packaging.sh
Created March 22, 2016 10:29
Script to make source code packaging easily
#!/bin/bash
# File: source_code_packaging.sh
# Script to generate the source code packaged for the client.
date=`date "+%Y_%m_%d"`;
commit=`git log -n 1 HEAD --format=%h`;
zip -9 -r "${date}_Android_source_code_${commit}.zip" \
.gradle/ \
.idea/ \
build.gradle \
@thebestpol
thebestpol / README
Created March 22, 2016 10:40
Icon tools: scripts to add a badge in the icon of an application. It's a good way to identify different types of builds, releases, etc to make easier the delivery to the client, testing, etc ASKME for the badges in .pdf format
HOW TO USE:
Parameters:
inputfile -- path to original file with extension
budget -- [debug, test, pilot, rc, rcg]
dimension -- dimension in number for generate output file
platform -- [ios, android]
outputfile -- path to outpuf file with extension
Example: