Skip to content

Instantly share code, notes, and snippets.

@ethyde
ethyde / universal_amd_cjs_plainjs.js
Created December 12, 2016 15:13
Universal JS module loader
/*
* From http://ifandelse.com/its-not-hard-making-your-library-support-amd-and-commonjs/
* http://ricostacruz.com/cheatsheets/umdjs.html
*/
(function (root, factory) {
if(typeof define === "function" && define.amd) {
// Now we're wrapping the factory and assigning the return
// value to the root (window) and returning it as well to
// the AMD loader.
@ethyde
ethyde / debounce.js
Created November 1, 2016 15:31
JS Native debounce function
// from : http://qnimate.com/javascript-limit-function-call-rate/
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this,
args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
@ethyde
ethyde / .bash_alias
Last active November 24, 2016 08:58
Git Config files
#!/bin/bash
alias g='git'
alias gs='git status'
<html>
<head>
<style>
.item {width:300px; display: inline-block; }
.item .itemtitle {font-weight:bold; font-size:2em;}
.hidden {display:none;}
</style>
</head>
<body>
<h1>Amalgam Comics Characters</h1>
<!-- Progressive Enhancements -->
<style>
/* Media Queries */
@media screen and (max-width: 480px) {
/* What it does: Forces table cells into full-width rows. */
.stack-column {
display: block !important;
width: 100% !important;
max-width: 100% !important;
@ethyde
ethyde / getCoordinate.js
Created January 10, 2016 18:52
getCoordinate of any box in JS
var getCoordinate = function(elemId, parentId){
var element = document.getElementById(elemId);
var context = document.getElementById(parentId);
var bodyRect = context.getBoundingClientRect(),
pointPos = element.getBoundingClientRect(),
offsetY = pointPos.top - bodyRect.top;
offsetX = pointPos.left - bodyRect.left;
centerX = offsetX + pointPos.width / 2;
@ethyde
ethyde / .bash_profile
Created December 3, 2015 11:06
Bash profile load ssh-agent and add all key in ~/.ssh/id_rsa*
# SSH Agent
# Note: ~/.ssh/environment should not be used, as it
# already has a different purpose in SSH.
# source : https://www.schoonology.com/technology/ssh-agent-windows/
env=~/.ssh/agent.env
# Note: Don't bother checking SSH_AGENT_PID. It's not used
# by SSH itself, and it might even be incorrect
# (for example, when using agent-forwarding over SSH).
@ethyde
ethyde / Gruntfile.js
Last active July 17, 2023 12:47
Grunt config for PostCSS
/**
* @fileOverview Gruntfile tasks. These tasks are intended to help you when modifying the template. If you are
* just using the template, don't sweat this stuff. To use these tasks, you must install grunt, if you haven't already,
* and install the dependencies. All of this requires node.js, of course.
*
* Install grunt:
*
* npm install -g grunt-cli
*
* Then in the directory where you found this file:
<!doctype html>
<html>
<head>
<title>Kitchen sink</title>
<style>
body { margin: 0 5%; }
.colA { width: 45%; float: left; margin-right: 5%; }
.colB { width: 45%; float: left; }
@ethyde
ethyde / kitchensink.html
Created September 9, 2015 16:16
Kitchen Sink HTML
<article>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
<section>
<h1>Heading 1 (in section)</h1>