Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Israel Ferrer Camacho rallat

🏠
Working from home
View GitHub Profile
@rallat
rallat / gist:131491722a4b677e8a24353476850812
Created Jun 24, 2019
This script compares the similarity between
View gist:131491722a4b677e8a24353476850812
#!/bin/bash
# This command expects two params.
# First param is the directory of the png.
# Second param is the directory of the webp.
# It will traverse the first directory and compare that file with the same webp in the second directory
# This script requires to download similar script from http://www.fmwconcepts.com/imagemagick/similar/index.php
# and leave it the same directory as this script. This script will be the one leveraging imagemagick
pngDir=$1
webpDir=$2
find $1 -name "*.png" | cut -sd / -f 11- | sed 's/\.png$//1'|while read fname; do
View DetailViewModel.kt
class DetailViewModel : ScopedViewModel() {
fun startTask() {
launch {
// Switch the 'background' thread
withContext(Dispatchers.Default) {
// do your long-running thing
}
// We're now back on the Android's Main thread
updateUi()
@rallat
rallat / gist:b90b1c11def8f728eb6f
Created Dec 15, 2015
Extend TwitterApiClient for fun an profit
View gist:b90b1c11def8f728eb6f
// extend from TwitterApiClient to use the auth
public class DmApiClient extends TwitterApiClient{
public DmApiClient(TwitterSession session) {
super(session);
}
public TimelineService getTimeLineService(){
return this.getService(TimelineService.class);
}
}
// new entrypoint you want to add
View VerifyCredentialsController.scala
package controllers
import play.api.libs.ws.WS
import play.api.mvc.{Action, Controller}
import scala.concurrent.Future
class VerifyCredentialsController extends Controller {
implicit val context = scala.concurrent.ExecutionContext.Implicits.global
@rallat
rallat / gist:849a68520ca10d913aeb
Created Oct 23, 2014
Digits with custom button
View gist:849a68520ca10d913aeb
final AuthCallback authCallback = new AuthCallback() {
@Override
public void success(DigitsSession digitsSession, String s) {
//Success !!
}
@Override
public void failure(DigitsException e) {
//sad :(
}
@rallat
rallat / build.gradle
Last active Nov 16, 2015
release signed apk using gradle
View build.gradle
android {
signingConfigs {
release {
storeFile file("/path/to/keystore")
storePassword "storepassword"
keyAlias "alias"
keyPassword "keypassword"
}
}
buildTypes {
@rallat
rallat / dexmethodcount
Last active Dec 14, 2015
Android Dex Method Count more sophisticated scripts that gives you method cound by package @JakeWharton https://gist.github.com/JakeWharton/6002797 and @tsmith https://gist.github.com/tyvsmith/6056422
View dexmethodcount
You can add this to your shell profile and then use it as dexcount file.
This file should have a classes.dex in order to work, that means it has to be a android lib project or android apk.
count(){
mkdir temp >/dev/null
cp $1 temp/$1+copy > /dev/null
unzip temp/$1+copy -d temp/ > /dev/null
cat temp/classes.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
rm -R temp > /dev/null
}
View gist:2a196edf7186356ff84b
<?php
//number of people in the reservation
$people = 2;
//time, just the hour, pm
$time = 7;
$url = 'http://www.opentable.com/nextavailabletable.aspx?hpu=1025002033&shpu=1&rid=1180&m=4&d=8/13/2010+'.$time.':00:00+PM&p='.$people;
$data = file_get_contents($url);
$regex = '/\[\'\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}\:\d{2}\:\d{2} PM/';