Skip to content

Instantly share code, notes, and snippets.

angular.module('myApp')
.run(['$rootScope', function ($rootScope) {
window.i18n.init(options, function () {
// When finished loading translations, trigger re-evaluation of views for translations
$rootScope.$digest();
});
}])
.filter('translate', [function(){
return function(key, params) {
// i18next needs time to initialize (loading translations). In this phase translation does not work
// Example Data
var CARS = [
{name: "Ferrari FF", horsepower: 660, dollar_value: 700000, in_stock: true},
{name: "Spyker C12 Zagato", horsepower: 650, dollar_value: 648000, in_stock: false},
{name: "Jaguar XKR-S", horsepower: 550, dollar_value: 132000, in_stock: false},
{name: "Audi R8", horsepower: 525, dollar_value: 114200, in_stock: false},
{name: "Aston Martin One-77", horsepower: 750, dollar_value: 1850000, in_stock: true},
{name: "Pagani Huayra", horsepower: 700, dollar_value: 1300000, in_stock: false}
];
@mooz
mooz / set-mark-with-ctrl-space-mac.ks.js
Created October 18, 2010 10:29
Set mark with Ctrl+Space key on Mac
(function () {
const KeyCodes = {
Space : 32,
Ctrl : 17
};
let ctrlOn = true;
function keyDownHandler(ev) {
switch (ev.keyCode) {
@nrabinowitz
nrabinowitz / README.md
Created December 9, 2012 20:51
Raster geocoding with D3.js

This demonstrates raster-based reverse geocoding using canvas and D3.js. Geocoding is based on the color of the pixel at a given projected position. Note that the canvas is only shown here for the sake of explanation and debugging - this would in fact probably work faster if the canvas was not attached to the document at all.

The biggest remaining issue here is precision, which depends on:

  • the size of the canvas, and
  • the projection used.

Determining the optimum size based on the accuracy of your data is left as an exercise for the reader. Edge cases will also fail here, generally returning null - one option might be to stroke neighborhoods in a color, and then return an "uncertain" value for any non-grayscale pixel.

@tomstove
tomstove / europe.topo.json
Created April 25, 2013 12:53
UK Satellite Projection D3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cburgmer
cburgmer / ng-i18next-filter.js
Created October 18, 2013 09:08
Simple i18next translation filter for angular This solves async issues with the filter accessing the translation function before i18next is ready. The solution here is not optimal but clearly maps out the solution, something that https://gist.github.com/archer96/5239617 or https://github.com/archer96/ng-i18next/blob/master/src/provider.js fails …
angular.module('myApp')
.run(['$rootScope', function ($rootScope) {
window.i18n.init(options, function () {
// When finished loading translations, trigger re-evaluation of views for translations
$rootScope.$digest();
});
}])
.filter('translate', [function(){
return function(key, params) {
// i18next needs time to initialize (loading translations). In this phase translation does not work
/*
* twitter-entities.js
* This function converts a tweet with "entity" metadata
* from plain text to linkified HTML.
*
* See the documentation here: http://dev.twitter.com/pages/tweet_entities
* Basically, add ?include_entities=true to your timeline call
*
* Copyright 2010, Wade Simmons
* Licensed under the MIT license
app.directive('infiniteScroll', [
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) {
return {
link: function(scope, elem, attrs) {
var checkWhenEnabled, handler, scrollDistance, scrollEnabled;
$window = angular.element($window);
elem.css('overflow-y', 'scroll');
elem.css('overflow-x', 'hidden');
elem.css('height', 'inherit');
scrollDistance = 0;
@hostsamurai
hostsamurai / canvas.html
Created July 1, 2011 16:54
Light flickering effect using html5 canvas and JavaScript
<canvas width=220 height=150></canvas>
@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)