New API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) ) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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/ | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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; } |
NewerOlder