Skip to content

Instantly share code, notes, and snippets.

View clasense4's full-sized avatar
🎯
Focusing

Fajri Abdillah clasense4

🎯
Focusing
View GitHub Profile
@clasense4
clasense4 / gist:9032552
Created February 16, 2014 11:04
Install scrapy 0.18.4 on centos6.5 Python 2.6.6
yum install libxml2-devel
yum install libxslt-devel
yum install python-devel
pip install MySQL-python
pip install scrapy==0.18.4
@clasense4
clasense4 / client_upload.php
Last active August 29, 2015 13:57
File Upload Saving dapodik
<?php
/**
* Client Side Upload
* AT : Server VPS Nufaza CloudKilat
* IP : 103.23.20.154
* PATH : /var/www/adminer/upload.php
*/
set_time_limit(600);
$file_name_with_full_path = realpath('./tesfile.txt');
// echo $file_name_with_full_path;
protected function addForeignKeys(Table $table)
{
$database = $table->getDatabase();
$stmt = $this->dbh->query("SELECT ccu1.TABLE_NAME, ccu1.COLUMN_NAME, ccu2.TABLE_NAME AS FK_TABLE_NAME, ccu2.COLUMN_NAME AS FK_COLUMN_NAME, ccu1.CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu1 INNER JOIN
INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc1 ON tc1.CONSTRAINT_NAME = ccu1.CONSTRAINT_NAME AND
CONSTRAINT_TYPE = 'Foreign Key' INNER JOIN
INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1 ON rc1.CONSTRAINT_NAME = tc1.CONSTRAINT_NAME INNER JOIN
INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu2 ON ccu2.CONSTRAINT_NAME = rc1.UNIQUE_CONSTRAINT_NAME
@clasense4
clasense4 / candy_tutorial.md
Last active August 29, 2015 14:05
Install Candy (Realtime Chat)
<?php
/* * **
*
* This script converts an existing MySQL database to migrations in Laravel 4.
*
* 1. Place this file inside app/controllers/
*
* 2. In this file, edit the index() method to customize this script to your needs.
* - inside $migrate->ignore(), you pass in an array of table
@clasense4
clasense4 / mysql_csv.md
Created December 1, 2014 09:48
MySQL Insert Data from CSV

Intro

Well, for hours i have been so frustated why my insert file does not work, so this is the solution.

I use MariaDB 10.0.14

LOAD DATA local INFILE "/tmp/pengguna.csv"  INTO TABLE pengguna_dapodik_tokudb FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\r\n' ( `username`, `password`, `nama`, `sekolah_id`, `sekolah_nama`, `kabupaten_kota_id`, `kabupaten_kota_nama`, `propinsi_id`, `propinsi_nama` );
@clasense4
clasense4 / instruction.md
Created December 3, 2014 01:16
Simple Nginx maintenance script

Simple Nginx Maintenance Script

Well, I'm too lazy to doing some command just for change the configuration, here is the script. The logic is simple, change app port from 80 into 8313, and make the port 80 maintenance. And to revert it, change app port from 8313 into 80, and make the maintenance.conf disable by change it into extension .confs.

To use it, make sure the filename just look like below, and then chmod a+x *.sh. Then ./maintenance.sh to make it maintenance mode or ./demaintenance.sh to revert.

maintenance.sh

#!/bin/bash
# @name     : Maintenance script for CRM App

sysbench result

[root@sim2-p2tk ~]# time sysbench --test=/usr/share/doc/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=250000 --mysql-user=testdb --mysql-password=testpw --mysql-socket=/var/lib/mysql/mysql.sock prepare
sysbench 0.5:  multi-threaded system evaluation benchmark

Creating table 'sbtest1'...
Inserting 250000 records into 'sbtest1'

real    0m11.455s
user    0m3.805s
@clasense4
clasense4 / backup.sh
Created June 16, 2015 23:10
Simple backup file use it with crontab
#!/bin/sh
now="$(date +'%Y_%m_%d_%H_%M')"
filename_app="CRM_APP_$now".tar.gz
filename_db="CRM_DB_$now".sql.gz
backupfolder="/home/backup"
backupfolder_app="/var/www/website"
fullpathbackupfile_db="$backupfolder/$filename_db"
fullpathbackupfile_app="$backupfolder/$filename_app"
# execute mysql
mysqldump -u user -pPasswd -h xxx.xxx.xxx.xxx databases | gzip -9 > "$fullpathbackupfile_db"