Skip to content

Instantly share code, notes, and snippets.

View premasagar's full-sized avatar

Prem Rose premasagar

View GitHub Profile
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name, ?depiction, ?thumbnail, ?influences, ?abstract
WHERE {
<http://dbpedia.org/resource/Isaac_Newton> rdfs:label ?name;
foaf:depiction ?depiction ;
<http://dbpedia.org/ontology/thumbnail> ?thumbnail;
<http://dbpedia.org/ontology/abstract> ?abstract.
http://collectionsonline.nmsi.ac.uk/grabimg.php?kv=107931 - painting; portrait
http://collectionsonline.nmsi.ac.uk/grabimg.php?kv=109011 - Isaac Newton’s reflecting telescope (replica)
http://collectionsonline.nmsi.ac.uk/grabimg.php?kv=107901 - print; portrait
http://collectionsonline.nmsi.ac.uk/grabimg.php?kv=126567 - medal
http://collectionsonline.nmsi.ac.uk/grabimg.php?kv=55342 - Metal spectacles with small thick oval lenses, as suggested
http://collectionsonline.nmsi.ac.uk/grabimg.php?kv=107052 - Newton's furnace, 1696-1727.
http://collectionsonline.nmsi.ac.uk/grabimg.php?kv=126565 - Royal Society Medal
http://collectionsonline.nmsi.ac.uk/grabimg.php?kv=122835 - Engraving: The paternal house of Sir Isaac Newton ... born 2
@premasagar
premasagar / _gzip.js
Created August 11, 2010 17:57 — forked from bga/_gzip.js
window._gzip = (function()
{
var _matchCount = function(s, word)
{
var n = 0, wordLen = word.length, p = -wordLen;
while((p = s.indexOf(word, p + wordLen)) > -1)
++n;
return n;
@premasagar
premasagar / 7z-ultra.sh
Created August 28, 2010 23:00
7z command line: adds directory "mydirectory" to archive myarchive.7z, using "ultra settings"
#!/bin/sh
# adds directory "mydirectory" to archive myarchive.7z, using "ultra settings"
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on myarchive.7z mydirectory
@premasagar
premasagar / numb.js
Created August 29, 2010 09:25
random numbers, ranges, rounding and more
var numb = {
/*
random integer
call it with the length of an array; returns a random
index or, if no argument suppplied, returns 0 or 1
e.g.
randomInt(); // will return 0 or 1
randomInt(3); // will return 0, 1 or 2
Rules on omitting quotation marks from HTML5 attributes:
http://www.w3.org/TR/html-markup/syntax.html#syntax-attr-unquoted
An unquoted attribute value has the following restrictions:
* must not contain any literal space characters
* must not contain any """, "'", ">", "=", characters
* must not be the empty string
@premasagar
premasagar / enumerables.js
Created January 17, 2011 17:59
Enumerable arrays and objects - useful methods
var forEach = Array.prototype.forEach ?
function(array, fn, thisp){
return array.forEach(fn, thisp);
} :
function(array, fn, thisp){
var i = 0,
arrayCopy = Object(array),
length = arrayCopy.length;
for (; i < length; i++){
// Use the test to create a simple element positioning function
function positionElemSimple(elem, x, y){
elem.style.cssText = "position:absolute;top:" + y + "px;left:" + x + "px;";
return elem;
}
function positionElem3d(elem, x, y){
var translate3d = "transform:translate3d(" + x + "px," + y + "px,0);";
@premasagar
premasagar / tim-lite-min.js
Created March 18, 2011 05:53
Tim (lite), renamed to timLite, for including in perf tests at http://jsperf.com/dom-vs-innerhtml-based-templating/111
var timLite=function(){var e=/{{\s*([a-z0-9_][\\.a-z0-9_]*)\s*}}/gi;return function(f,g){return f.replace(e,function(h,i){for(var c=i.split("."),d=c.length,b=g,a=0;a<d;a++){b=b[c[a]];if(b===void 0)throw"tim: '"+c[a]+"' not found in "+h;if(a===d-1)return b}})}}();
@premasagar
premasagar / tim-lite-cached-min.js
Created March 18, 2011 05:53
Tim (lite, cached), renamed to timLiteCached, for including in perf tests at http://jsperf.com/dom-vs-innerhtml-based-templating/111
var timLiteCached=function(){function i(b,e){return b.replace(m,function(g,c){for(var j=c.split("."),k=j.length,h=e,f=0;f<k;f++){h=h[j[f]];if(f===k-1)return h}})}var m=RegExp("{{\\s*([a-z0-9_][\\.a-z0-9_]*)\\s*}}","gi"),d={},l=window.JSON;return l?function(b,e){var g=l.stringify(e),c=d[b]&&d[b][g];if(c)return c;d[b]||(d[b]={});return c=d[b][g]=i(b,e)}:i}();