Skip to content

Instantly share code, notes, and snippets.

Drag this to your bookmark bar: <a href='javascript: (function () {
var pid;
var p_url;
var S = require("models/sound");
var playlists = require("models/playlist").instances._store;
for (p in playlists) {
p_url = playlists[p].attributes.permalink_url.split("/")[5];
if (p_url == window.location.pathname.split("/")[3]) {
pid = p;
@theophani
theophani / gist:4492648
Last active December 10, 2015 21:08
"by" and "until"

Germans have a hard time with by and until

-> Use by for actions that will be or must be performed at some moment before a time.

-> Use until for actions that continue and stop at a time.

Examples:

  • I work until 17:00. (working happens continuously)
  • I will leave by 17:00. (leaving happens once)
  • Give me the report by 17:00. (giving the report happens once)
@theophani
theophani / dabblet.css
Created November 7, 2012 16:23
Untitled
body {
background: #eef;
font-family: Monaco, Consolas, Inconsolata, 'Deja Vu Sans Mono', 'Droid Sans Mono', 'Andale Mono', 'Lucida Console', monospace;
margin: 20px;
font-size: 18px;
max-width: 30em;
}
@theophani
theophani / dabblet.html
Created November 6, 2012 18:42
Untitled
<br>
<br>
Drag this link into your
bookmark bar:
<a href='javascript: (function () {
var field = document.querySelector("#promotion_days");
@theophani
theophani / dabblet.html
Created November 6, 2012 18:33
Untitled
Drag this link into your
bookmark bar:
<a href='javascript: function () { var field = document.querySelector("#promotion_days"); function days(date) { var parts = date.split("-"); // YY-MM-DD var year = parseInt(parts[0]) + 2000; var month = parseInt(parts[1]) - 1; var day = parseInt(parts[2]); console.log(year, month, day); var now = new Date(); var then = new Date(year, month, day, 0,0,0,0); var days = Math.ceil((then - now) / 1000 / 3600 / 24); return days; } var date = prompt("When should this gift expire? Tell me in YY-MM-DD format!"); field.value = days(date);}'>Gift Expiry</a>
<br>
<br>
Then while looking at a gift form, click the bookmarklet :)
@theophani
theophani / dabblet.css
Created October 15, 2012 10:56
Untitled
body { font-size: 250px; }
.responsive-number { white-space: nowrap; }
.responsive-number > *:before { content: " "; /* six-per-em-space */ }
.responsive-number > :first-child:before {content: ""; }
@media (max-width: 1000px) {
.m-group:after { content: " M"; }
.k-group, .base-group { display: none; }
}
@media (max-width: 1300px) {
.k-group:after { content: " k"; }
@theophani
theophani / gist:2250859
Created March 30, 2012 11:14
Y U NO RESIZE? bookmarklet
// put this in a bookmarklet
// click it as required
javascript: (function () {
var style = document.createElement('style');
style.innerHTML = '* { -webkit-text-size-adjust:auto; }';
document.head.appendChild(style);
})();
console.log(Array.apply(null, Array(30)).map(Function.call.bind(Number)).map(Math.pow.bind(null, 2)))
> [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912]
@theophani
theophani / gist:1322203
Created October 28, 2011 12:56
best is also the best of the best
var best = function (array) {
if (!array.reduce) return array;
return array.reduce(function (p, c) {
if (c.reduce) {
return (p > best(c)) ? p : best(c);
}
return (p > c) ? p : c;
}, -Infinity);
};
@theophani
theophani / gist:1211161
Created September 12, 2011 12:40
bookmarklet for making Facebook stream more readable
javascript: (function(d) { var e = d.createElement('style'); e.innerHTML = ".uiStream .uiStreamMessage { font-size: 20px; } #rightCol { display: none; } .hasLeftCol .hasRightCol #contentArea { width: 759px; } .uiStreamStory { padding-right: 0; } .uiUfi { width: auto; } #leftCol { opacity: 0.5 } .uiStream .uiStreamHide { margin-right: 0; }"; d.body.appendChild(e); } )(document);