Skip to content

Instantly share code, notes, and snippets.

Avatar
🦜
VP Eng @ FirstAML

Alex Henderson bittercoder

🦜
VP Eng @ FirstAML
View GitHub Profile
@bittercoder
bittercoder / FileArranger.cs
Created Jan 28, 2019
C# program to arrange movies into folders, then those folders in groups by first letter (A-Z...)
View FileArranger.cs
using System;
using System.IO;
using System.Linq;
namespace FileArranger
{
class Program
{
static void Main(string[] args)
{
@bittercoder
bittercoder / convert.sh
Last active Aug 13, 2022
Convert .heic files to .jpg on linux (coming from an iOS11 device over USB)
View convert.sh
# 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 Dec 16, 2015
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.
View gist:5506001
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 Feb 20, 2013
Example of an ExtJS mix-in to render a chart title on the top of a chart.
View MyApp.ChartTitleMixin.js
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 Dec 7, 2012
Babysteps rules (with git hints)
View babysteps.txt
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 Dec 7, 2012
no-conditionals conways rules
View conwayrules.js
var evalRules = function(isAlive, neighbours) {
var isAliveAfterTick = false;
var dead = function() {
isAliveAfterTick = false;
return true;
};
var live = function() {
View gist:4076233
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 Nov 5, 2012
Generic list of actions
View gist:4014624
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));
}
View MemoryTributary.cs
/// <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 Sep 1, 2012
Monkey Coconuts Brute Force
View Program.cs
namespace MonkeyCoconuts
{
class Program
{
static void Main(string[] args)
{
for (int i=0; i<10000000; i++)
{
if (test(i))
{