Skip to content

Instantly share code, notes, and snippets.

View chetbox's full-sized avatar
🤖
Making da codez

Chetan Padia chetbox

🤖
Making da codez
View GitHub Profile
@chetbox
chetbox / java-to-kotlin-beeline-android.sh
Created December 7, 2017 21:43
Script to automate the majority of the Java to Kotlin conversion fixes for the Beeline Android app
#!/bin/bash
set -e
rm -f $(find app/src -iname "Triple*.java")
JAVA_FILES=$(find app/src -iname "*.java")
EXISTING_KOTLIN_FILES=$(find app/src -iname "*.kt")
for FILE in $JAVA_FILES ; do
<div class="explorometer">
<h2 style="text-align: center; color: #000000; font-weight: bold;">Beeline Explorometer™</h2>
<h2 style="text-align: center; color: #ffffff; font-weight: bold;"><span class="journeys">34,994</span> rides</h2>
<h2 style="text-align: center; color: #ffffff; font-weight: bold;"><span class="distance">313,362</span> km</h2>
</div>
<script src="https://www.gstatic.com/firebasejs/4.5.0/firebase.js"></script>
<script>
firebase.initializeApp({
databaseURL: "https://beeline-e46ed.firebaseio.com"
});
@chetbox
chetbox / firebase-forEachPage.js
Created April 11, 2017 08:17
Page through large collections of data in a Firebase Cloud Function
const _ = require('lodash');
function forEachPage(ref, pageSize, callback, startAt) {
var query = ref.orderByKey();
if (startAt) query = query.startAt(startAt);
return query.limitToFirst(pageSize + 1) // Ask for one extra
.once('value')
.then((snapshot) => {
if (snapshot.numChildren() <= pageSize) {
// There was no extra value returned, this is the last page
@chetbox
chetbox / find-git-authors.sh
Last active August 23, 2016 09:14
Find author names and email addresses from a git repo
#!/bin/bash
set -e
DIR=/tmp/find-git-authors
rm -rf "$DIR"
mkdir -p "$DIR"
git clone --bare "$1" "$DIR" 2> /dev/null
cd "$DIR"
@chetbox
chetbox / README.md
Last active January 20, 2016 12:21
Docker Hub webhook (PHP)

Docker Hub deploy webhook

A ghetto webhook for automatically deploying after a Docker Hub build.

Install (Ubuntu)

sudo apt-get install php-cli
/* Get a value from a nested object using just a string for readability
*
* Example:
* var o = {first: {second: {third: {a: 1, b: 2}}}};
* o.get_in('first.second.third.b'); // => 2
*/
Object.prototype.get_in = function(selector) {
return selector.split('.').reduce(
function(obj, key) {
return obj[key];
@chetbox
chetbox / count_apk_methods.sh
Last active October 22, 2016 16:11
Method count of multidex APK one-liner
apk=app.apk count=0 ; for dex in $(unzip -Z1 $apk classes*.dex); do count=$(($count + $(unzip -p $apk $dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'))) ; done ; echo $count
@chetbox
chetbox / optionally_global.js
Created July 23, 2015 10:20
A node module whose exports can optionally be made global
/*
This module can be required normally:
var optionally_global = require('./optionally_global');
console.log(optionally_global.bar());
Or its exports can be made global:
require('./optionally_global').global();
console.log(bar());
# Emulate a user in a terminal for the purposes of a video recording
# Waits 1 second for every blank line
tell application "Terminal"
activate
end tell
delay 1
tell application "System Events"
@chetbox
chetbox / say_youtube_comments.py
Last active August 29, 2015 14:08
Read YouTube comments from a video out loud
# Code has moved to: https://github.com/chetbox/SayYouTubeComments