Skip to content

Instantly share code, notes, and snippets.

@RainerAtSpirit
RainerAtSpirit / CustomBindingHandler.js
Created August 2, 2012 15:14
KnockoutJS, RequireJS and the revealing module pattern
define (['knockout', 'jquery', 'prettyDate', 'metrojs'], function ( ko, $ ) {
"use strict";
// See https://github.com/SteveSanderson/knockout/wiki/Bindings---class
ko.bindingHandlers['class'] = {
'update' : function ( element, valueAccessor ) {
if ( element['__ko__previousClassValue__'] ) {
ko.utils.toggleDomNodeCssClass (element, element['__ko__previousClassValue__'], false);
}
var value = ko.utils.unwrapObservable (valueAccessor ());
@thomaspark
thomaspark / subnav.css
Last active April 27, 2025 16:39
Subnav for Bootstrap 2
section {
padding-top: 60px;
}
.subnav {
margin-bottom: 60px;
width: 100%;
height: 36px;
background-color: #eeeeee; /* Old browsers */
background-repeat: repeat-x; /* Repeat the gradient */
@iki
iki / README.md
Last active December 14, 2015 18:49
Building Angular.js on Windows

Building Angular.js on Windows

Current grunt based build

  1. Install grunt launcher.

     npm install -g grunt-cli
    
  2. Run grunt as Administrator. That's needed to create directory symlinks using mklink /d.

@nailkhasipov
nailkhasipov / gist:5686588
Last active December 17, 2015 23:09
AngularJS directive for contenteditable that clear clipboard data on paste event
app.directive('contenteditable', function () {
return {
require: 'ngModel',
link: function (scope, elm, attrs, ctrl) {
// clear paste data
elm.bind('paste', function(e){
setTimeout(function() {
scope.$apply(function() {
ctrl.$setViewValue(e.target.innerText);
});
@pablojim
pablojim / hchart.js
Created June 23, 2013 17:01
hcharts & sparklines
'use strict';
angular.module('mydashApp')
.directive('hchart', function () {
var seriesId = 0;
var ensureIds = function(series) {
series.forEach(function(s) {
if(!angular.isDefined(s.id)) {
s.id = "series-" + seriesId++;
}
@eyston
eyston / controller.js
Created June 24, 2013 17:11
angular typeahead
angular.module('ymusica').controller('AlbumSearch', ['$scope', 'Albums', 'Artists', '$q', function($scope, albums, artists, $q) {
$scope.albums = [];
$scope.artists = [];
var terms = new Rx.Subject();
$scope.searchMusic = terms.onNext.bind(terms);
terms.sample(250)
@niquola
niquola / controller.coffee
Last active September 22, 2023 21:10
Progress indication in angularjs, while promises :)
MyController = ($scope, $resource)->
$scope.items = $resource.query()
@harperreed
harperreed / DownloadStationAPI.py
Last active September 10, 2024 20:07
example script to sync/download/etc put.io downloads to your synology download station
import time
import requests
import json
class DownloadStationAPI():
def __init__(self, host=None, username=None, password=None):
self.name = 'DownloadStation'
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 27, 2025 16:31
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@clouddueling
clouddueling / confirm.js
Created August 14, 2013 16:57
confirm directive angularjs
directives.directive('confirmButton', function($document) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var buttonId, html, message, nope, title, yep;
buttonId = Math.floor(Math.random() * 10000000000);
attrs.buttonId = buttonId;