Skip to content

Instantly share code, notes, and snippets.

View gustavobgama's full-sized avatar
🏠
Working from home

Gustavo Gama gustavobgama

🏠
Working from home
View GitHub Profile
<?php
$url = 'https://hostserver.com/gateway/remote_send';
$payload = array(
'profile_name' => 'username',
'profile_pw' => 'password1234',
'attached_type' => 'action_1'
);
$file = realpath('/home/username/tests/test1234qwerty.csv');
// build multipart
@gustavobgama
gustavobgama / CurlsExamples.sh
Created February 24, 2014 14:32
Curls examples
# GET
curl -i -u user:password http://localhost/productimage/create
# POST
curl -i -u user:password --data "param1=value1&param2=value2" http://localhost/productimage/create
@gustavobgama
gustavobgama / QueryToFile.sql
Created January 28, 2014 18:27
Save result of a query to CSV file
SELECT
*
FROM
table
INTO OUTFILE
'/tmp/file.csv'
FIELDS TERMINATED BY
','
ENCLOSED BY
'"'
@gustavobgama
gustavobgama / GetFileCreationDate.md
Created January 24, 2014 16:05
How to get the creation date of file in *nix systems

Get mounted partitions

$ sudo mount -l

Get creation date of file

$ debugfs -R 'stat <path_to_file>' <momunted_partition_path>

momunted_partition_path is the partition mouting path of path_file

@gustavobgama
gustavobgama / SeachForColumn.sql
Created January 17, 2014 09:43
Search for a column in all tables
SELECT table_name,table_schema FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name='column_name';
@gustavobgama
gustavobgama / TarGzCommands.sh
Created January 15, 2014 15:19
Tar gz commands
# compact
tar -zcvf file.tar.gz source-folder
# extract
tar -zxvf file.tar.gz
@gustavobgama
gustavobgama / GetLastMatch.sh
Created December 23, 2013 17:06
Get last match in file
tac file | grep -m 1 term
@gustavobgama
gustavobgama / AutoIncrement.sql
Created December 18, 2013 19:03
View auto increment value of a table
SELECT `AUTO_INCREMENT`
FROM `information_schema`.`TABLES`
WHERE `TABLE_SCHEMA` = SCHEMA()
AND `TABLE_NAME` = 'tbl_name';
@gustavobgama
gustavobgama / MySQLDump.sh
Created December 3, 2013 20:17
Commands to export/import/transport mysql database dumps
# Reference: http://webcheatsheet.com/sql/mysql_backup_restore.php
# import without compression
mysql --host=host --user=user --password=password database < path_to_file.sql
# import with compression
gunzip < path_to_file.sql.gz | mysql --host=host --user=user --password=password database
# export wihtout compression
mysqldump --host=host --user=user --password=password database table --where="condition" > path_to_file.sql
@gustavobgama
gustavobgama / clearQueryCache.sql
Created September 24, 2013 12:07
Clear MySQL query cache
RESET QUERY CACHE;