Skip to content

Instantly share code, notes, and snippets.

View frapontillo's full-sized avatar

Francesco Pontillo frapontillo

View GitHub Profile
@frapontillo
frapontillo / android-demo.sh
Created May 27, 2021 12:52
Turn Android Demo Mode on and off
#!/bin/bash
on() {
adb shell settings put global sysui_demo_allowed 1 > /dev/null
adb shell am broadcast -a com.android.systemui.demo -e command enter > /dev/null
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1000 > /dev/null
adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4 > /dev/null
adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 4 -e datatype lte > /dev/null
adb shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false > /dev/null
adb shell am broadcast -a com.android.systemui.demo -e command battery -e level 100 -e plugged false > /dev/null
@frapontillo
frapontillo / rec-android.sh
Last active September 16, 2021 06:13
Record a video from an Android device
#!/bin/bash
adb shell screenrecord --bit-rate 6000000 /sdcard/$1.mp4 & PID=$!
# Upon a key press
read -p "Press [Enter] to stop recording..."
# Kills the recording process
kill $PID
# Wait for 3 seconds for the device to compile the video
sleep 3
# Download the video
@frapontillo
frapontillo / rec-ios.sh
Last active September 16, 2021 06:14
Record video from an iOS emulator
#!/bin/bash
xcrun simctl io booted recordVideo --codec=h264 "$1".mp4;
@frapontillo
frapontillo / giffify.sh
Last active June 18, 2019 12:28
Record Android screen straight to GIF
#!/bin/bash
if [ -z "$1" ]; then
shot_path=$(date +%Y-%m-%d-%H-%M-%S).mp4
else
shot_path="$*"
fi
# Enable show taps on screen
adb shell content insert --uri content://settings/system --bind name:s:show_touches --bind value:i:1
@frapontillo
frapontillo / RxTest.java
Last active May 23, 2016 17:43
RxJava retryWhen with dynamic delay
package com.novoda.github.reports;
import java.sql.Date;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import rx.Observable;
@frapontillo
frapontillo / install.sh
Last active November 30, 2015 22:01
Crowd Pulse Install Scripts
#!/usr/bin/env bash
# install build tools and node for ubuntu
sudo apt-get update -y
sudo apt-get install -y build-essential
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
cd /opt/
@frapontillo
frapontillo / bump.js
Created November 18, 2015 08:08
Gulp Bump Tasks
'use strict';
var gulp = require('gulp');
var bump = require('gulp-bump')();
var bumpTargets = ['package.json', 'bower.json'];
['major', 'minor', 'patch'].forEach(function (type) {
gulp.task('bump:' + type, function () {
gulp.src(bumpTargets)
@frapontillo
frapontillo / changelog.js
Last active November 18, 2015 08:08
Gulp AngularJS Full Lib Changelog Generation Task
'use strict';
var gulp = require('gulp');
var conventionalChangelog = require('gulp-conventional-changelog');
var transform = function(commit) {
var commitMap = {
'feat': 'Features',
'fix': 'Bug Fixes',
'docs': 'Documentation Changes',
@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 .
@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