Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

smac89

🎯
Focusing
View GitHub Profile
@smac89
smac89 / sln.html
Last active Aug 29, 2015
CMPT 280 sample final tentative solutions
View sln.html
<head>
<style>
li{
margin: 5px 0;
}
</style></head>
<ol>
<li>
<ol type="a">
<li>(3 points) What are the three components that an Abstract Data Type has, regardless of the method of ADT specification used? <em>(Note: not looking for sets, syntax, semantics..." here, those are components of a specific ADT specification method.)</em><br/><br/>
@smac89
smac89 / Timetable.md
Last active Aug 29, 2016
[SOLVED] The struggle to print your u of s schedule without unnecessary details filling up the page
View Timetable.md

This is a method to get a clear, printable version of your uofs time table. This method involves a little work from you, then the attached app below does the rest. For this method to work well, you need to use firefox browser, as the end result looks off on chrome.

  1. Open your schedule in a browser:

  1. Right-click anywhere in the page and select Inspect Element:

  2. Inside the new window, type table.datadisplaytable into the search bar:

@smac89
smac89 / ObservableStack.java
Last active May 14, 2018
A simple implementation of a JavaFX observable stack
View ObservableStack.java
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Smac89
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
@smac89
smac89 / .gitconfig
Last active Jun 21, 2017
Gitconfig settings to use p4merge on windows using Cygwin terminal
View .gitconfig
[merge]
tool = p4merge
[mergetool "p4merge"]
path = "C:/PROGRA~1/Perforce/p4merge.exe"
[mergetool]
keepBackup = false
trustExitcode = false
[diff]
tool = p4merge
@smac89
smac89 / p4merge.sh
Created May 6, 2016
Script to install p4merge on Linux
View p4merge.sh
#!/bin/bash
set -euf
if [[ ! "$#" = 1 ]]; then
echo "You need to supply the folder containing p4merge as arguement"
exit 1
elif [[ ! -d "$1" ]]; then
echo "The file is not a folder"
exit 1
@smac89
smac89 / RandJoin.py
Last active May 20, 2016
Version of python's string join which allows for random seperators
View RandJoin.py
import random
def join_rand(words, *sep):
return reduce(lambda joined, new: random.choice(sep).join((joined, new)), words)
@smac89
smac89 / readwords.py
Last active Nov 29, 2016
Efficient method to read words from a file.
View readwords.py
import itertools
def readwords(file_object):
byte_stream = itertools.groupby(
itertools.takewhile(lambda c: bool(c),
itertools.imap(file_object.read,
itertools.repeat(1))), str.isspace)
return ("".join(group) for pred, group in byte_stream if not pred)
@smac89
smac89 / install_ffmpeg.sh
Last active Jun 23, 2018
Install latest version of ffmpeg on Ubuntu
View install_ffmpeg.sh
#!/bin/bash
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev
# Create a dir where the rest of the sources will live
mkdir ~/ffmpeg_sources
@smac89
smac89 / BitmapDrawableFromDrawable.java
Created Jun 27, 2016
Converts drawable image to BitmapDrawable
View BitmapDrawableFromDrawable.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.Canvas;
public static final class BitmapDrawableFromDrawable {
public static BitmapDrawable drawableToBitmapDrawable (Context ctx, Drawable drawable) {
Bitmap bitmap;
if (drawable instanceof BitmapDrawable) {
@smac89
smac89 / fpr.py
Last active May 10, 2020
Floating point regex: A regular expression to match any valid python floating point value.
View fpr.py
# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
# See it in action https://regex101.com/r/ObowxD/5
import re
regex = r"""
(?xm)
(?:\s|^)
([-+]*(?:\d+\.\d*|\.?\d+)(?:[eE][-+]?\d+)?)
You can’t perform that action at this time.