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
@anasnakawa
anasnakawa / wrapper.js
Created October 20, 2013 07:17
AMD / CommonJs (NodeJs) / Browser wrapper pattern
// AMD / Common Js / Browser Wrapper pattern
// copyright to [millermedeiros](https://github.com/millermedeiros/js-signals/blob/master/src/wrapper.js)
// ---------------------------------
(function(global){
var libName;
// define your library
//exports to multiple environments
if(typeof define === 'function' && define.amd){ //AMD
@anasnakawa
anasnakawa / tiny-js-pubsub.js
Last active February 2, 2023 08:14
very tiny Pub/Sub implementation that utilizes native browser event methods. ( only browsers .. no IE8 )
/*! Js Pub/Sub
* http://anasnakawa.com/
* Copyright (c) Anas Nakawa
* inspired by Ben Alman's one <https://gist.github.com/cowboy/661855>
* MIT License
*/
(function( p ) {
var e = p.e = {};
var elementToCheck;
var DELAY = 200;
function checker() {
elementToCheck = document.querySelector('#spoAppComponent');
if(elementToCheck != null) {
putBreakPoint();
return;
}
// otherwise, keep listening
/**
* when you open https://status.aws.amazon.com/, trying to find what went wrong on a specific day,
* it can become hard to notice the blue & yellow circles among thousands of green check marks
* open the developer tools, and add the following css, and you'll only see errors
*/
/* hide green mark */
img[src*="/images/status0.gif"],
/* hide disabled (-) mark */
img[src*="status-disabled.gif"] {
/**
* acceps colors as arguments, and will simply print them out to console
*
* e.g: console.color('red', 'blue', 'green'); // prints red, blue and green squares
*/
console.color = function() {
var result = '';
var args = [];
for(var i = 0; i < arguments.length; i++) {
result += '%c ' + arguments[i] + ' ';
<script type="text/javascript">
(function() {
'use strict';
/**
* configurations
*/
var tickersClass = 'my-paused-text-shows';
@anasnakawa
anasnakawa / ko-component-class.js
Created June 9, 2013 13:18
knockout js component class
// ui component class structure
// ----------------------------
(function(sandbox) {
'use strict';
var Component = function(foo, bar) {
this.foo = foo;
this.bar = bar;
@anasnakawa
anasnakawa / rotate-tabs.html
Created June 14, 2018 12:53
snippet when it will be added to the page, it will rotate tabs every few seconds
<script type="text/javascript">
(function() {
'use strict';
/**
* configurations
*/
var tabsClass = 'my-rotating-tabs'; // <- put the css class of the tabs you want to control
@anasnakawa
anasnakawa / pause-ticker.html
Last active June 14, 2018 12:13
snippet when it will be added to the page, it will pause one or more tickers shortpoint elements
<script type="text/javascript">
(function() {
'use strict';
/**
* configurations
*/
var tickersClass = 'my-paused-ticker';