Skip to content

Instantly share code, notes, and snippets.

View CraigTheKiwi's full-sized avatar

Craig Walker CraigTheKiwi

View GitHub Profile
@CraigTheKiwi
CraigTheKiwi / sendBeacon.py
Created August 28, 2021 21:47
Solution to Cassidoo Newsletter 23 Aug 2021
#!/bin/python3
import requests
from bs4 import BeautifulSoup
from urllib.request import urlopen
#number of results per page
num = "500"
# query - site:github.com and (/blob/master "navigator.sendBeacon") and (MIT|Apache|GPL|BSD)
@CraigTheKiwi
CraigTheKiwi / pSubstring.py
Created August 16, 2021 09:46
Solution for Cassidoo Newsletter (Aug 16)
#!/bin/python3
def checkPal(string, i, j):
length = j-i+1
while string[i] == string[j] and i <= j:
# 5 , 6
i+=1
j-=1
# 6 , 5
if i == j or i + 1 == j:
#!/bin/python3
def generateMinesweeper(gridSize, mines):
# lets setup the board
board = []
for i in range(gridSize):
board.append(['x']*gridSize)
# trigger all the mines
for mine in mines:
@CraigTheKiwi
CraigTheKiwi / zerosEndingFactorial.py
Created July 26, 2021 08:17
Solutions for Cassidoo Newsletter (July 26)
#!/bin/bash
import math
import re
# There are a couple of solutions here, one that can be easily stepped through to understand the
# process and allows for error checking to be introduced easily, the other a one liner just because
# it's what the cool kids seem to be doing.
def zerosEndingFactorial(n):
total = 1
@CraigTheKiwi
CraigTheKiwi / subarraySum.py
Last active July 23, 2021 20:38
Solution for Cassidoo Newsletter (July 19) in Python
#!/bin/python3
def subarraySum(arr, n):
arr_len = len(arr)
count = 0
for x in range(0, arr_len - 1):
total = arr[x]
for y in range(x+1, arr_len):
total += arr[y]
if total == n:
#!/bin/python3
# Take an ip string and return a string representing it's binary value
# inputs: ip_string = '192.168.1.12'
# outputs: returns '1100000010...'
def prepBinary(ip_string):
binary_string = ""
ip_nums_string = ip_string.split(".");
for ip_num in ip_nums_string:
def translateShift2(text):
crypt = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?"
print("".join(list(map(lambda a : " " if a==" " else crypt[crypt.index(a)-1], text))))
translateShift2(";p; epe")
translateShift2("vtsmnrttu")
@CraigTheKiwi
CraigTheKiwi / drawCube.py
Last active June 22, 2021 01:01
Solution for Cassidoo Newsletter (June 22) in Python
#!/bin/bash
import sys
pattern = [
[" ", "+","-","+"], #top row
[" ", "/", " ", "/", " ", "|"], # lid rows (many)
["+", "-", "+", " ", "|"], # top face
["|", " ", "|", " ", "|"], # front and side rows (many)
["|", " ", "|", " ", "+"], # pivot to bottom rows
["|", " ", "|", " ", "/"], # front and bottom rows (many)
@CraigTheKiwi
CraigTheKiwi / gist:1707ae15edba48ddb542e890e487f8ad
Created June 15, 2021 21:28
Solution for Cassidoo Newsletter (June 14) in Python
#!/bin/python3
import sys
def arrow(direction, number):
start = -1
# start going left
finish = number+1
modifier = 1 #controls direction
counter = 0