Skip to content

Instantly share code, notes, and snippets.

View psyked's full-sized avatar

James Ford psyked

View GitHub Profile
{
"GPSLatitudeRef": "N",
"GPSLatitude": [ 52, 39, 15.8 ],
"GPSLongitudeRef": "W",
"GPSLongitude": [ 0, 30, 20.45 ],
"GPSAltitudeRef": 0,
"GPSAltitude": 62.632075471698116,
"GPSTimeStamp": [ 19, 21, 42 ],
"GPSSpeedRef": "K",
"GPSSpeed": 0,
const ExifImage = require('exif').ExifImage;
new ExifImage({ image: './input-file.jpg' }, function (error, exifData) {
if (error) throw error;
const { gps } = exifData;
console.log(gps);
}
@psyked
psyked / upload.js
Created May 15, 2017 20:49
Uploading a file to Trello API with Node.js
'use strict'
const fs = require('fs')
const path = require('path')
const Trello = require('node-trello')
const trelloAuth = JSON.parse(fs.readFileSync('trello-credentials.json', 'utf8'))
const t = new Trello(trelloAuth.key, trelloAuth.token)
t.post(`/1/cards/${card.id}/attachments`, {
This file has been truncated, but you can view the full file.
{"lighthouseVersion":"1.4.1","generatedTime":"2017-01-27T21:08:44.717Z","initialUrl":"https://www.psyked.co.uk/","url":"https://www.psyked.co.uk/","audits":{"is-on-https":{"score":true,"displayValue":"","rawValue":true,"name":"is-on-https","category":"Security","description":"Site is on HTTPS","helpText":"All sites should be protected with HTTPS, even ones that don't handle sensitive data. HTTPS prevents intruders from tampering with or passively listening in on the communications between your app and your users, and is a prerequisite for HTTP/2 and many new web platform APIs. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/https)."},"redirects-http":{"score":true,"displayValue":"","rawValue":true,"name":"redirects-http","category":"Security","description":"Site redirects HTTP traffic to HTTPS","helpText":"If you've already set up HTTPS, make sure that you redirect all HTTP traffic to HTTPS. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/http-redirects-to-https).
@psyked
psyked / gist:5847065
Last active November 13, 2018 15:35
JavaScript Observer Pattern - Module Pattern implementation
var Observable = (function()
{
"use strict";
/**
* @constructor
* @returns {{attach: Function, detach: Function, notify: Function}}
*/
var constructor = function()
{
@psyked
psyked / gist:5729474
Created June 7, 2013 14:02
Regex find & replace to swap expect & toBe parameters for Jasmine tests
expect\(([#a-zA-Z0-9,.'\(\) ]*?)\)\.toBe\(([#a-zA-Z0-9,.'\(\) ]*?)\);
expect($2).toBe($1);
@psyked
psyked / implementation.js
Last active December 17, 2015 06:48
An example of how the Decorator pattern might work in Javascript.
// ==== Sample implementation
var modal = new Modal();
modal.maximise(); // outputs "Error: undefined is not a method (windowInstance.maximise)"
MaximiseDecorator.addTo(modal);
modal.maximise(); // outputs "I'm going to maximse myself!"
MaximiseDecorator.removeFrom(modal);
modal.maximise(); // outputs "Error: undefined is not a method (windowInstance.maximise)"
@psyked
psyked / gist:5237761
Last active December 15, 2015 09:19
Converting old ActionScript 2 trace(); statements to HTML5-eque console.log() statements with a regular expression
Find: trace\(([A-Z a-z 0-9"'=_\-.+,\\/\(\)\[\]:#!<>%]*)\);
Replace: ExternalInterface.call("console.log", $1);
@psyked
psyked / RateMe.js
Created March 7, 2012 10:08 — forked from dawsontoth/app.js
"Rate my app in Appcelerator Titanium Mobile" as a commonJS module.
function RateMe(ios_url, goog_url, usecount) {
if(!Ti.App.Properties.hasProperty('RemindToRate')) {
Ti.App.Properties.setString('RemindToRate', 0);
}
var remindCountAsInt = parseInt(Ti.App.Properties.getString('RemindToRate'), 10);
var newRemindCount = remindCountAsInt += 1;
if(remindCountAsInt === -1) {
// the user has either rated the app already, or has opted to never be
// reminded again.
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.psyked.co.uk%2Fflash%2Ffotb2011-highlight-1.htm&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 30px; align: left; margin: 2px 0px 2px 0px"></iframe>