Skip to content

Instantly share code, notes, and snippets.

@johnnybui
johnnybui / index.js
Last active November 15, 2023 11:26
Amazfit GTR 3 Pro Pilots Watch Face (modified for smooth second animation) - Sample script for smooth second - https://amazfitwatchfaces.com/gtr/view/21850 - Modified from chen1092 code
/*
** Modified by Johnny Bui for smooth second hand sweeping,
** credits to chen1092 original code
**
** File originaly generated by tool
** Watch_Face_Editor tool
** watchface js version v1.0.1
** Copyright © CashaCX75. All Rights Reserved
*/
@johnnybui
johnnybui / monitor.sh
Last active March 14, 2020 01:07
Raspberry Pi Raspbian System Monitor Shell Script
#!/bin/bash
cpu=$(vcgencmd measure_clock arm)
core=$(vcgencmd measure_clock core)
h264=$(vcgencmd measure_clock h264)
isp=$(vcgencmd measure_clock isp)
v3d=$(vcgencmd measure_clock v3d)
temp=$(vcgencmd measure_temp)
volt=$(vcgencmd measure_volts core)
ram_free=$(awk '/^Mem/ {print $7}' <(free -h))

Keybase proof

I hereby claim:

  • I am johnnybui on github.
  • I am johnnybui (https://keybase.io/johnnybui) on keybase.
  • I have a public key ASDF4eyB9w0H9aQUS_rk5P93B0XcjzFCij9UyUSm0YXUiAo

To claim this, I am signing this object:

@johnnybui
johnnybui / remove-old-snaps.sh
Created January 17, 2019 02:58
Remove old snap app revisions
#!/bin/sh
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@johnnybui
johnnybui / elasticsearch-scroll.js
Last active February 22, 2022 18:15
Get all documents from Elasticsearch index by scroll method
const elasticsearch = require('elasticsearch');
const esClient = new elasticsearch.Client({
host: 'YOUR ELASTICSEARCH SERVER'
});
/**
* Get all documents of an Elasticsearch index by scroll method
* @param {string} index Index to get documents
* @param {Object} query Querying object
@johnnybui
johnnybui / mysql-backup.sh
Last active November 1, 2018 03:40 — forked from spalladino/mysql-docker.sh
Backup and restore a MySQL database from a running Docker MySQL container
#!/bin/sh
CONTAINER="CONTAINER"
USER="USER"
PASSWORD="PASSWORD"
DATABASE="DATABASE"
FILE="backup.sql"
echo "User: $USER"
if [ -n "$PASSWORD" ]
@johnnybui
johnnybui / docker-compose.yml
Created October 30, 2018 02:57
Docker Compose Elasticsearch and Kibana Server
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.4.2
container_name: elasticsearch
restart: always
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
@johnnybui
johnnybui / app.js
Last active April 14, 2022 21:25
Node.JS - Import Data From Cloud Firestore Into Elasticsearch
const admin = require('firebase-admin');
const elasticsearch = require('elasticsearch');
// Config before running
const CONFIG = {
limit: 1000, // reduce if got Deadline exceeded error
index: 'stock',
type: 'doc',
dev: {
serviceAccountJson: './devServiceAccount.json',