Skip to content

Instantly share code, notes, and snippets.

View hesoyamcode's full-sized avatar
💭
I may be slow to respond.

fu hesoyamcode

💭
I may be slow to respond.
  • Singapore
View GitHub Profile
@hesoyamcode
hesoyamcode / gist:368517a290934b8196e4f5608cdacb59
Last active September 18, 2019 07:02
Mongodb dump, restore, import, export
The counterpart to mongodump is mongorestore (and the counterpart to mongoimport is mongoexport) -- the major difference is in the format of the files created and understood by the tools (dump and restore read and write BSON files; export and import deal with text file formats: JSON, CSV, TSV.
If you've already run mongodump, you should have a directory named dump, with a subdirectory for each database that was dumped, and a file in those directories for each collection. You can then restore this with a command like:
mongorestore -h host.com:port -d dbname_test -u username -p password dump/dbname/
Assuming that you want to put the contents of the database dbname into a new database called dbname_test.
Src: https://stackoverflow.com/questions/8070298/how-to-import-dumped-mongodb
@hesoyamcode
hesoyamcode / nginx.conf
Created September 17, 2019 17:43 — forked from thoop/nginx.conf
Official prerender.io nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;

AWS Fargate Docker Simple Deployment Setup with SSL termination

How to:

  • create a Docker-based AWS Fargate/ECS deployment
  • without the Docker containers having a public IP
  • with an Application Load Balancer as reverse proxy / SSL termination proxy sitting in front of the containers

For Fargate/ECS to be able to access your Docker images hosted on ECR (or somewhere else) you'll have to allow outbound internet access to the Fargate subnets. Here's how you do it.

@hesoyamcode
hesoyamcode / gist:ad9cccb1d13ceea910780574b0723f3f
Last active July 21, 2019 18:12
docker command copy from/to docker local (server it self)
The cp command can be used to copy files. One specific file can be copied like:
SQL
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
MONGO
@hesoyamcode
hesoyamcode / gist:9643011e823d5d3b1d19ca97deddd364
Created May 13, 2019 16:30 — forked from voskobovich/gist:43f851859c23a8261514
The list of countries with currency (ISO code and symbol) format in SQL.
DROP TABLE currency;
-- Create table variable
CREATE TABLE currency (
country VARCHAR(100),
currency VARCHAR(100),
code VARCHAR(100),
symbol VARCHAR(100)
);
@hesoyamcode
hesoyamcode / gist:17ed19d484ac79a920c782ff30719fee
Created May 10, 2019 04:29
Complete mysql country list and administrative meta country
DROP TABLE IF EXISTS `meta_country`;
DROP TABLE IF EXISTS `meta_province`;
CREATE TABLE IF NOT EXISTS `meta_country` (
`alpha_2` char(2) NOT NULL,
`alpha_3` char(3) NOT NULL,
`numeric` char(3) NOT NULL,
`name` varchar(255) NOT NULL,
`common_name` varchar(255) NOT NULL,
`official_name` varchar(255) NOT NULL,
Open jmeter
open /usr/local/bin/jmeter
Run jmeter in CLI
/usr/local/bin/jmeter -n -t ~/Desktop/Health-Integration-Jmeter.jmx -l ~/Desktop/health-integration-load-test.csv -D jmeter.save.saveservice.output format.csv
Run jmeter in CLI jtl output with log
/usr/local/bin/jmeter -n -t ~/Desktop/Health-Integration-Jmeter.jmx -l ~/Desktop/health-integration-load-test.jtl -j jmeter-health-integration.log
INSERT INTO `online_account_categories` (`id`, `name`, `description`, `created_by`, `updated_by`, `created_at`, `updated_at`)
VALUES
(NULL, 'Other', NULL, 0, 0, NOW(), NOW()),
(NULL, 'Social Media', NULL, 0, 0, NOW(), NOW()),
(NULL, 'Entertainment', NULL, 0, 0, NOW(), NOW()),
(NULL, 'Ecommerce', NULL, 0, 0, NOW(), NOW()),
(NULL, 'Finance', NULL, 0, 0, NOW(), NOW());
INSERT INTO `user_professionals` (`id`, `name`, `is_active`, `description`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES (NULL, 'Unspecific', '1', NULL, '0', '0', '2018-12-12 00:00:00', '2018-12-12 00:00:00'), (NULL, 'Health Care', '0', NULL, '0', '0', '2018-12-12 00:00:00', '2018-12-12 00:00:00');
INSERT INTO `user_professionals` (`id`, `name`, `is_active`, `description`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES (NULL, 'Social Care', '1', NULL, '0', '0', '2018-12-12 00:00:00', '2018-12-12 00:00:00'), (NULL, 'Funeral Professional', '1', NULL, '0', '0', '2018-12-12 00:00:00', '2018-12-12 00:00:00');
@hesoyamcode
hesoyamcode / timezone_country.sql
Last active February 17, 2019 13:38
mysql timezone with country/city
DROP TABLE IF EXISTS `timezones`;
CREATE TABLE `timezones` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`country_code` char(3) NOT NULL,
`zone_name` varchar(125) NOT NULL DEFAULT '',
`gmt_offset` char(6) DEFAULT NULL,
`dst_offset` char(6) DEFAULT NULL,
`raw_offset` char(6) DEFAULT NULL,
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;