Skip to content

Instantly share code, notes, and snippets.

View frapontillo's full-sized avatar

Francesco Pontillo frapontillo

View GitHub Profile
@frapontillo
frapontillo / mongodb-install.bat
Created December 4, 2014 22:28
MongoDB Batches for Windows
mkdir %~dp0data\db
mkdir %~dp0log
echo logpath=%~dp0log\mongo.log >> "%~dp0mongod.cfg"
echo dbpath=C:\mongodb\data\db >> "%~dp0mongod.cfg"
sc.exe create MongoDB binPath= "\"%~dp0bin\mongod.exe\" --service --config=\"%~dp0mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
net start MongoDB
pause
@frapontillo
frapontillo / make-gif.sh
Created March 18, 2015 22:31
Make (good) GIFs w/ ffmpeg
#!/bin/sh
# originally from http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
palette="palette.png"
filters="fps=15,scale=320:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
rm $palette
@frapontillo
frapontillo / video-for-web.sh
Last active August 29, 2015 14:17
Convert videos for the Web (H264/VP8)
#!/bin/sh
mp4="-threads 16 -strict -2 -c:v libx264 -c:a aac -f mp4"
webm="-threads 16 -map 0 -c:v libvpx -qmin 0 -qmax 50 -crf 5 -b:v 5M -c:a libvorbis -c:s webvtt -f webm"
ffmpeg -i $1 \
$mp4 -vf scale=-2:1080 $2-1080.mp4 \
$webm -vf scale=-2:1080 $2-1080.webm \
$mp4 -vf scale=-2:720 $2-720.mp4 \
$webm -vf scale=-2:720 $2-720.webm \
@frapontillo
frapontillo / CustomRecyclerViewAdapter.java
Last active August 31, 2019 13:28
How to use SwitchCompat inside a RecyclerView item
// omissis
@Override
public void onBindViewHolder(final CustomViewHolder holder, final int position) {
holder.mSwitch.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, final boolean isChecked) {
// TODO: handle your switch toggling logic here
}
@frapontillo
frapontillo / pipeline
Last active August 29, 2015 14:22
crowd-pulse pipeline
+-----------------+
| |
| Observable<A> |
| |
+--------+--------+
|
|
+--------v--------+
| |
| Observable<A> |
@frapontillo
frapontillo / gulp-conventional-changelog.js
Created June 30, 2015 08:44
gulp-conventional-changelog
var gulp = require('gulp');
var conventionalChangelog = require('conventional-changelog');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var addsrc = require('gulp-add-src');
var concat = require('gulp-concat');
/**
* Creates a `changelog` task, that will process all commits from the latest tag
* and generates a CHANGELOG.md file by appending the old contents to it.
@frapontillo
frapontillo / android-update.sh
Last active August 29, 2015 14:27
Android SDK CLI Update
root@b700d288820c:/opt# android list sdk --extended --all
Refresh Sources:
Fetching https://dl.google.com/android/repository/addons_list-2.xml
Validate XML
Parse XML
Fetched Add-ons List successfully
Refresh Sources
Fetching URL: https://dl.google.com/android/repository/repository-11.xml
Validate XML: https://dl.google.com/android/repository/repository-11.xml
Parse XML: https://dl.google.com/android/repository/repository-11.xml
@frapontillo
frapontillo / upsource-load-balancer.yaml
Last active August 29, 2015 14:27
Multiple pods on same cluster/port
apiVersion: v1
kind: Service
metadata:
labels:
name: upsource-service
name: upsource-service
spec:
type: LoadBalancer
ports:
- # The port that this service should serve on.
@frapontillo
frapontillo / Dockerfile
Last active October 25, 2015 14:01
Android on Docker
FROM frapontillo/java:7
MAINTAINER Francesco Pontillo <francescopontillo@gmail.com>
WORKDIR /opt/
RUN wget http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz
RUN tar -xvf android-sdk_r24.3.4-linux.tgz
RUN mv android-sdk-linux android-sdk && \
rm android-sdk_r24.3.4-linux.tgz
ENV ANDROID_HOME /opt/android-sdk
@frapontillo
frapontillo / README.md
Last active August 29, 2015 14:27
Weird Twitter Search behavior

Description: with a search query containing the word "abdullah" (not for any different word so far), the Twitter Search API stops returning results after a few elements.

You can test this behavior with the attached NodeJS script (edit the config.json file and set your OAuth bearer token there). Try to launch the following command and observe the output:

$ node twitter-search.js
Retrieved 100 elements so far. Going on, last date was Tue Aug 18 23:55:12 +0000 2015 .
Retrieved 200 elements so far. Going on, last date was Tue Aug 18 23:51:16 +0000 2015 .
Retrieved 300 elements so far. Going on, last date was Tue Aug 18 23:47:42 +0000 2015 .