Skip to content

Instantly share code, notes, and snippets.

@tomcritchlow
tomcritchlow / 7books.py
Created November 9, 2010 23:23
The main code for 7books (www.7bks.com)
import cgi
import os
from google.appengine.ext.webapp import template
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.api import memcache
from google.appengine.api import urlfetch
@tomcritchlow
tomcritchlow / Google Docs Script
Created April 5, 2011 18:36
The Google Spreadsheets Script Used To Call Social Media APIs
function FBshares(url) {
var jsondata = UrlFetchApp.fetch("http://graph.facebook.com/"+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.shares;
}
function Tweets(url) {
var jsondata = UrlFetchApp.fetch("http://urls.api.twitter.com/1/urls/count.json?url="+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.count;
@tomcritchlow
tomcritchlow / pushstatecanonical.js
Created February 27, 2012 16:54
Proof of concept for pushtate + canonical tag
<script>
$(document).ready(function() {
if (canonical = $('link[rel=canonical]').attr('href'))
history.replaceState('', '', canonical);
});
</script>
function fetchInsta() {
var lat = ;
var long = ;
var apikey = ;
var url = "https://api.instagram.com/v1/media/search?lat="+lat+"&lng="+long+"&distance=400&access_token="+apikey+"&count=100";
Logger.log(url);
var result = UrlFetchApp.fetch(url);
var json = JSON.parse(result.getContentText());
<script>
function OpenInNewTab() {
var screenwidth = screen.width-500;
window.open("http://m.me/fiercelycurious", '_blank',"width=500,height=800,left="+screenwidth);
}
</script>
<a href="http://m.me/fiercelycurious" target="_blank" onclick="OpenInNewTab();"> <!-- m.me/facebookpage works for any facebook page -->
<div class="fbmessenger">
.fbmessenger{
position:fixed;
bottom:15px;
right:15px;
z-index:15;
}
.fbmessenger img{
width:50px;
filter: drop-shadow(2px 6px 4px rgba(0,0,0,.3));
hemioctahedron
Parabier won fle
Spiral
Hitesore curvet
Pentahedron
Great Lcetux
Trocor plian stat
drapnage pysshedtiptated of Var1
Lecthoctahedra
Cincagon
@tomcritchlow
tomcritchlow / hypothesis-gist.js
Last active June 29, 2020 16:29
Current customization for hypothesis annotation layer. See post here: https://tomcritchlow.com/2019/02/12/annotations/
<script type="application/json" class="js-hypothesis-config">
{
"openSidebar": false,
"theme": "clean"
}
</script>
<script src="https://hypothes.is/embed.js" async></script>
<script type="text/javascript">
@tomcritchlow
tomcritchlow / annotations.gs
Last active May 23, 2019 18:46
annotation-tracker-google-scripts
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var outputsheet = ss.getSheets()[0];
// get the existing IDs already in our spreadsheet in column A, sheet 1
var existingfeeddata = outputsheet.getRange("A:A").getValues();
var ids = [];
for(var i in existingfeeddata){
ids.push(existingfeeddata[i][0]); // convert 2d getvalues array to 1d array of IDs
}
@tomcritchlow
tomcritchlow / quote-text.js
Created June 19, 2019 18:46
A bookmarklet for turning selected text into a quote for markdown blogs
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}