Skip to content

Instantly share code, notes, and snippets.

View anggadarkprince's full-sized avatar

Angga Ari Wijaya anggadarkprince

View GitHub Profile
@anggadarkprince
anggadarkprince / apache-alias.conf
Last active March 1, 2023 04:58
Apache configuration with sub paths that contain other applications: example.com (app1), example.com/warehouse (app2), example.com/sso (app3), example.com/finance (app4), any path except /warehouse, /sso, /finance, will be handled by app1
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin admin@example.com
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
@anggadarkprince
anggadarkprince / backup-shell.sh
Last active July 19, 2019 07:31
Shell script to run mysqldump and gzip them to separate database
#!/bin/bash
folder_name=/home/backup/databases/$(date +%Y)/$(date +%Y%m)/"$(date +%Y-%m-%d)-$(date +%H:%M)"
mkdir -p $folder_name && cd $folder_name
mysql -N -e 'show databases' |
while read dbname;
do
if [ $dbname != "mysql" ] && [ $dbname != "information_schema" ] && [ $dbname != "performance_schema" ] && [ $dbname != "sys" ]
then
mysqldump --complete-insert --routines --triggers --single-transaction "$dbname" > "$dbname".sql;
[[ $? -eq 0 ]] && gzip "$dbname".sql;
@anggadarkprince
anggadarkprince / dynamic_url
Created October 8, 2018 07:40
Dynamic URL
<?php
if (isset($_SERVER['HTTP_HOST']) && $_SERVER["SCRIPT_NAME"]) {
$root = (isset($_SERVER["HTTPS"]) ? "https://" : "http://") . $_SERVER['HTTP_HOST'];
$root = $root . str_replace(basename($_SERVER["SCRIPT_NAME"]), "", $_SERVER["SCRIPT_NAME"]);
} else {
$root = 'localhost/absent';
}
@anggadarkprince
anggadarkprince / sandbox.sql
Last active August 23, 2018 01:55
TCI database
CREATE TABLE `activities` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `activities` VALUES (1,'Act 1'),(2,'Act 2');
CREATE TABLE `activity_details` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@anggadarkprince
anggadarkprince / simple_array.php
Created August 23, 2018 01:48
TCI Structure Data
<?php
$data = [
[
'no_transaction' => '001',
'items' => [
['name' => 'Milk', 'total' => 4],
['name' => 'Coffee', 'total' => 2],
]
],
@anggadarkprince
anggadarkprince / data.php
Created May 29, 2017 08:34
Typeahead Remote
<?php
$data = [
[
'id' => 1,
'title' => 'Alice in wonderland',
'year' => '1993'
],
[
'id' => 2,
@anggadarkprince
anggadarkprince / dynamic_func.php
Last active November 30, 2016 04:03
Dynamic Function
<?php
$words = ['dibawakan', "dimakan", "menangis"];
$list = ['bawa', 'makan'];
$complete = [];
$functions = ['trim_prefix', 'trim_suffix', 'trim_another_affix'];
function trim_prefix($word){
if(preg_match('/^(di|[ks]e)/', $word)){
@anggadarkprince
anggadarkprince / MainActivity.java
Created May 8, 2016 02:53
Android Object Pooling (reservoir)
/**
* Sketch Project Studio
* Created by Angga 20/04/2016 19:32
*/
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@anggadarkprince
anggadarkprince / Validator.java
Last active April 22, 2022 01:33
Android Form Validator Class Helper
package com.sketchproject.infogue.modules;
import android.util.Log;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;
/**
@anggadarkprince
anggadarkprince / AppHelper.java
Last active May 2, 2023 22:39
Upload file with Multipart Request Volley Android
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import java.io.ByteArrayOutputStream;
/**
* Sketch Project Studio
* Created by Angga on 12/04/2016 14.27.
*/
public class AppHelper {