Skip to content

Instantly share code, notes, and snippets.

@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
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 / 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 = {};
@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.
*/
<?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)
{
// 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)
var count = 0;
function cc(card) {
// Only change code below this line
data = {};
for ( x of [2,3,4,5,6] ){ data[x] = 1; }
for ( x of [7,8,9] ){ data[x] = 0; }
@thinsoldier
thinsoldier / form1.js
Last active January 9, 2017 04:46
EzReports.org - set default values for the fields that never change
/*
-----------------------------
2017-01-08
-----------------------------
Birthday Defaults
grade 1: 01/01/2009
grade 2: 01/01/2008
grade 3: 01/01/2007
grade 4: 01/01/2006
#!/usr/bin/env php
<?php
// 2016-12-06 github.com/thinsoldier
error_reporting(E_ALL);
//-----------------------------
if( !isset($argv[1]) ) {
echo "CODEPEN PEN URL MUST BE PROVIDED!";
@thinsoldier
thinsoldier / index.html
Last active December 6, 2016 15:16
YpaBOB
<!--
version history:
too many dots
-->
<h1>Once upon a time...</h1>
<p>first foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar </p>
<p>foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar </p>