Skip to content

Instantly share code, notes, and snippets.

@Technowise
Technowise / shell-script-import-all-mongo-db-json-files-from-folder-to-remote-server.sh
Created Oct 12, 2016
Shell script to import all MongoDB json files in current folder to remote database
View shell-script-import-all-mongo-db-json-files-from-folder-to-remote-server.sh
ls -1 *.json | sed 's/.json$//' | while read col; do
mongoimport --host sample-mongodb-host.com --username john --password sample-password --db sample-db --collection $col --file $col.json
echo $cmd
done
@Technowise
Technowise / Connecting-to-RDS-using-SSL-in-Python.py
Last active Nov 7, 2017
Connecting-to-RDS-using-SSL-in-Python
View Connecting-to-RDS-using-SSL-in-Python.py
import mysql.connector
#CA Bundle file is provided on AWS documentation for RDS: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html
#Link: https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
SSL_CA='rds-combined-ca-bundle.pem'
cnx = mysql.connector.connect(user='sequoia_usr_prod', password='iz8sVGk0TwYxKfJo',
host='sequoia-db-prod.cxtfi76qjanv.us-west-2.rds.amazonaws.com',
database='sequoia_db_prod', ssl_ca=SSL_CA)
cnx.close()
@Technowise
Technowise / validate_fb_auth_token.php
Created May 10, 2013
Validate Facebook Auth-Token. This helper function checks if the Facebook auth-token is valid, and belongs to the said facebook-id
View validate_fb_auth_token.php
<?php
// A helper function to validate Facebook Auth-Token.
// This checks if the Facebook auth-token is valid, and belongs to the said facebook-id
function is_facebook_auth_valid($facebook_token, $facebook_id)
{
$ch = curl_init();
$url="https://graph.facebook.com/me?access_token=".$facebook_token;
curl_setopt($ch, CURLOPT_URL,$url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@Technowise
Technowise / play-framework-init.d-script
Created Jan 4, 2017
Play Framework init.d script - Run play application as service in Linux, so that you do not have to do a lot of manual stuff
View play-framework-init.d-script
#!/bin/bash
#To use this script:
#1) Save this file with name of your app in /etc/init.d folder.
#2) Update the APP_NAME to the name of your application in build.sbt.
#3) Update the APP_PATH of the application to the path where you extracted your dist version/snapshot.
#4) Update the value of PORT to the port you would like your application to run on.
#5) Add this script as service using update-rc.d. (Example: sudo update-rc.d your-app defaults).
#
APP_NAME="your-app-name"
You can’t perform that action at this time.