Skip to content

Instantly share code, notes, and snippets.

View hasantayyar's full-sized avatar
⌨️
AFK

Hasan Tayyar Beşik hasantayyar

⌨️
AFK
View GitHub Profile
@hasantayyar
hasantayyar / .env
Created October 11, 2017 08:18 — forked from lukewduncan/.env
AWS Lambda function for Mailchimp list subscription
API_KEY='xxxxxxxxxxxxxxxxxxx-us1'
LIST_ID=12033101ax
@hasantayyar
hasantayyar / upload-ssec.sh
Created September 12, 2017 13:55 — forked from imbradbrown/upload-ssec.sh
Uploading to Amazon S3 from curl with Server Side Encrpytion - Customer Provided Key used. Note that this uses the Amazon Access Keys which should be used with care.
#!/bin/bash
## file to upload.
S3_UPLOAD_FILE=some/path/file.txt
## Specify the bucket name here. This can be found in the S3 console
S3_BUCKET=bucket name here
## The desired path relative to the root of the bucket. All folders must be forward slash '/' separated
S3_DESTINATION_FILE=folder/folder2/file.txt
@hasantayyar
hasantayyar / kill.js
Created September 6, 2017 12:28
meteor - workaround that kills the instance, if the reconnect has failed.
MongoInternals.defaultRemoteCollectionDriver().mongo.db.s.topology.on('reconnectFailed', err => {
console.error(err.stack)
process.exit(1)
})
@hasantayyar
hasantayyar / docker-cleanup-resources.md
Created August 25, 2017 09:52 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@hasantayyar
hasantayyar / simple-promise-retry.js
Created August 7, 2017 21:41 — forked from briancavalier/simple-promise-retry.js
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
### your_cronjob.sh ####
btc=$(curl -s http://api.coindesk.com/v1/bpi/currentprice.json | python -c "import json, sys; print(int(json.load(sys.stdin)['bpi']['USD']['rate'].replace(',','').split('.')[0] ))")
ALERT_BTC=3000
if [ $(($btc + 1)) -gt $ALERT_BTC ];
then
echo "btc is greater than $ALERT_BTC";
push "BTC value is greater then $ALERT_BTC"
fi;
@hasantayyar
hasantayyar / postal-codes.json
Created June 15, 2017 07:43 — forked from matthewbednarski/postal-codes.json
Global postal codes regex formats
[{ "Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup", "Country": "Afghanistan", "ISO": "AF", "Format": "NNNN", "Regex": "^\\d{4}$"}, { "Note": "With Finland, first two numbers are 22.", "Country": "Åland Islands", "ISO": "AX", "Format": "NNNNN", "Regex": "^\\d{5}$"}, { "Note": "Introduced in 2006, gradually implemented throughout 2007.", "Country": "Albania", "ISO": "AL", "Format": "NNNN", "Regex": "^\\d{4}$"}, { "Note": "First two as in ISO 3166-2:DZ", "Country": "Algeria", "ISO": "DZ", "Format": "NNNNN", "Regex": "^\\d{5}$"}, { "Note": "U.S. ZIP codes (range 96799)", "Country": "American Samoa", "ISO": "AS", "Format": "NNNNN (optionally NNNNN-NNNN or NNNNN-NNNNNN)", "Regex": "^\\d{5}(-{1}\\d{4,6})$"}, { "Note":
@hasantayyar
hasantayyar / mongodb-s3-backup.sh
Created June 8, 2017 12:31 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
# USAGE
# 1. Run this script in v2 root folder
# 2. No need to pass the parameters. The feault values are
# - Build directory : '../../../build'
# - Architecture : null (means the same that this script is running)
# 3. Running by samples
# - sh bin/build-staging.sh
# - sh bin/build-staging.sh /tmp/build-dir
# - sh bin/build-staging.sh /home/www/build os.linux.x86_64
@hasantayyar
hasantayyar / deploy_aws.sh
Created May 11, 2017 16:49 — forked from wearhere/deploy_aws.sh
CI script to convert a Meteor application into a Node.js application then deploy it to AWS Elastic Beanstalk.
#!/bin/bash
#
# This script will convert a Meteor application into a Node.js application
# then deploy it to AWS Elastic Beanstalk.
#
# Run like `deploy_aws.sh my_eb_app my_eb_app-production`.
#
# That will deploy the Meteor application containing this script
# to the `my_eb_app-production` environment of the `my_eb_app` EB application.