Skip to content

Instantly share code, notes, and snippets.

View anasnakawa's full-sized avatar
💭
I may be slow to respond.

Anas Nakawa anasnakawa

💭
I may be slow to respond.
View GitHub Profile
<script type="text/javascript">
(function() {
document.title = '';
function getNow() {
return ( Math.round( performance.now() / 10 ) / 100 );
}
document.addEventListener( 'DOMContentLoaded', function() {
document.title = 'dm:' + getNow();
});
<script type="text/javascript">
(function() {
'use strict';
/**
* hook method to be executed as soon as shortpoint
* is available in the page
*/
function initHook() {
@anasnakawa
anasnakawa / shortpoint-ready.html
Last active May 1, 2017 09:08
a code that when added into a Script Editor Web Part, on a site that has ShortPoint installed, will be executed as soon as ShortPoint is ready on the page.
<script type="text/javascript">
(function() {
'use strict';
/**
* hook method to be executed as soon as shortpoint
* is available in the page
*/
function initHook() {
// open http://requirebin.com/, paste the following snippet
// and play with the following variable to see the output in action
var cssColorManipulation = 'color( #7A256D s(+ 5%) l(+ 43) )';
var color = require('css-color-function');
var updatedColor = color.convert( cssColorManipulation );
console.clear();
console.log( updatedColor );
document.body.style.backgroundColor = updatedColor;
@anasnakawa
anasnakawa / remove-shortpoints-inserter.js
Last active August 31, 2016 10:47
remove single or multiple shortpoint elements from inserter
(function() {
'use strict';
/**
* hook method to be executed as soon as shortpoint
* is available in the page
*/
function initHook() {
/**
* knockout observable subscriber that will get triggered only once at most
*
* @param {fn} handler
* @param {object} [optional] context
*/
ko.observable.fn.subscribeOnce = function( handler, context ) {
var subscribtion = this.subscribe(function() {
handler.apply( this, arguments );
@anasnakawa
anasnakawa / isRtl.js
Last active August 29, 2015 14:20
detect html document if it has right-to-left layout, even if direction is provided using css and not as an attribute.
/**
* polyfill `getComputedStyle` in IE
*/
window.getComputedStyle = window.getComputedStyle || function( element ) {
return element.currentStyle;
}
/**
* detect RTL layout
@anasnakawa
anasnakawa / SassMeister-input.scss
Created April 1, 2015 14:27
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
// rtl variables
$bi-app-left : right;
$bi-app-right : left;
$bi-app-direction : rtl;
$bi-app-invert-direction: ltr;
/**
* polyfilling console.time & timeEnd
* on IE
*/
(function( console ) {
// cache to hold running timers
console._timers = {};
@anasnakawa
anasnakawa / sass-charset-node.js
Last active August 29, 2015 14:05
adding `charset "utf-8"` to all sass files in the current directory
/**
* node js module to add `@charset "utf-8"` to all
* sass files in the current directory
* -----------------------------------
* sovles this bug:
* https://github.com/sass/sass/issues/1037
* https://github.com/Compass/compass/issues/205
*/
var fs = require( 'fs' );