Angular 4 download file from server via http

When want to download a file from server, usually just provide a <a href... will do. But what if the file only allow authorised user to access? Means you have to download first, in this case will have to use http

Read More

CefSharp listen to JavaScript event

CefSharp is a Chromium browser embedded to an application.

In my case, I’m using WinForms (CefSharp.WinForms v57.0.0).

Read More

PayPal Rest API with Laravel 5 and Angular

Previously I wrote a post regarding to Integrate PayPal SDK into Laravel 4. And I believe now Laravel 5 is quite different from Laravel 4. Also, PayPal API also updated now.

Read More

Allow Vagrant to access from other computers in LAN network

I’m using Laravel Homestead. By default, the config is set to private network with IP 192.168.10.10.

Read More

How to backup MySQL database from time to time

To backup your database from time to time, this can be done by write a simple shell script, and setup a cron job to run it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash

# config
backup_dir=/path/to/backup/folder
max_backup_files=5
db_host="127.0.0.1"
db_name="my_db"
db_user="root"
db_pass="secret"

if [ ! -d $backup_dir ]; then
mkdir $backup_dir
fi

output_file=$backup_dir/`date +"%Y-%m-%d_%H-%M-%S.sql"`
# the tables data you want to exclude, but keep the structure
excluded_tables=(
ex_table1
ex_table2
ex_table3
)

ignored_tables_string_with_option=''
ignored_tables_string=''
for tbl in "${excluded_tables[@]}"
do :
ignored_tables_string_with_option+=" --ignore-table=${db_name}.${tbl}"
ignored_tables_string+=" ${tbl}"
done

# change this line if you use postgresql
mysqldump $db_name -u $db_user -h $db_host -p$db_pass ${ignored_tables_string_with_option} > $output_file
mysqldump $db_name -u $db_user -h $db_host -p$db_pass ${ignored_tables_string} --no-data >> $output_file

total_sql=`ls -l $backup_dir/*.sql | wc -l`

if [ $total_sql -gt $max_backup_files ]; then
old_file=`ls $backup_dir/*.sql | sort | head -n 1`
echo "Exceed $max_backup_files files, remove $old_file"
rm -f $old_file
fi

Read More

JavaScript class define a callback delegate method

I recently working on a JavaScript project, which required to write class.

Usually I just use 3rd party plugin for most of my project, e.g. jQuery.ajax

Read More

Laravel 5 custom validator

As the official documentation doesn’t specify how exactly to create a custom
validation class.

1. Create custom validator class

You can create in any where as you like. For my example, I will create in
app/Libraries/CustomValidator.php

Read More

Automate WinForm app publish to match NAppUpdate standard

If you’re using NAppUpdate framework to publish your WinForm app, this post is for you.

Assume that you already setup NAppUpdate successfully. Now we want to simplify it to just 1 click publish, and the others clients can just update it

Read More

Setup cronjob &amp; queue in Elastic Beanstalk with Laravel

This is basically part-2 continue from Setup Laravel 5 in Amazon Elastic Beanstalk.

Read More

Python script to simulate multiple concurrent requests to web application

I first created this script to heavy test the web application hosted in elastic beanstalk.

Why python? Just for fun :)

Let’s begin

Read More