Skip to content

Instantly share code, notes, and snippets.

View bertrandmartel's full-sized avatar
💤
👀

Bertrand Martel bertrandmartel

💤
👀
View GitHub Profile
@bertrandmartel
bertrandmartel / mfa.sh
Created April 17, 2021 23:41
re-enable mfa device in aws
aws iam deactivate-mfa-device --user-name MFA_NAME --serial-number "arn:aws:iam::ACCOUNT_ID:mfa/MFA_NAME"
aws iam delete-virtual-mfa-device --serial-number arn:aws:iam::ACCOUNT_ID:mfa/MFA_NAME
aws iam create-virtual-mfa-device --virtual-mfa-device-name MFA_NAME --outfile mfa --bootstrap-method QRCodePNG
aws iam enable-mfa-device --user-name MFA_NAME --serial-number "arn:aws:iam::ACCOUNT_ID:mfa/MFA_NAME" --authentication-code1 "CODE1" --authentication-code2 "CODE2"
@bertrandmartel
bertrandmartel / cursor.py
Created March 31, 2021 17:55
Github Graphql API cursor decoding
import requests
import base64
token = "YOUR_TOKEN"
query = """
query {
search(type:ISSUE, query:"repo:mui-org/material-ui is:issue", first: 100){
nodes {
... on Issue {
@bertrandmartel
bertrandmartel / credentials
Last active August 21, 2024 15:39
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 <[email protected]>
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"