Skip to content

Instantly share code, notes, and snippets.

View richshaw's full-sized avatar

Richard Shaw richshaw

View GitHub Profile
@richshaw
richshaw / loan.sol
Created July 22, 2021 19:21
Video Rental loan Ethereum smart contract
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;
/* *
* "Video Rental" Loan
* Alice lends Bob x eth
* Bob owes principle + interest on borrowed eth until term ends
* If Bob does not repay borrowed eth before the term ends then
* Bob will incur a late fee in the form of a higher interest rate.
@richshaw
richshaw / MTurk update workerlist.R
Last active September 30, 2016 19:46 — forked from arnoud999/MTurk update workerlist.R
Excluding MTurk workers who participated in your previous studies: An R solution
############################################################################
# #
# Excluding participants who participated in previous studies #
# By Arnoud Plantinga, based on Gabriele Paolacci's Excel solution #
# #
# Instructions (Note: edit only the non-indented lines): #
# #
# 1. Create a qualification (e.g., "Study 1"; keep in mind that the name #
# will be visible to Workers) in MTurk/Manage/Qualification Types #
# #
@richshaw
richshaw / fonts.sh
Created August 12, 2016 17:36
List fonts used in pdf file, terminal
strings file.pdf | grep FontName
@richshaw
richshaw / sitemetadata.r
Created August 11, 2016 06:09
Get website metadata
library("rvest", lib.loc="/usr/local/lib/R/3.3/site-library")
getMetaData <- function (sites) {
url <- c()
domain <- c()
lang <- c()
name <- c()
description <- c()
type <- c()
@richshaw
richshaw / index.php
Last active April 5, 2016 19:00
Confidence Interval of Proportions
<?php
/**
* Function to get confidence interval of proportions in PHP
* Based on https://onlinecourses.science.psu.edu/stat200/node/48
*/
/**
* Calculates CI, defaults to 95% z of 1.96
* for 99% use z of 2.58
*/
@richshaw
richshaw / slider.js
Created January 20, 2016 03:05
How to customize Slider labels in Shiny
$(document).ready(function() {
var now = new Date();
var now_bin = now.getHours() * 2; // bin number, 30-minute bins
if (now.getMinutes() >= 30) {
now_bin += 1;
}
/**
Function to convert bin numbers 0 to 47
@richshaw
richshaw / Example1.bson
Created June 27, 2014 14:08
Bot content data structure examples
{
_id: ObjectId("525db371b1e6020700000001"),
bot_id: "525db35a18f354a034000000",
link: "http://www.guernicamag.com/features/the-naked-man/",
link_hash: "21eb41e9cfca527d9827084db5953e22c9742d4a653fab9c23dabb58be9d6aa4",
source: "primal",
created: ISODate("2013-10-15T21:28:08.033Z"),
content: "An, er, intimate reconsideration of male nudity.",
title: "The Naked Man",
type: "news",

README is empty

@richshaw
richshaw / README.md
Last active August 29, 2015 14:02
#Beautiful images data

Table data of a images of people tagged as #beautiful on Instagram

@richshaw
richshaw / README.md
Last active August 29, 2015 14:02
#Beautiful images graph

A sample of 1000 #beautiful images were automatically analysed using an automated visual analytics API from Alchemy.

Graph was generated automtaically in R using D3 network package.