Skip to content

Instantly share code, notes, and snippets.

View tim545's full-sized avatar

Tim tim545

  • Australia
View GitHub Profile
@tim545
tim545 / json2.js
Created July 28, 2015 05:03
JSON 2 JS converter, theoretically....
"object" != typeof JSON && (JSON = {}),
function() {
"use strict";
function f(t) {
return 10 > t ? "0" + t : t
}
function quote(t) {
return escapable.lastIndex = 0, escapable.test(t) ? '"' + t.replace(escapable, function(t) {

Detect a mobile device in Javascript

This function will return true for any mobile device and false if not mobile.

//initiate as false
var isMobile = false;

// device detection
@tim545
tim545 / New dev machine setup (Mac).md
Last active October 14, 2015 23:12
New development machine setup (Mac)

New development machine setup (Mac)

An attempt to store the steps for setting up a mac from scratch for web development. (Excluding any language-spcefic dependencies, for example Node.js or Ruby would not be listed here). Also note that this list only uses open source software, so replace anything with a paid alternative if appropriate.

These should be done in order:

Show hidden files by default

  • open Terminal and run defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder
@tim545
tim545 / randomArrayItem.js
Last active December 11, 2015 05:44
Add a method to the Array prototype to return a random array item
// Adds a method to the Array prototype to return a random array item
Array.prototype.random = function() {
return this[Math.floor(Math.random() * this.length)];
};
@tim545
tim545 / node-setup.md
Last active May 9, 2016 23:10
Set up a dev machine to work on NodeJs projects
@tim545
tim545 / sublime-setup.md
Last active June 8, 2016 09:57
Sublime Text 3 Settings

Setup a new installation of Sublime Text

These instructions will set up sublime with some good setting and packages quickly.

Add key bindings

These key bindings do two things:

  • Add's camel case stops in word seperations which helps with keyboard navigation
  • Add's a new shortcut alt+space which toggles the sidebar on and off for some nice full-width distraction free coding Copy and paste the code into your user key bindings file.
@tim545
tim545 / working-with-docker.md
Last active June 14, 2016 10:27
Working with Docker

Working with Docker

Although Docker has a huge learning curve, it also has a rewarding goal. Once you understand the docker way, things which were previously a blocker to your development can be done surprisingly easily.

Your production environment becomes the same as your development environment, making deployments simple.

Keeping your dev machine clean of muliple language dependencies also becomes a reality.

Difficult concepts

@tim545
tim545 / gist:1e10d066eeec6694ea08a1322f857f00
Created September 14, 2017 00:06 — forked from philfreo/gist:0a4d899de4257e08a000
4 different ways to save a Highcharts chart as a PNG (with and without a server)
// Method 1: simply use Highcharts built-in functionality (SVG -> Highcharts server -> PNG)
// Downside: won't work in webview native apps that don't handle the form response
highcharts.exportChart({
filename: filename
});
@tim545
tim545 / tech-reads.md
Last active March 15, 2018 23:02
Good technical articles

Good Technical Articles

This is a running list (in no particular order) of good articles/posts/tutorials I find on the web. I have tried to keep it narrowed down to articles which are in a sense 'timeless' in that they don't just teach something about a particular framework but also have something to be learnt about programming in general.

Conventions

@tim545
tim545 / zerowidthspace.md
Last active August 11, 2019 14:51
The most evil character in Unicode

'Zero Width Space' character

I had some trouble with this character in a client project, it was hidden inside a configuration string which is validated in the clients API. It's basically invisible, literally a space character with zero width, it could not be seen but it was breaking at the API because it would not validate, causing problems with hundreds of user accounts.

The Unicode value of this character is U+200B, and it's evil, very evil. Lying in wait to break your applications while leaving no sign of it's presence...

It also has some friends, check the answer of this Stack Overflow question

In my project, it was one of my colleuges who managed to find the character, he re-copied the string into the code and Git showed that the line had been changed, even though all the Git GUI's didn't actually show any difference. He ran git diff in the command line and this did show the Unicode character being deleted, that's somet