Skip to content

Instantly share code, notes, and snippets.

View Zoybean's full-sized avatar

Zoey Hewll Zoybean

View GitHub Profile
@Zoybean
Zoybean / staq.py
Last active January 27, 2017 14:22
queue implemented with a pair of stacks
View staq.py
class staq:
def __init__(self, stack = []):
self.enqstk = stack
self.deqstk = []
def _swap(self):
if len(self.deqstk) == 0:
while len(self.enqstk) > 0:
_pus(self.deqstk, _pop(self.enqstk))
def enq(self, item):
_pus(self.enqstk, item)
@Zoybean
Zoybean / Pronounify.hs
Last active February 5, 2017 04:59 — forked from Qata/Pronounify.hs
View Pronounify.hs
import Data.String.Utils (replace)
import Data.Char (isUpper, toUpper)
import System.Environment (getArgs)
main :: IO ()
main = do
strings <- getArgs
mapM_ (putStrLn . pronounify) strings
capitalise :: String -> String
@Zoybean
Zoybean / fix-git
Last active March 19, 2021 12:54
For when you've got a local git repo that's just too hard to recover
View fix-git
#!/bin/bash
# Author: Zoey Llewellyn "Zobean" Hewll
#
# Usage: fix-git [REMOTE-URL]
# Must be run from the root directory of the repository.
# If a remote is not supplied, it will be read from .git/config
#
# For when you have a corrupted local repo, but a trusted remote.
# This script replaces all your history with that of the remote.
View Solomon Problem.hs
import Data.List (intercalate)
-- takes n from the start of a list and puts them at the end
wrap :: Int -> [a] -> [a]
wrap 0 xs = xs
wrap _ [] = []
wrap n (x:xs)
| n > 0 = wrap (n-1) (xs ++ [x])
| otherwise = undefined -- cannot move backward through the list
View cloner.rs
#![feature(cell_update)]
#[cfg(test)]
mod test {
use crate::*;
use std::cell::Cell;
#[test]
fn test() {
test_counter::<0>();