Skip to content

Instantly share code, notes, and snippets.

<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">
@thinsoldier
thinsoldier / typographic-calculated.js
Last active August 29, 2015 14:08
Show all calculated styles related to typography of an element
function typographyInfo( element )
{
var styles = getComputedStyle(element);
var props = ['font-family','font-size','line-height','margin-top','margin-bottom','padding-top','padding-bottom'];
console.log(element);
for( i in props )
{
@thinsoldier
thinsoldier / html-to-json.js
Last active August 29, 2015 14:08
extracting data from html to json
toplevel = $('#subnav > ul > li > a');
var all = [];
toplevel.each(function(i,x){
//console.log(i, x);
var data = {};
data.id = i + 500;
data.slug = x.href.split('#').pop();
data.headline = $(x).text();
@thinsoldier
thinsoldier / detect duplicate ids
Created March 6, 2015 17:51
Detect duplicate id's in html document.
jq = jQuery;
var collection = {};
// change selector to * for everything use it to limit the kinds of nodes that get inspected.
jq('[name*=amenities]').each(
function(i,e){
var found = jq('[id=' + e.id + ']');
var count = found.length;
@thinsoldier
thinsoldier / gist:c5af3b8eff46cbe344ac
Created March 26, 2015 17:26
How to find out in which SVN revision a file was deleted.
How to find out in which SVN revision a file was deleted.
This will give you the revisions for all the actions (add, delete, remove, modify) concerning the file
svn log -v --limit <nr> -v | grep -E '<fileName>|^r' | grep -B 1 <fileName>
where:
<fileName> - the name of the file or any pattern which matches it
<nr> - how many revisions deep into the past in which I want to look for
<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">
@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 / 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 = {};