Skip to content

Instantly share code, notes, and snippets.

View strukturedkaos's full-sized avatar

Don Pottinger strukturedkaos

View GitHub Profile
@strukturedkaos
strukturedkaos / controllers-3.js
Created June 18, 2014 14:33
addList function in Angular task list
$scope.addList = function() {
var newList = $scope.newList.trim();
if (!newList.length) {
return;
}
lists.push({
listId: Slug.slugify(newList + '-' + lists.length),
title: newList,
@strukturedkaos
strukturedkaos / controllers-2.js
Created June 18, 2014 14:30
Changing lists on Angular task list
// Monitor the current route for changes and adjust the filter accordingly.
$scope.$on('$routeChangeSuccess', function () {
if ($routeParams.listId) {
var listId = $routeParams.listId.split("-").pop()
var list = lists[listId];
if (list !== undefined && list !== $scope.currentList) {
$scope.currentList = list;
$scope.setTasks();
} else if (list !== $scope.currentList) {
@strukturedkaos
strukturedkaos / controllers-2.js
Last active August 29, 2015 14:02
Example of controllers.js for Angular task list
'use strict';
/* Controllers */
var taskListControllers = angular.module('taskListControllers', []);
taskListControllers.controller('TaskListCtrl', function TaskListCtrl($scope, $routeParams, $filter, $location, storage, Slug) {
'use strict';
var LIST_STORAGE_ID = 'lists';
storage.bind($scope, LIST_STORAGE_ID);
@strukturedkaos
strukturedkaos / task-list-1.html
Last active August 29, 2015 14:02
Example of single task list item in Angular task list
<li ng-class="{active: currentList.title == list.title}" ng-repeat="list in lists track by $index">
<a data-toggle="tab" href="#{{list.listId}}">
<span class="badge pull-right">{{list.remainingCount}}</span>
<div class="destroy pull-right glyphicon glyphicon-trash" ng-click="removeList(list)"></div>
<strong>{{list.title}}</strong>
</a>
</li>
@strukturedkaos
strukturedkaos / dependencies-2.html
Created June 18, 2014 04:37
Javascript dependencies for Angular task list
body>
<div ng-view></div>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
@strukturedkaos
strukturedkaos / dependencies-1.html
Created June 18, 2014 04:35
Dependencies for Angular Task List
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link href="css/app.css" media="all" rel="stylesheet">
<link href="bower_components/animate.css/animate.min.css" media="all" rel="stylesheet" type="text/css" />
<link href="css/animations.css" media="all" rel="stylesheet">
<link href="bower_components/font-awesome/css/font-awesome.min.css" media=all rel=stylesheet />
<script src="bower_components/modernizr/modernizr.js"></script>
@strukturedkaos
strukturedkaos / index-1.html
Created June 18, 2014 04:33
Beginning of angular task list app index template
<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en" ng-app="taskListApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="taskListApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="taskListApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="taskListApp" class="no-js"> <!--<![endif]-->
# encoding: binary
require 'active_model/validator'
class EmailValidator < ActiveModel::EachValidator
EmailAddress = begin
qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'
dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'
atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' +
'\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'
## This gist is intended to provide a code example for the
# 'Making Signed Requests' section of the 'Authentication Overview' document.
# (http://developer.netflix.com/docs/Security).
#
# We are going to make a catalog request. The hardest part of
# it is figuring out how to generate the oauth_signature.
require 'cgi'
require 'base64'
require 'openssl'
class PdfMerger
def merge(pdf_paths, destination)
first_pdf_path = pdf_paths.delete_at(0)
Prawn::Document.generate(destination, :template => first_pdf_path) do |pdf|
pdf_paths.each do |pdf_path|
pdf.go_to_page(pdf.page_count)