Skip to content

Instantly share code, notes, and snippets.


Tony Vu tonyvu2014

View GitHub Profile
View app.json
"expo": {
"name": "Balsa",
"description": "A super lightweight news feed",
"githubUrl": "",
"sdkVersion": "25.0.0",
"icon": "balsa.png",
"version": "0.1.6",
"slug": "balsa",
"ios": {
View axios.js,
terms: terms,
limit: LIMIT
{ timeout: TIMEOUT }
.then(res => {
console.log('FeedsScreen - loading feeds is done')
View componentDidMount.js
componentDidMount() {
onTabFocus: this.getFeeds
View navigationOptions.js
static navigationOptions = ({ navigation }) => {
const { params } = navigation.state;
return {
tabBarOnPress({ jumpToIndex, scene }) {
View Stack_Tab_Navigator.js
const FeedsStack = StackNavigator({
Feeds: {
screen: FeedsScreen,
navigationOptions: {
title: 'Feeds'
Reader: {
screen: ReaderScreen,
navigationOptions: {
View AsyncStorage_getItem.js
.then(value => {
if (value) {
console.log('PreferencesScreen - preferences:', value)
let terms = []
let prefs = value.split(',')
for (let i = 0; i < prefs.length; i++) {
terms.push({key: i, term: prefs[i]})
this.setState({terms: terms})
tonyvu2014 / send_email.cgi
Created Jul 20, 2015
A perl cgi script to collect and send plain feedback to a list of site admin emails. This script can be used for contact us form, just need to ensure that the form fields match the param names in the script and update the corresponding email addresses. module is required on the server.
View send_email.cgi
use CGI;
# Create a object
my $cgi = new CGI;
# Get the form data
my $email_address = $cgi->param('email');
my $feedback = $cgi->param('message');
my $name = $cgi->param('name');
tonyvu2014 /
Last active Aug 16, 2016
Java program to monitor a web server. To use, type in Monitor <web address> <frequency> <timeout>
public class Monitor {
public static void main(String[] args) throws IOException {
if (args.length < 3)
throw new IllegalArgumentException("Invalid number of arguments");
tonyvu2014 / replication_monitor.sql
Created Apr 17, 2015
Mysql replication monitor and recovery. Set up the cronjob on mysql server (slave side) to run this script daily or weekly to monitor and recover from mysql replication failure. If there is any error an notification email will be sent to the email of your choice.
View replication_monitor.sql
USER=<your mysql username>
PASSWORD=<your mysql password>
SUBJECT="Mysql Replication Problem"
EMAIL=<your monitor email>
RESULT=`mysql -u$USER -p$PASSWORD -e 'show slave status\G' | grep Last_SQL_Error | sed -e 's/ *Last_SQL_Error: //'`
if [ -n "$RESULT" ]; then
echo "$RESULT" | mail -s "$SUBJECT" $EMAIL