Skip to content

Instantly share code, notes, and snippets.

View gearsdigital's full-sized avatar

Steffen Giers gearsdigital

View GitHub Profile
@gearsdigital
gearsdigital / chatting.js
Created March 31, 2017 20:53 — forked from bmeck/chatting.js
a chat server using generators to manage connection state.
'use strict';
/*::
type Client = Object;
type Channel = string;
*/
const channels/*: Map<Channel, Set<Client>> */ = new Map;
const clients/*: Map<Client, Set<Channel>> */ = new WeakMap;
const join = (name, client) => {
if (!channels.has(name)) {
@gearsdigital
gearsdigital / sticky-nav.js
Created April 27, 2016 12:26 — forked from arielsalminen/sticky-nav.js
Simple sticky nav in plain JS
// Simple sticky nav in plain JS
// p.s. this is just a short example, you should remember to debounce the scroll event ;-)
if ("addEventListener" in window && "classList" in document.documentElement) {
var element = document.getElementById("nav"),
offset = element.offsetTop;
window.addEventListener("scroll", function() {
if (offset < window.pageYOffset) {
element.classList.add("fixed");
// Post repeat directive for logging the rendering time
angular.module('myApp').directive('postRepeatDirective',
['$timeout',
function($timeout) {
return function(scope) {
if (scope.$first)
window.a = new Date(); // window.a can be updated anywhere if to reset counter at some action if ng-repeat is not getting started from $first
if (scope.$last)
$timeout(function(){
console.log("## DOM rendering list took: " + (new Date() - window.a) + " ms");
angular.module('services', [])
.factory('State', function ($rootScope) {
'use strict';
var state;
var broadcast = function (state) {
$rootScope.$broadcast('State.Update', state);
};
var update = function (newState) {
@gearsdigital
gearsdigital / gist:1958811
Created March 2, 2012 14:41 — forked from anonymous/gist:1904282
Ant With Colors in OS X Terminal
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
ant () { command ant -logger org.apache.tools.ant.listener.AnsiColorLogger "$@" | sed 's/2;//g' ; }