This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
miscellaneous language learnings | |
*/ | |
package main | |
import "fmt" | |
func main() { | |
fmt.Println("Oh yeah.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main (int argc, const char * argv[]) | |
{ | |
/* | |
Shows max length for some types | |
*/ | |
int zint; | |
char zchar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rumor has it that in newer releases of Python v3, ipaddr objects are not iterable | |
import ipaddr | |
import hashlib | |
salt = 'NN' | |
subnet = ipaddr.IPNetwork('192.168.100.0/24') | |
for ip in subnet: | |
# Try md5 or sha512 | |
maskedIP = hashlib.md5(str(ip) + salt).hexdigest() | |
print('{ip:<15} :: {maskedIP}'.format(ip=ip, maskedIP=maskedIP)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from random import randrange | |
while True: | |
ssn1 = randrange(1, 999, 1) | |
ssn2 = randrange(1, 99, 1) | |
ssn3 = randrange(1, 9999, 1) | |
print('{0:0>3}-{1:0>2}-{2:0>4}'.format(ssn1, ssn2, ssn3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while($True) { | |
$ssn1 = $(random -min 1 -max 999).tostring("000") | |
$ssn2 = $(random -min 1 -max 99).tostring("00") | |
$ssn3 = $(random -min 1 -max 9999).tostring("0000") | |
$ssn = $ssn1 + "-" + $ssn2 + "-" + $ssn3 | |
write-output $ssn | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import boto3 | |
from datetime import date | |
from time import sleep | |
session = boto3.Session(profile_name = 'default') | |
athena = session.client('athena') | |
database = 'ct' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import boto3 | |
from datetime import date | |
from time import sleep | |
session = boto3.Session(profile_name = 'default') | |
athena = session.client('athena') | |
database = 'ct' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE EXTERNAL TABLE cloudtrail_logs ( | |
eventversion STRING, | |
userIdentity STRUCT< | |
type:STRING, | |
principalid:STRING, | |
arn:STRING, | |
accountid:STRING, | |
invokedby:STRING, | |
accesskeyid:STRING, | |
userName:String, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import json | |
import glob | |
def getlogs(logfile): | |
with open(logfile, 'rb') as fs: | |
return json.load(fs)['Records'] | |
def scanlogs(logs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
url = 'http://api.shoutcloud.io/V1/SHOUT' | |
input = {'INPUT': 'this is a lowercase string'} | |
headers = {'content-type': 'application/json'} | |
payload = json.dumps(input) | |
r = requests.post(url, data=payload, headers=headers) |