Skip to content

Instantly share code, notes, and snippets.

View gingeleski's full-sized avatar
📈

Randy Gingeleski gingeleski

📈
View GitHub Profile
@gingeleski
gingeleski / merge_sort.rb
Created February 9, 2015 00:57
Basic merge sort
# Basic merge sort
def merge_sort(list)
# Return the original array if its size is 1 or less.
return list if list.length <= 1
# Split the array in half.
mid = list.length / 2
left = list[0..mid - 1]
right = list[mid..-1]
@gingeleski
gingeleski / helloWorld.js
Last active August 29, 2015 14:24
Node.js hello world.
// Node.js HelloWorld
// Add the HTTP module - https://nodejs.org/api/http.html
var http = require('http');
// Create a server
// It always expects to work with a request and response
var myServer = http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type" : "text/plain"});
response.end('Hello world');
@gingeleski
gingeleski / bitcoinLendCalc.rb
Created March 5, 2016 19:35
Ballpark numbers of continuously lending # out a given amount of BTC...
# Ballpark numbers of continuously lending
# out a given amount of BTC on Poloniex
##########################################################
# FILL THESE IN
start_btc = 150.0 # BTC - amount you're starting with
term = 2 # days - all loans will be for 2 day terms
daily_interest = 0.0025 # % expressed as 1.0 being 100%
run_days = 364 # how many days to run this for
@gingeleski
gingeleski / ergo_stop.ps1
Created March 6, 2016 20:31
Kills Ergosuite processes.
# for workplaces that have planted ergosuite s/w in the computers...
# get ergonomics s/w processes
$smergo = get-process smergo -erroraction silentlycontinue
$ergosuite = get-process ergosuite -erroraction silentlycontinue
if ($smergo) {
$smergo | stop-process -force
}
@gingeleski
gingeleski / maxSubArray.java
Last active September 20, 2016 00:20
Variant of Kadane's algorithm implemented in Java, using no Math calls
public class Main
{
public int maxSubArray(final List<Integer> a)
{
int ans = a.get(0);
int sum = a.get(0);
for (int i = 1; i < a.size(); i++)
{
if (sum + a.get(i) > a.get(i)) sum += a.get(i);
@gingeleski
gingeleski / gogo21_basic_sim.py
Last active December 15, 2016 01:35
A very basic simulator for GoGo 21 / Catch-21
from random import shuffle
class Hand:
def __init__(self):
self.cards = []
self.possible_values = [0]
self.blackjacks = 0
def can_add(self, card):
if (min(self.possible_values) + min(card)) <= 21:
@gingeleski
gingeleski / bucksFizz.java
Created January 18, 2017 00:58
Prints numbers 1 to 100, but for multiples of 3 prints “Bucks” instead and for multiples of 5 prints “Fizz”
public static void printBucksFizzOrNumber()
{
for (int number = 1; number <= 100; number++)
{
boolean hasThreeOrFiveAsMultiple = false;
// If number is a multiple of 3, print "Bucks" and set flag
if (number % 3 == 0)
{
hasThreeOrFiveAsMultiple = true;
@gingeleski
gingeleski / anaconda-python-3-download.jpg
Last active March 28, 2017 00:08
Keyword Captain wiki images
anaconda-python-3-download.jpg
@gingeleski
gingeleski / grab_all_dp.py
Created May 9, 2018 02:29
Download all cached Danger & Play posts. Dependencies: bs4, requests
from bs4 import BeautifulSoup
import requests
def get_all_links(r):
all_links = []
soup = BeautifulSoup(r.content,'lxml')
for url in soup.findAll('loc'):
all_links.append(url.string)
return all_links
@gingeleski
gingeleski / bad_sessions.py
Created June 9, 2019 20:24
Creates thousands of weak session token/cookie values. Used to demo Burp Suite Sequencer (you can "Manual Load" these in there) for security training.
import random
import string
bad_random_chars1 = 'ABCFG123' # length = 8
bad_random_chars2 = 'HIKLN589'
bad_random_chars3 = 'OQRTUVYZ'
number_of_tokens = 5000
for _ in range(number_of_tokens):