Skip to content

Instantly share code, notes, and snippets.

View restlessmedia's full-sized avatar
🎯
Focusing

Phil Cooper restlessmedia

🎯
Focusing
View GitHub Profile
@restlessmedia
restlessmedia / gist:ff09ab58fc53d3cdf495
Created May 8, 2014 09:12
Responsive images using inline styles
<html>
<head></head>
<body>
<img class="image"/>
<style type="text/css">
.image {
background-color: grey;
@restlessmedia
restlessmedia / gist:36dcf9161356b805d796
Last active August 29, 2015 14:01
Multiple template fetching with promises
var getTemplate = function(url){
var deferred = $.Deferred();
// simulate latency
setTimeout(function(){
deferred.resolve('template-result-done-'+url);
}, 1000);
return deferred.promise();
}
var fetch = function(/* params string[] urls */){
@restlessmedia
restlessmedia / gist:351340bc3af843dd18f5
Last active August 29, 2015 14:03
Javascript prototype inheritance
var app = {};
Function.prototype.inherits = function (base) {
var isFunction = base.constructor == Function;
this.prototype = isFunction ? new base : base;
this.prototype.constructor = this;
return this;
};
(function (app) {
@restlessmedia
restlessmedia / RequestMessageExtensions.cs
Last active August 29, 2015 14:03
RequestMessageExtensions MultipartDataAsync for working with file uploads in Web api. Supports chunked requests.
using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace restlessmedia.UI.Api.Extensions
@restlessmedia
restlessmedia / gist:2317b8337aa20b7cec97
Last active August 29, 2015 14:04
DropZone - jQuery drag and drop wrapper
// var upload = function (url, files) {
// var data = new FormData();
// app.utils.forEach(files, function () {
// data.append('file', this);
// });
// return send({ type: 'POST', url: url, data: data, contentType: false, processData: false });
// }
(function ($, app) {
@restlessmedia
restlessmedia / gist:1356aea6367ce20a3392
Created July 25, 2014 10:08
Azure container name validation
public static class Validator
{
public static bool IsValidName(string name)
{
if (string.IsNullOrEmpty(name))
return false;
const string rootName = "$root";
if (name.Equals(rootName))
@restlessmedia
restlessmedia / example.html
Last active August 29, 2015 14:05
Simple loader
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css"/>
<style type="text/css">
.loading {
position: absolute;
left: 0;
top: 0;
opacity: 0;
@restlessmedia
restlessmedia / bookmarklet.js
Created September 19, 2014 09:24
Trello visible card counter bookmarklet
javascript:alert([].join.call($('.list:not(.add-list)').map(function(){return $(this).find('h2').text() + ': ' + $(this).find('.list-card:not(.hide)').length}),'\n') + '\n\n' + 'Total: ' + $('.list-card:not(.hide)').length)
@restlessmedia
restlessmedia / gist:12a249faf2007870500f
Last active August 29, 2015 14:11
scrolly a window scroll listener
var scrolly = (function () {
var isDrag = false;
var lag = 100;
var isMouseDown = false;
var listeners = {};
var previous;
var Bounce = function (delegate, lag) {
var that = this;
@restlessmedia
restlessmedia / tap.js
Last active August 29, 2015 14:14
Handing touch events
var tap = (function () {
var isSwipe = false;
var handlers = {};
var eventTypes = {
swipe: 'swipe',
tap: 'tap'
};
var applyEach = function (arr, context, args) {