Skip to content

Instantly share code, notes, and snippets.

View defmech's full-sized avatar

David Lochhead defmech

View GitHub Profile
@anantn
anantn / angular_promise.html
Created April 3, 2013 19:21
An example showing the use of angular $q promises to authenticate a Firebase session and then writing data.
<html ng-app="test">
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.1/angular.min.js"></script>
<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase.js"></script>
</head>
<body ng-controller="Test">
<script typ="text/javascript">
function TestController($scope, $q) {
this._q = $q;
this._scope = $scope;
@simenbrekken
simenbrekken / firebase-auth-deferred.js
Created March 13, 2013 12:47
Easier Firebase authentication with jQuery Deferred
var db = new Firebase('https://demo.firebaseio.com')
var authenticate = (function(db) {
var loggedIn,
deferred = $.Deferred()
var client = new FirebaseAuthClient(db, function(err, user) {
loggedIn = !!user
if (err) {
@Anthelmed
Anthelmed / WRL loader and parser
Last active April 2, 2018 21:03
WRL loader/parser es6
/**
* WRLLoader class
*/
class WRLLoader {
/**
* load method
* @returns {Promise}
*/
load(path) {
const xhr = new XMLHttpRequest();
@TimvanScherpenzeel
TimvanScherpenzeel / .htaccess
Created May 8, 2019 13:28
Client side routing fix on reload
# BEGIN ROUTING
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
# END ROUTING
_.deburr("déjà vu");
// -> deja vu
_.deburr("Juan José");
// -> Juan Jose
@stolinski
stolinski / keybindings.json
Created June 21, 2017 23:10
VSCode Tab Switching Keybindings
[
{ "key": "ctrl+1", "command": "workbench.action.focusFirstEditorGroup" },
{ "key": "ctrl+2", "command": "workbench.action.focusSecondEditorGroup" },
{ "key": "ctrl+3", "command": "workbench.action.focusThirdEditorGroup" },
{ "key": "cmd+1", "command": "workbench.action.openEditorAtIndex1" },
{ "key": "cmd+2", "command": "workbench.action.openEditorAtIndex2" },
{ "key": "cmd+3", "command": "workbench.action.openEditorAtIndex3" },
{ "key": "cmd+4", "command": "workbench.action.openEditorAtIndex4" },
{ "key": "cmd+5", "command": "workbench.action.openEditorAtIndex5" },
{ "key": "cmd+6", "command": "workbench.action.openEditorAtIndex6" },
@mattt
mattt / UIImageForSwatchOfColorWithSize.h
Created September 27, 2013 01:25
Create a UIImage swatch of a color with a specified size.
static UIImage * UIImageForSwatchOfColorWithSize(UIColor *color, CGSize size) {
UIImage *image = nil;
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
{
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(c, [color CGColor]);
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
@pixelbacon
pixelbacon / MomentJS-iteration.js
Last active May 24, 2021 08:44
MomentJS iterate through daily start/end, check for clashes
var moment = require('moment'); // http://momentjs.com/docs/
var _ = require('lodash'); // https://lodash.com/docs
function(collectionsWithDateValues){
var slots = [];
var hours = {
start: 7, // 7am
end: 21, // 9pm
window: 2 // How long each item should be slotted for.
};
@drmikecrowe
drmikecrowe / app.js
Last active October 27, 2021 04:28
Sharing constants between node.js app and web app
//** In web app **//
var current = constants.STATE_WAITING;