Skip to content

Instantly share code, notes, and snippets.

@trankimvu
trankimvu / DynamicallyColoredBarChartWithLabel.java
Created October 20, 2016 02:58 — forked from jewelsea/DynamicallyColoredBarChartWithLabel.java
Colors the the bars in a JavaFX BarChart depending upon the value of each bar's data.
import javafx.application.Application;
import javafx.beans.value.*;
import javafx.geometry.Bounds;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.chart.*;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
@trankimvu
trankimvu / visor-archivos-online.md
Created December 15, 2017 16:19 — forked from izazueta/visor-archivos-online.md
Google Docs Viewer & Office Web Apps Viewer

Google Docs Viewer

Only files under 25 MB can be previewed with the Google Drive viewer.

Google Drive viewer helps you preview over 16 different file types, listed below:

  • Image files (.JPEG, .PNG, .GIF, .TIFF, .BMP)
  • Video files (WebM, .MPEG4, .3GPP, .MOV, .AVI, .MPEGPS, .WMV, .FLV)
  • Text files (.TXT)
  • Markup/Code (.CSS, .HTML, .PHP, .C, .CPP, .H, .HPP, .JS)
  • Microsoft Word (.DOC and .DOCX)
@trankimvu
trankimvu / README.md
Created December 28, 2017 16:25 — forked from jehaby/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
#!/bin/bash
# Remote all exited container
docker rm $(docker ps -q -f status=exited)
# Remote none tag images (image with tag <none>)
docker images | grep "<none>" | awk '{print $3}' |xargs docker rmi -f
# Remove all images that is not using by any running container
# note: docker ps --format {{.Image} -> List all images of running container then set it as grep pattern
truncate -s 0 /var/lib/docker/containers/*/*-json.log
# Short script to quick create swapfile on ubuntu
sudo fallocate -l 4G /swapfile && \
sudo chmod 600 /swapfile && \
sudo mkswap /swapfile && \
sudo swapon /swapfile
@trankimvu
trankimvu / list-files-from-n-biggest-directories.sh
Last active June 25, 2018 02:16
How to list files from n biggest directories?
#https://askubuntu.com/questions/898104/how-to-list-files-from-n-biggest-directories
du -hs */ | sort -rh | head -5 | while read -r size dir ; do echo "$dir"; ls -lha "$dir"; done
#accepted
#There are two types of file access that use disk space, but don't show up with your tools: deleted (but still open) files, and files being written to.
#I have these two aliases defined that I find very useful:
# from http://www.certpal.com/blogs/2010/12/find-open-files-in-linux-using-lsof/
alias bigopenfiles="sudo lsof / | awk '{if(\$7 > 1048576) print \$7/1048576 \"MB\" \" \" \$9 }' | sort -n -u"
@trankimvu
trankimvu / postgres_dump_and_restore.sh
Last active June 29, 2018 05:10
postgres dump and restore.sh
pg_dump --file=./dbname.20180626.tar --if-exists --clean --dbname=dbname --format=t --username=hyperloop --host=localhost --port=5432
pg_restore --dbname=dbname --clean --if-exists --single-transaction --username=hyperloop --host=localhost --port=5432 ./dbname.20180626.tar
pg_dump postgres://username:password@ec2-00-00-100-100.eu-west-1.compute.amazonaws.com:5432/databasename
#Optionally you can add -f filename to specify a local filename.
@trankimvu
trankimvu / mysql-docker.sh
Created July 24, 2018 12:48 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@trankimvu
trankimvu / install-docker-and-docker-compose.sh
Last active July 27, 2018 15:18 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"