Skip to content

Instantly share code, notes, and snippets.

@maurostorch
maurostorch / assume-role-load-envs.sh
Created March 24, 2023 19:54
AWS CLI assume role and load environment variables. Usage: `./assume-role-load-envs.sh ROLENAME |sh`
ROLENAME=$1
ACCOUNTID=$(aws sts get-caller-identity --query "Account" --output text)
JSON=$(aws sts assume-role --role-arn arn:aws:iam::$ACCOUNTID:role/$ROLENAME --role-session-name run)
echo $JSON | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\"\(.AccessKeyId)\""'
echo $JSON | jq -r '.Credentials | "export AWS_SECRET_ACCESS_KEY=\"\(.SecretAccessKey)\""'
echo $JSON | jq -r '.Credentials | "export AWS_SESSION_TOKEN=\"\(.SessionToken)\""'
@maurostorch
maurostorch / remove_events_rules.sh
Created October 9, 2021 01:58
Remove CloudWatch Rules with targets
#!/bin/bash
# Requires AWS CLI v2
#Usage ./remove_events_rules.sh <rule name, or partial name>
set -eo pipefail
echo "Searching rules for $1";
rules=$(aws events list-rules |jq -r '.Rules[].Name'|grep $1);
echo "Deleting rules:\n$rules";
read -p "Confirm (y/n)?" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
@maurostorch
maurostorch / BitShiftCrypt.java
Last active March 14, 2018 20:40
ShiftCrypt: 2 bit shift.
public class BitShitCrypt {
public static byte[] encrypt(byte[] data) {
if (data == null) return null;
byte r=(byte)0x00;
for (int i=0;i<data.length;i++) {
byte lr = (byte)(data[i]&0x03);
data[i]=(byte)(data[i]>>2 | r);
r=(byte)(lr<<6);
if (i+1==data.length) {
@maurostorch
maurostorch / x11vnc-start
Created July 31, 2017 12:49 — forked from tavinus/x11vnc-start
Starts VNC server for the current session
#!/bin/bash
###########################################################################
# /usr/local/bin/x11vnc-start
# Starts VNC server for the current session
#
# Gustavo Neves - 4th Jul 2016
#
# Install x11vnc:
# sudo apt-get install x11vnc
@maurostorch
maurostorch / parallax.html
Last active June 26, 2017 23:50
Parallax with jQuery
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="jquery-3.1.1.min.js"></script>
<style media="screen">
html, body{
width: 100%;
height: 100%;
from OpenSSL import crypto
import os
fk = open('security/server.key','r')
k = crypto.load_privatekey(crypto.FILETYPE_PEM, fk.read())
fcert = open('security/server.crt','r')
cert = crypto.load_certificate(crypto.FILETYPE_PEM, fcert.read())
signature = crypto.sign(k, 'data', 'sha1')
try:
crypto.verify(cert, signature, 'data', 'sha1')
@maurostorch
maurostorch / bcjobs.py
Created September 27, 2016 11:22
jobsearcher crawler using scrapy
#job searcher crawler
import scrapy
class BlogSpider(scrapy.Spider):
name = 'blogspider'
start_urls = ['https://www.bcjobs.ca/search-jobs?q=cloud']
pagecount = 2
def parse(self, response):
for it in response.css('a.list-item-wrapper'):
import sys
a=[18897109,12828837, 9461105, 6371773, 5965343, 5946800, 5582170, 5564635, 5268860, 4552402, 4335391, 4296250, 4224851, 4192887, 3439809, 3279833, 3095313, 2812896, 2783243, 2710489, 2543482, 2356285, 2226009, 2149127, 2142508, 2134411]
CUT=100000000
#a=[1,2,3,4]
#CUT=5
# the recursion
def r(pos, level):
global a
if level == 1:
package main
import (
"fmt"
)
func check(tab [3][3]int) int {
if tab[0][0] == tab[1][0] && tab[0][0] == tab[2][0] && tab[0][0] > 0{
return tab[0][0]
}
@maurostorch
maurostorch / envelope.html
Created May 21, 2016 12:16
Icon envelope
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
.holder {
width: 100px;
height: 100px;
float: left;