Skip to content

Instantly share code, notes, and snippets.

View bertrandmartel's full-sized avatar
💤
👀

Bertrand Martel bertrandmartel

💤
👀
View GitHub Profile
@bertrandmartel
bertrandmartel / credentials
Last active January 10, 2023 10:54
Assume role with MFA for terraform/terragrunt (https://stackoverflow.com/a/66878739/2614364)
[prod]
aws_secret_access_key = redacted
aws_access_key_id = redacted
[tf_temp]
[tf]
credential_process = sh -c 'mfa.sh arn:aws:iam::{account_id}:role/{role} arn:aws:iam::{account_id}:mfa/{mfa_entry} prod 2> $(tty)'
@bertrandmartel
bertrandmartel / wtb_decode.py
Created October 19, 2020 14:29
Decode wtb format in python
with open("test.bin", mode='rb') as file:
encodedData = file.read()
offset = 0
objects = []
iteration = 0
while offset < len(encodedData):
elementSize = encodedData[offset]
offset+=1
#compile with : g++ -o scan scan.cpp -lbluetooth
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include <cerrno>
int main(int argc, char **argv)
{
import requests
from bs4 import BeautifulSoup
s = requests.Session()
r = s.get("https://www.kickstarter.com")
soup = BeautifulSoup(r.text, 'html.parser')
xcsrf = soup.find("meta", {"name": "csrf-token"})["content"]
query = """
query GetEndedToLive($slug: String!) {
@bertrandmartel
bertrandmartel / world_map.py
Last active June 11, 2020 10:55
extract map data from Arcgis Rest service World_Topo_Map
import requests
params = {
"text": "",
"objectIds": "",
"time": "",
"geometry": "",
"geometryType": "esriGeometryEnvelope",
"inSR": "",
"spatialRel": "esriSpatialRelIntersects",
@bertrandmartel
bertrandmartel / github.js
Created June 8, 2020 01:04
Github Oauth2 authentication in nodeJS with a page inviting user to choose the preferred login account
var app = require('express')(),
passport = require('passport'),
GitHubStrategy = require('passport-github').Strategy,
mongoose = require('mongoose'),
github = require('octonode'),
bodyParser = require('body-parser'),
session = require('express-session');
var config = {
clientID: 'YOUR_CLIENT_ID',
@bertrandmartel
bertrandmartel / doc.txt
Created June 6, 2020 12:03
Override file type by using vim modeline
= Introduction to AsciiDoc
Doc Writer <doc@example.com>
A preface about https://asciidoc.org[AsciiDoc].
== First Section
* item 1
* item 2
@bertrandmartel
bertrandmartel / steam_collection.py
Created June 3, 2020 23:00
search items in a specific collections on the Steam Market
import requests
import json
r = requests.get("https://steamcommunity.com/market/appfilters/730")
tags = json.loads(r.text)["facets"]["730_ItemSet"]["tags"]
winter_offensive_tag = [
t[0]
for t in tags.items()
if t[1]["localized_name"] == "The Winter Offensive Collection"
@bertrandmartel
bertrandmartel / ace.vue
Created April 20, 2020 21:50
Ace editor using vue.js
<template>
<div :id="editorId" class="editor">
</div>
</template>
<script>
import * as ace from 'brace';
import 'brace/mode/yaml';
import 'brace/theme/monokai';
export default {
@bertrandmartel
bertrandmartel / migrate.sh
Created April 14, 2020 01:42
Migrate from DocumentDB to DocumentDB using mongodump/mongorestore
mongodump --host [HOST] --username [USER] \
--password [PASSWORD] --db rfp --authenticationDatabase admin \
--readPreference secondary --ssl --sslCAFile rds-combined-ca-bundle.pem --sslAllowInvalidCertificates
mongorestore --uri="mongodb://<target_username>:<target_password>@<target_host>/?authSource=admin&replicaSet=rs0" \
--ssl --sslCAFile rds-combined-ca-bundle.pem --sslAllowInvalidCertificates \
--numInsertionWorkersPerCollection 64 dump