Skip to content

Instantly share code, notes, and snippets.

View bittercoder's full-sized avatar
:shipit:
CTO @ Zoolibrary

Alex Henderson bittercoder

:shipit:
CTO @ Zoolibrary
View GitHub Profile
@bittercoder
bittercoder / FileArranger.cs
Created January 28, 2019 02:37
C# program to arrange movies into folders, then those folders in groups by first letter (A-Z...)
using System;
using System.IO;
using System.Linq;
namespace FileArranger
{
class Program
{
static void Main(string[] args)
{
@bittercoder
bittercoder / convert.sh
Last active March 28, 2024 18:54
Convert .heic files to .jpg on linux (coming from an iOS11 device over USB)
# download release from github: https://github.com/monostream/tifig/releases and install at ~/tools/tifig
# then run these commands in the folder (just to keep things simple we normalize the file extension case before proceeding).
for f in *.HEIC; do mv "$f" "`echo $f | sed s/.HEIC/.heic/`"; done
for file in *.heic; do echo "~/tools/tifig -v -p $file ${file/%.heic/.jpg}"; done
@bittercoder
bittercoder / gist:5506001
Last active December 16, 2015 22:19
Turns out there's a maximum limit on setInterval after which it will fire immediately, rather then what you expect (which is to never fire) on chrome/firefox.
var a = function() {
alert('bang!');
}
var signedIntMax = 2147483647;
var signedIntMaxPlus1 = signedIntMax+1; // will cause bang immediately on webkit/firefox but not IE
setInterval(a, signedIntMaxPlus1);
@bittercoder
bittercoder / MyApp.ChartTitleMixin.js
Created February 20, 2013 03:56
Example of an ExtJS mix-in to render a chart title on the top of a chart.
Ext.define("MyApp.ChartTitleMixin", {
createTitleItem: function() {
this.chartTitle = new Ext4.draw.Sprite({
type: "text",
"text-anchor": "middle",
fill: "black",
"font-size": "12px",
"font-weight": "bold",
"font-family": "Arial",
text: this.title
@bittercoder
bittercoder / babysteps.txt
Created December 7, 2012 10:36
Babysteps rules (with git hints)
Grab git from here if you don't have it (and don't have another SCM you want to use instead):
http://git-scm.com/downloads
Initialize a git repository.
mkdir session3
cd session3
git init
@bittercoder
bittercoder / conwayrules.js
Created December 7, 2012 09:55
no-conditionals conways rules
var evalRules = function(isAlive, neighbours) {
var isAliveAfterTick = false;
var dead = function() {
isAliveAfterTick = false;
return true;
};
var live = function() {
public namespace MyCompany.MyProject.MyFeature {
public class MySuite {
public MySuite() {
// SetupSomeTestData in here - but oh noi throw an error.
throw new Exception("bang!");
}
[Fact]
@bittercoder
bittercoder / gist:4014624
Created November 5, 2012 00:58
Generic list of actions
public class GenericActionList
{
readonly IList<Action<object>> _actions = new List<Action<object>>();
public void AddAction<T>(Action<T> action)
where T : class
{
_actions.Add(input => Invoke(action, input));
}
@bittercoder
bittercoder / MemoryTributary.cs
Created September 1, 2012 21:33
MemoryTributary
/// <summary>
/// MemoryTributary is a re-implementation of MemoryStream that uses a dynamic list of byte arrays as a backing store, instead of a single byte array, the allocation
/// of which will fail for relatively small streams as it requires contiguous memory.
/// </summary>
public class MemoryTributary : Stream /* http://msdn.microsoft.com/en-us/library/system.io.stream.aspx */
{
#region Constructors
public MemoryTributary()
{
@bittercoder
bittercoder / Program.cs
Created September 1, 2012 20:42
Monkey Coconuts Brute Force
namespace MonkeyCoconuts
{
class Program
{
static void Main(string[] args)
{
for (int i=0; i<10000000; i++)
{
if (test(i))
{