Skip to content

Instantly share code, notes, and snippets.

View cdimascio's full-sized avatar
👋
🤔👨‍💻🚀

Carmine DiMascio cdimascio

👋
🤔👨‍💻🚀
View GitHub Profile
@cdimascio
cdimascio / mongodump
Last active June 6, 2018 18:04
Compose MongoDB mongodump/mongorestore
mongodump --host your-hostname --port your-port --ssl --sslAllowInvalidCertificates --db=your-db-name --archive=./ep-ao-dump -u admin -p your-password --authenticationDatabase admin
@cdimascio
cdimascio / create_user.sh
Last active April 20, 2018 13:54
Create MongoDB user via Mongo shell
# start the mongo shell, then set to the appropriate db and create a user
# in this case, create a user with dbadmin, and read write access roles
use my_db
db.createUser( { user: "my_user", pwd: "MyP@ssw0rd", roles: [ { role: "readWrite", db: "my_db"}, { role: "dbAdmin", db: "my_db" } ] })
@cdimascio
cdimascio / crypto-ctr.js
Last active March 2, 2018 23:26 — forked from chris-rock/crypto-ctr.js
Encrypt and decrypt text in nodejs
// Part of https://github.com/chris-rock/node-crypto-examples
// Nodejs encryption with CTR
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq',
key = Buffer.from('5ebe2294ecd0e0f08eab7690d2a6ee69', 'hex'),
iv = Buffer.from('26ae5cc854e36b6bdfca366848dea6bb', 'hex');
function encrypt(text){
@cdimascio
cdimascio / Configure awscli
Last active January 20, 2023 04:05
IBM Cloud Object Storage COS with AWS CLI
cat ~/.aws/config
[default]
region = us-standard
output = json
@cdimascio
cdimascio / .env.sh
Last active January 1, 2018 15:52
Dotenv Java
# formatted as key=value
MY_ENV_VAR1=some_value
MY_EVV_VAR2=some_value
@cdimascio
cdimascio / Node 8 Mocha with Babel VSCode
Last active July 27, 2018 15:19
Connect VSCode debugger to Node.js, Typescript using webpack, mocha, ...
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"protocol": "inspector",
"args": [
"-u",
"tdd",
"--timeout",
@cdimascio
cdimascio / main.go
Last active January 7, 2017 15:20
Golang Promise simulation
func main() {
person := new(Person)
person.Name = "Carmine"
SavePerson(person).Then(func(obj interface{}) error {
fmt.Printf("Successfully created %v\n", obj)
return nil
}, func(err error) {
fmt.Printf("Failed to create %v\n", err)
}).Then(func(obj interface{}) error {
@cdimascio
cdimascio / jquery.getjson.observable.js
Last active January 6, 2016 18:50
RxJs: Adapt jQuery.getJSON to an Rx.Observable
function getJSON(url, data) {
return Rx.Observable.create(observer => {
var canceled = false;
if (!canceled) {
jQuery.getJSON(url, data).
done(data => {
observer.onNext(data);
observer.onCompleted();
}).
fail(err => observer.onError(err));
@cdimascio
cdimascio / 1_observations.js
Last active January 2, 2016 18:26
Adapt ES7 Object.observe to Rx.Observable
var Observable = Rx.Observable;
Observable.fromObservations = function(obj) {
return Observable.create(function forEach(observer) {
var handler = changes => observer.onNext(changes);
Object.observe(obj, handler);
return function dispose() {
Object.unobserve(obj, handler);
};
@cdimascio
cdimascio / 1_index.html
Last active January 1, 2016 23:30
RxJS - Simple autocomplete box
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.6/rx.all.js"></script>
<meta charset="utf-8">
<title>Test</title>
</head>
<body>
<input id="textbox">