Skip to content

Instantly share code, notes, and snippets.

@tomrandle
tomrandle / gist:8229157
Created January 2, 2014 23:21
jQuery to extract old style Flickr embed image. Run in console by right clicking 'inspect element' then changing to the console tab, pasting the code in a and pressing enter. You need the bit that's returned in the format <a href=""><img src=""></a>
var imageSource = $('.main-photo').src;
var photoPage = window.location.href;
var htmlString = '<a href="' + photoPage + '"><img src="' + imageSource + '"></a>';
console.log(htmlString);
@tomrandle
tomrandle / clubhouse-stylish.css
Last active September 21, 2016 14:31
Custom styling that adds avatars to clubhouse
/* Yes, I'm going to CSS hell! Install stylish browser extension then add this for clubhouse.io */
/* We don't find story and user ID useful so hide them */
.bucket-content .story-id,
.project-name {
display: none;
}
/* Font size 0 needed to hide forward separator between owners */
.bucket-content .story-summary {
@tomrandle
tomrandle / openlunch.js
Last active October 17, 2016 13:52
openlunch
function openLunch() {
var restaurant = sheet.getRange("B1").getValues()[0][0];
var deadline = sheet.getRange("B2").getValues()[0][0];
triggerSlackRequest("main", "@london: FRIDAY LUNCH: *"+ restaurant +"*. Please order by *"+ deadline +"*. Cheers.\n"+ sheetURL);
createTimeTriggers(2);
}
@tomrandle
tomrandle / createTimeTrigger.js
Created October 17, 2016 13:56
createTimeTrigger
function createTimeTriggers(hour) {
ScriptApp.newTrigger('lunchReminder')
.timeBased()
.everyHours(hour)
.create();
ScriptApp.newTrigger('notifyOrdersAppearCompleted')
.timeBased()
.everyMinutes(5)
.create();
@tomrandle
tomrandle / triggerSlackRequest.js
Created October 17, 2016 13:57
triggerSlackRequest
function triggerSlackRequest(channel, msg) {
var slackWebhook = "YOUR PERSONAL SLACK TOKENIZED URL";
var payload = { "channel": channel, "text": msg, "link_names": 1, "username": "lunchbot", "icon_emoji": ":hamburger:" };
var options = { "method": "post", "contentType": "application/json", "muteHttpExceptions": true, "payload": JSON.stringify(payload) };
Logger.log(UrlFetchApp.fetch(slackWebhook, options));
}
@tomrandle
tomrandle / notifyOrdersAppearCompleted.js
Created October 17, 2016 13:58
notifyOrdersAppearCompleted
function notifyOrdersAppearCompleted() {
var curHour = new Date().getHours();
var notifiedCell = sheet.getRange("F3").getValues()[0][0];
if (notifiedCell == true) {
return
}
if (curHour > 17 || curHour < 9) {
Logger.log("Outside work hours stopping");
@tomrandle
tomrandle / closeLunch.js
Created October 17, 2016 13:59
closeLunch
function closeLunch() {
var triggers = ScriptApp.getProjectTriggers();
updateUnattendingRows();
triggerSlackRequest("main", "Lunch orders are now closed");
triggerSlackRequest(completedOrdersUser, "Lunch is now officially closed");
for (var i = 0; i < triggers.length; i++) {
if (triggers[i].getHandlerFunction() == "lunchReminder" || triggers[i].getHandlerFunction() == "notifyOrdersAppearCompleted") {
ScriptApp.deleteTrigger(triggers[i]);
@tomrandle
tomrandle / updateUnattendingRows.js
Created October 17, 2016 14:00
updateUnattendingRows
function updateUnattendingRows() {
var attendingValues = sheet.getRange(startRow,4,rowRange,1).getValues();
var color = "lightgrey"
for (var i = 0; i < attendingValues.length; i++) {
var rr = sheet.getRange("A"+(i+startRow)+":I"+(i+startRow))
if(attendingValues[i][0] === false && rr.getBackground() != color) {
rr.setBackground(color);
} else {
@tomrandle
tomrandle / lunchReminder.js
Created October 17, 2016 14:02
lunchReminder
function lunchReminder() {
var curHour = new Date().getHours();
if (curHour > 17 || curHour < 9) {
Logger.log("Outside work hours stopping");
return
}
var completedValues = sheet.getRange(startRow,1,rowRange,1).getValues();
var slackNames = sheet.getRange(startRow,2,rowRange,1).getValues();
@tomrandle
tomrandle / start-standup.AppleScript
Last active August 14, 2022 20:57
Applescript for automatically starting standup
on run argv
# Set variables
set chrome to "Google Chrome"
set zoom to "zoom.us"
set wait to 0.5
set initialWindow to "Zoom - Pro Account" # If you're not using Zoom Pro you will need to change this
tell application chrome
if it is running then