Skip to content

Instantly share code, notes, and snippets.

@E01T
E01T / basic.md
Created March 22, 2018 17:04 — forked from zenorocha/basic.md
New Firebase Auth vs Old Firebase Auth
@E01T
E01T / modulo.py
Created November 6, 2017 10:10
Modulo in Python 3
# Also check math.fmod() and divmod
for i in range(20):
print(i%10)
print('\n')
for index, i in enumerate(range(-20,0)):
print('{:d}%10 {: d}'.format(i, i%10) )
@E01T
E01T / modulo.js
Last active February 5, 2020 09:24
Correct Modulo in JavaScript
// From https://stackoverflow.com/questions/10063546/modulo-for-negative-dividends-in-python?noredirect=1&lq=1
// a % b = a - (a // b) * b
const divMod = (a, b) => {
return a - Math.floor(a / b) * b;
}
for (let i = 0; i < 20; i++) {
console.log(divMod(i, 10));
}
/*
* A script found in crius theme (bottom) that
* inserts google analytics at the bottom of the page
* https://developers.google.com/analytics/devguides/collection/gajs/
*/
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21959663-3']);
<script type="text/javascript">
(function(){
var e=document.createElement("script");
e.type="text/javascript";
e.async=true; /* Maybe async is overstatement (pleonasmos) it is already created asynchronously. */
e.src=document.location.protocol+"//d1agz031tafz8n.cloudfront.net/thedaywefightback.js/widget.min.js";
var t = document.getElementsByTagName("script")[0];
t.parentNode.insertBefore(e,t)})()
</script>
@E01T
E01T / gist:8912148
Created February 10, 2014 08:14 — forked from isGabe/gist:3072378
<?php
/*
**** Load jQuery from Google CDN if available, local fallback if not ****
** Place in your theme's functions.php or relevant file. Edit local jQuery path if needed.
** Works as-is with WordPress Bones Theme v1.2 https://github.com/eddiemachado/bones (replace wp_enqueue_script( 'jquery' ); on line 142
** reference: http://wp.tutsplus.com/tutorials/load-jquery-from-google-cdn-with-local-fallback-for-wordpress/
*/
@E01T
E01T / getElementsByClassName.js
Created July 26, 2013 12:07
getElementsByClassName shims. Various shims solving this problem
/*
All the getElementsByClassName functions below are in:
http://snook.ca/archives/javascript/your_favourite_1
*/
if( typeof document.getElementsByClassName !== "function"){
document.getElementsByClassName= function( className, nodeName ){
var a = [];
var re = new RegExp('(^| )'+className+'( |$)');
var els = nodeName.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
/*!
* JavaScript preload() function
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Demo: http://mathiasbynens.be/demo/javascript-preload
*/
function preload(arr) {
var i = arr.length,
@E01T
E01T / array_index_of.js
Created July 13, 2013 07:23
How to fix Array indexOf() in JavaScript for IE browsers
/*
If you have worked with JavaScript at any length you are aware that IE does not implement
the ECMAScript function for Array.prototype.indexOf() [including IE8]. Not a huge problem
because you can extend the functionality on your page with the following code.
*/
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }