Skip to content

Instantly share code, notes, and snippets.

Avatar

Angga Ari Wijaya anggadarkprince

View GitHub Profile
@anggadarkprince
anggadarkprince / backup-shell.sh
Last active Jul 19, 2019
Shell script to run mysqldump and gzip them to separate database
View backup-shell.sh
#!/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;
View 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';
}
View sandbox.sql
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,
View simple_array.php
<?php
$data = [
[
'no_transaction' => '001',
'items' => [
['name' => 'Milk', 'total' => 4],
['name' => 'Coffee', 'total' => 2],
]
],
View data.php
<?php
$data = [
[
'id' => 1,
'title' => 'Alice in wonderland',
'year' => '1993'
],
[
'id' => 2,
View dynamic_func.php
<?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
Android Object Pooling (reservoir)
View MainActivity.java
/**
* 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 Jan 4, 2017
Android Form Validator Class Helper
View Validator.java
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 Oct 12, 2020
Upload file with Multipart Request Volley Android
View AppHelper.java
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 {
You can’t perform that action at this time.