Skip to content

Instantly share code, notes, and snippets.

Xanir

  • Minnesota
Block or report user

Report or block Xanir

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View EventManager.js
var EventManager = function() {
var emitter = this;
// Map of even names to list of event callbacks
emitter.events = {};
};
/*
Registerer a callback function for a specific event
*/
@Xanir
Xanir / Flexy css
Last active Apr 6, 2017
Flex Layout
View Flexy css
[flexy],
[flexy=h] {
flex-wrap: nowrap;
display: flex;
> * {
flex: 1 1 auto;
display: block;
View Keyboard Command Key
var isCommandKey = function (keycode) {
if (keycode < 47) {
// Most Command Keys
return true;
} else if (keycode === 91 || keycode === 92 || keycode === 93) {
// Windows keys
return true;
} else if (keycode === 144 || keycode === 145) {
// Scroll Lock / Num Lock
View Interesting in the DOM
document.createTreeWalker(root, whatToShow, filter, entityReferenceExpansion);
CSS.supports(prop, value)
performance.timing
View Javascript Define Property by Mask
/*
* :: function setProp ::
*
* nMask is a bitmask:
* flag 0x1: property is enumerable,
* flag 0x2: property is configurable,
* flag 0x4: property is writable (only applies if no setterFn is passed),
* obj is the object on which to define the property;
* propName is the name of the property to be defined or modified;
* getterVal is the value or getter function to assign;
@Xanir
Xanir / Generic
Last active Aug 29, 2015
Angular I18N Initalization Format
View Generic
(function (angular) {
"use strict";
var mod;
try {
mod = angular.module(!*ANGULAR_PACKAGE*!);
} catch(e) {}
if (mod) {
mod.config(function ($translateProvider) {
var i18nValues = !*LOCALE_MAP*!;
$translateProvider.translations(!*LOCALE_CODE*!, i18nValues);
View Mod Function
var escapeRegexpSpecialChars = function(str) {
return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
var funcModder = function(func, replacements) {
var funcStr = func.toString();
Object.keys(replacements).forEach(function(replaceKey) {
var escappedReplacement = escapeRegexpSpecialChars(replaceKey);
funcStr = funcStr.replace(new RegExp(escappedReplacement, 'g'), replacements[replaceKey]);
});
return (function() {eval('var fn = ' + funcStr); return fn;})().toString(); // jshint ignore:line
View gist:b64ff36ce20b5046722a
module.directive("wrapper", function( $compile ) {
var priority = 123456;
return {
restrict: "A",
terminal: true,
priority: priority,
compile: function( $element, $attrs ) {
var directiveName = this.name;
@Xanir
Xanir / httpd.conf
Last active Aug 29, 2015
Apache Multi-Domain CORS Support
View httpd.conf
<IfModule mod_headers.c>
SetEnvIf Origin "http(s)?://(www\.)?(myhost.com|myhos2,net):(80|8080)" AccessControlAllowOrigin=$0$1
Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials true
</IfModule>
@Xanir
Xanir / gist:ac55fd3065904b6c06cf
Last active Aug 29, 2015
AutoComplete Grouping Directive
View gist:ac55fd3065904b6c06cf
Use in row template for AutoComplete hints.
module.directive('grouping', function($timeout) {
return {
restrict: 'AE',
link: function (scope, element, attr) {
$timeout(function() {
var groupClass = scope.groupClass;
var groupLabel = scope.groupLabel;
var newElem = angular.element('<div class="' + groupClass + '">' + groupLabel + '</div>');
You can’t perform that action at this time.