Skip to content

Instantly share code, notes, and snippets.

View supasympa's full-sized avatar
🎧
💻⌨️🖥 @barclaytweets

Lewis Barclay supasympa

🎧
💻⌨️🖥 @barclaytweets
  • Supa Sympa Ltd
  • London
View GitHub Profile
@supasympa
supasympa / download-web-page-locally.sh
Created February 13, 2016 12:21
Download a web page locally
wget http://mywebsite.co.uk -e robots=off -H -p -k
@supasympa
supasympa / responsive-vs-adaptive.md
Created December 23, 2015 07:12
Responsive vs Adaptive web design

Responsive vs adaptive

Responsive design works on the principle of flexibility - a single fluid website that can look good on any device. Responsive websites use media queries, flexible grids, and responsive images to create a user experience that flexes and changes based on a multitude of factors.

Adaptive design is more like the modern definition of progressive enhancement. Instead of one flexible design, adaptive design detects the device and other features, and then provides the appropriate feature and layout based on a predefined set of viewport sizes and other characteristics

From this article

@supasympa
supasympa / javascript & angular test
Last active December 11, 2015 10:44
Simple Javascript and Angular test for developers
JAVASCRIPT - around 60 mins to complete:
/* code */
var wordsCollection = [];
var sentence = 'A sentence of words that we\'d like to seperate';
var position = 0;
function splitSentence(s, i){
var parts;
/**
* gets the number of milliseconds from a date using a date format.
* @param dateString : the date to convert
* @param format : the format the date is in
* @returns Milliseconds from 01/01/1970
*/
return function (dateString, format){
function getDatePart(part){
var re, start, end;
@supasympa
supasympa / AngularJS mocking resource dependencies in tests
Created July 11, 2014 10:35
An example of hot to mock reource dependencies in tests as see in the video: AngularJS mocking resource dependencies in tests
beforeEach(function () {
mockAccessTokenResource = jasmine.stub();//stub of resource
module(function ($provide) {
$provide.value('AccessToken', mockAccessTokenResource);
})
});
@supasympa
supasympa / osxHiddenfiles
Created July 5, 2014 13:46
enable disabled hidden files in finder ...
Run the following command to show hidden files:
defaults write com.apple.finder AppleShowAllFiles TRUE;killall Finder
Run the following command to hide hidden files:
defaults write com.apple.finder AppleShowAllFiles FALSE;killall Finder
@supasympa
supasympa / backbone click proxy
Created December 13, 2013 11:45
click proxy for backbone
//<a href="#/my/application/route" rel="" data-forproxy="{myproxy:data}">Some link</a>
var someView = {
events : {
'click a[rel="proxy"]' : clickProxy
},
clickProxy : function(e){
var $anc, proxyData, route;
@supasympa
supasympa / model replacments
Created September 26, 2013 08:26
Replace a string with model object properties
var M = function(){
}
M.prototype = {
format : function(){
var s = "/data/mu/programs/{{programCode}}/campaign-mus/{{muid}}/validate";
var r = /{{[a-zA-Z_-]*}}/gi.exec(s);
var key = '';
while(r!==null){
@supasympa
supasympa / StringFormat
Created July 2, 2013 14:34
A simple string format function replacing items in a string with their respective strings / numbers in a map.
define([],
function () {
var resolvePath = function (path, map) {
var pathParts, i, ctx;
ctx = map;
i = 0;
pathParts = path.split('.');
@supasympa
supasympa / mustard-cutting-browserdetection.js
Created April 23, 2013 07:58
Test for minimal browser requirements when including jQuery
if ('querySelector' in document &&
'localStorage' in window &&
'addEventListener' in window) {
// bootstrap the JavaScript application
}