Skip to content

Instantly share code, notes, and snippets.

// https://www.freecodecamp.com/challenges/chunky-monkey/
function chunkArrayInGroups(arr, size) {
// avoid infinite loop
if( arr.length === 0 || size === 0)
{ return false; }
var chunkedList = [];
for ( var i=0; i < arr.length; i += size)
<?php
$statusArray = array();
$allURLs = array("https://kat.cr/usearch/life%20of%20pi/","https://en.wikipedia.org/wiki/Basketball","https://kat.cr/usearch/life%20of%20pi/","https://en.wikipedia.org/wiki/Basketball");
foreach( $allURLs as $key => $value )
{
$handle = fopen( $value, "r");
if ($handle)
{
@thinsoldier
thinsoldier / getroomvalues.php
Last active April 23, 2016 11:08
Esau date diff problem
<?php
//-----------------------------
/*
It is not safe to rely on the system's timezone settings.
You are *required* to use the date.timezone setting
or the date_default_timezone_set() function.
*/
@thinsoldier
thinsoldier / log-computed-style.js
Last active November 26, 2015 18:42
How to extract computed style of dom nodes as text that can be compared in a text editor.
function logComputedStyles(elem,prop) {
var cs = window.getComputedStyle(elem,null);
if (prop) {
console.log(" "+prop+" : "+cs.getPropertyValue(prop)+"\n");
return;
}
var len = cs.length;
var list = {};
var reportMouse = function(x,y)
{
text("x: "+ mouseX +" y: "+mouseY, x, y);
};
var pointWithinRect = function(pointX, pointY, x, y, w, h)
{
if(pointX > x && pointX < x+w && pointY > y && pointY < y+h)
{return true;} else {return false;}
};
@thinsoldier
thinsoldier / git-submodule-add-from-gitmodules-file
Created October 19, 2015 17:29
When you want to use a pre-existing .gitmodules file to set up submodules on another repository.
#!/bin/sh
# http://stackoverflow.com/a/11258810/1154693
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path
@thinsoldier
thinsoldier / code.js
Created September 25, 2015 21:09
CodeCombat - Kithgard Dungeon - forgetful-gemsmith
// http://codecombat.com/play/level/forgetful-gemsmith
// This function allows passing in a string of directions
// which will be converted into calls to the standard
// this.move____() functions.
this.moveSequence = function( instructions )
{
// Remove spaces from the instructions using a "greedy" Regular Expression.
var clean_instructions = instructions.replace( / /g, '' );
@thinsoldier
thinsoldier / find-position-absolute-elements.js
Last active April 11, 2016 07:42
Find every element that has position:absolute applied.
$('*').each( function(index,element)
{
if( getComputedStyle(element).position === 'absolute' )
{
console.log( element )
}
})
@thinsoldier
thinsoldier / google photos progress bar numbers
Last active April 11, 2016 07:45
Google Photos - When you would rather see an accurate number instead of a progress bar
// When you would rather see an accurate number instead of a progress bar:
// http://jsbin.com/bomirabewa/2/edit?html,css,js,output
//-----------------------------
window.requestAnimationFrame(barmeasure);
function barmeasure()
{
document.querySelector('title').innerText = document.querySelector('.i9Crcb').style.transform.replace('translateX(','');
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../google-map/google-map-search.html">