Skip to content

Instantly share code, notes, and snippets.

View gingeleski's full-sized avatar
📈

Randy Gingeleski gingeleski

📈
View GitHub Profile
@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 / 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 / mergeSort.java
Created September 20, 2016 00:26
Merge sort implemented in Java
import java.util.ArrayList;
public class Main
{
public static ArrayList<Integer> mergeSort(ArrayList<Integer> ar)
{
if (ar.size() <= 1) return ar;
ArrayList<Integer> left, right;
left = new ArrayList<Integer>();
@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 / 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 / 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 / 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 / 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 / fibonacci.rb
Created February 8, 2015 23:21
Fibonacci sequence with and without recursion.
# Fibonacci sequence with and without recursion
def fibs(num) # Not recursive
return num if num <= 1
fib = 1
fib_prev = 1
count = 2
while count < num
@gingeleski
gingeleski / bubble_sort.rb
Created January 26, 2015 00:25
Simple bubble sort for numbers.
# Simple bubble sort for numbers
def bubble_sort(array_to_sort)
swap = true # Track whether swap has occurred
while swap
(0... array_to_sort.length - 1).each do |x|
# If we detect disorder...
if array_to_sort[x] > array_to_sort[x + 1]
# Perform a simple 3-step swap