Skip to content

Instantly share code, notes, and snippets.

View yrsdi's full-sized avatar
👋
Hi

Yadi Rosadi yrsdi

👋
Hi
View GitHub Profile
@yrsdi
yrsdi / my.cnf
Created August 29, 2018 01:44 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on cPanel/WHM servers)
# Optimized my.cnf configuration for MySQL/MariaSQL on cPanel/WHM servers
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# === Updated July 2018 ===
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
@yrsdi
yrsdi / install_golang_centos7.md
Last active June 29, 2018 01:59
Install golang on Centos 7

download latest version https://golang.org/dl/

wget https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz
tar xzvf go1.7.linux-amd64.tar.gz

extract file and install

sudo tar -C /usr/local -xvzf go1.7.linux-amd64.tar.gz
@yrsdi
yrsdi / mysql-analyze-all-tables.sh
Created May 25, 2018 07:16 — forked from tony4d/mysql-analyze-all-tables.sh
Analyze all tables in a mysql database from the command line (bash)
#!/bin/bash
# To avoid doing things like putting your mysql password on the cli which is not secure
# Use mysql config editor http://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html
for table in $(mysql --login-path=mylogins -D database_name -Bse "show tables");
do mysql --login-path=mylogins -D database_name -Bse "analyze table $table";
done
@yrsdi
yrsdi / postgres-import-export-csv.md
Last active September 28, 2018 03:12 — forked from nepsilon/postgres-import-export-csv.md
Importing and Exporting CSV files with PostgreSQL — First published in fullweb.io issue #19

Importing and exporting CSV files with PostgreSQL

Let’s see how to use PostgreSQL to import and export CSV files painlessly with the COPY command.

Import CSV into table t_words:

COPY t_words FROM '/path/to/file.csv' DELIMITER ',' CSV;

You can tell quote char with QUOTE and change delimiter with DELIMITER.

@yrsdi
yrsdi / postgres_queries_and_commands.sql
Created April 25, 2018 10:16 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@yrsdi
yrsdi / generate.sh
Created March 26, 2018 22:55
Generate file contain random value
for i in $(seq 1 6000000)
do
echo SERVER$((RANDOM%800+100)),$RANDOM,$RANDOM,$RANDOM >> sample2.csv
done
@yrsdi
yrsdi / mysqlImport.sh
Created March 26, 2018 22:47
shell script to load big data from file to mysql db
#!/bin/sh
mysql -uroot -hlocalhost --local-infile=1 tableName << Eof
load data local infile "data.csv" into table server FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
;
Eof
@yrsdi
yrsdi / server.ex
Created December 5, 2016 21:45 — forked from prio/server.ex
Elixir gen_server example
defmodule Tcprpc.Server do
use GenServer.Behaviour
defrecord State, port: nil, lsock: nil, request_count: 0
def start_link(port) do
:gen_server.start_link({ :local, :tcprcp }, __MODULE__, port, [])
end
def start_link() do
@yrsdi
yrsdi / html_form
Created October 9, 2016 00:26 — forked from zvineyard/html_form
PHP: Upload and Rename File
<form action="" enctype="multipart/form-data" method="post">
<input id="file" name="file" type="file" />
<input id="Submit" name="submit" type="submit" value="Submit" />
</form>
@yrsdi
yrsdi / serverExplode.php
Last active September 7, 2015 08:37 — forked from steveathon/serverExplode.php
Explode PHP $_SERVER['REQUEST_URI'];
<?php
$URIParts = explode('?',$_SERVER['REQUEST_URI']);
$URI = explode('/',$URIParts[0]);
// Shift the array, to move it past the 'root'
@array_shift($URI);
// Now, get rid of any pesky empty end slashes
while ( @count($URI) > 0 && !end($URI) ) {
@array_pop($URI);
}