Skip to content

Instantly share code, notes, and snippets.

View H-Max's full-sized avatar
🎓
Working from home

Henri-Maxime Ducoulombier H-Max

🎓
Working from home
View GitHub Profile
@H-Max
H-Max / InfiniteScrollableView.js
Created August 28, 2012 16:13 — forked from dawsontoth/InfiniteScrollableView.js
Infinite scrollable list.
/**
* We're going to create an infinite scrollable list. In this case, we're going to show a date. When you swipe left,
* you'll see yesterday. Then the day before yesterday, and so on. Swiping right shows you tomorrow, and so on.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var isAndroid = Ti.Platform.osname === 'android';
/**
* Track where we are in the infinite scrollable views, and define how large of a step goes between each view.
*/
var currentDate = new Date(), msIntervalBetweenViews = 1000/*ms*/ * 60/*s*/ * 60/*m*/ * 24/*h*/;
@H-Max
H-Max / mongodb-backup.sh
Last active October 23, 2023 17:21
Backup mongodb database directly to S3
# Use environment variable as password (could also be a password stored in a file, read with cat)
# DO NOT use --password argument in mongodump command or authentication will fail
# DO NOT add a file name after --archive argument, or mongodump output won't be sent to stdout
# Use S3 infrequent access storage class to reduce cost
# Use aes-256 encryption of your file on S3 (or your own KMS keys)
# Benefits of this method :
# 1 > You won't see the password sent to mongodump using in ps command (it's safe in a multi-user environment)
# 2 > You don't have to store the backup locally before sending it to S3
# 3 > Everything is done in one line, fits a cronjob easily
# Mongodump + GPG + S3
#
# MDB_HOST is your mongod/s host / IP
# MDB_PORT is your mongod/s instance port
# MDB_BACKUP_USER is your mongodb backup user with backup/restore role
# MDB_BACKUP_PASSWORD is your mongodb backup user password
# MDB_AUTHDB is mongodb database used for authentication mechanism
# MDB_DB is the dabatase you want to backup
# BACKUP_BUCKET is the S3 bucket where you store your backups
# GPG_RECIPIENT is the recipient footprint in your GPG recipient list
@H-Max
H-Max / preshard-database.js
Last active September 3, 2019 15:40
Shard and enable pre-splitting (on hashed index) for collection(s) in a MongoDB Database.
/*
Shard collection(s) before restoring or mass importing data in them
Script has to run against a mongos instance (not mongod), with a user having:
- "clusterAdmin" privilege
- "readWrite" privilege on database to shard
For each collection to shard, you will have to estimate the "numInitialChunks" value depending on :
- The volume of data to import/insert
- The configured chunks size for your instance
@H-Max
H-Max / comm-files.sh
Last active January 13, 2021 11:14
One liner to compare 2 files and keep only the difference
# Unique lines only (does not work if lines are present more than once in any of the 2 source files)
comm -13 <(head -n 1 a.txt && tail -n +2 a.txt | sort) <(head -n 1 b.txt && tail -n +2 b.txt | sort) > compare.txt
pkill -2 mongos && sudo pkill -2 mongod
@H-Max
H-Max / README.md
Created January 11, 2024 09:36
IntelliJ validators for dbt YAML files

Simply copy this file in the .idea folder at the root of your project.