Skip to content

Instantly share code, notes, and snippets.

View jmccardle's full-sized avatar

John McCardle jmccardle

View GitHub Profile
#!/bin/bash
# ffmpeg video editing workflow script
set -e #exit immediately on errors
original_file=`basename "$1"`
cd `dirname "$1"`
if [ -z "$original_file" ]
then
echo "av_editing.sh - ffmpeg video editing workflow"
@jmccardle
jmccardle / generate_markdown_links.py
Last active September 6, 2018 02:55
Use youtube-dl to turn a Youtube playlist into a set of Markdown embeddable image links.
import random, time, copy
def new_grid(width, height):
grid = []
for x in range(width):
column= []
for y in range(height):
column.append('#' if random.randint (0,1) else ' ')
grid.append(column)
return grid
@jmccardle
jmccardle / weed_infestation.py
Last active January 5, 2023 15:57
CasualMath - Weed Infestation
rules = {2: 5, 7: 1}
weeds = [10]
def pick(w, pick, grow):
if w == pick: return 0
return w - pick + grow
step = 0
while 0 not in weeds:
print(f"{step}:{weeds}")
from datetime import date, timedelta
def eight_digit_date(d: str):
return all([str(x) in d for x in range(8)])
valid_dates = []
d = date(year=2000, day=1, month=1)
while d.year < 2100:
if eight_digit_date(d.isoformat()): valid_dates.append(d)
d += timedelta(days=1)
# How many bananas can you bring 1,000 miles away, if your camel eats 1 banana per mile?
class CamelJourney:
def __init__(self, distance=1000, start=3000, capacity=1000):
self.map = [start] + [0] * (distance - 1)
self.aboard = 0
self.position = 0
self.capacity = capacity
self.current_cache = 0
self.N = 4 # tuned for this puzzle
#include <Python.h>
#include <iostream>
// init_python - configure interpreter details here
PyStatus init_python(const char *program_name)
{
PyStatus status;
PyConfig config;
PyConfig_InitPythonConfig(&config);
// Python script engine includes
#include <Python.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
// SFML
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
// Python script engine includes
#include <Python.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
// SFML
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
// Python script engine includes
#include <Python.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
// SFML
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>