Skip to content

Instantly share code, notes, and snippets.

View JCGrant's full-sized avatar
🤓

James Grant JCGrant

🤓
View GitHub Profile
@JCGrant
JCGrant / SquaresAndTS.hs
Last active December 3, 2015 01:55
Square numbers which remain squares with the last digit removed
isSquare :: Integer -> Bool
isSquare x
= root ^ 2 == x
where
root = floor $ sqrt $ fromIntegral x
isTruncatedSquare :: Integer -> Bool
isTruncatedSquare x
| x < 10 = False
| otherwise = isSquare $ x `div` 10
@JCGrant
JCGrant / AppendedSquareChains.hs
Created December 3, 2015 06:21
Chains of square numbers which remain squares when repeatedly adding digits. [1,16,169] appears to be the only chain with a length greater than 2.
import Data.Maybe
isSquare :: Integer -> Bool
isSquare x
= root ^ 2 == x
where
root = floor $ sqrt $ fromIntegral x
append :: [Integer] -> Integer -> [Integer]
append ys x

Keybase proof

I hereby claim:

  • I am JCGrant on github.
  • I am jcgrant (https://keybase.io/jcgrant) on keybase.
  • I have a public key whose fingerprint is B919 ED51 D5B6 464F DE65 8485 1EBB D452 BD82 D307

To claim this, I am signing this object:

@JCGrant
JCGrant / shush.se-x.user.js
Last active November 10, 2016 23:05
Adds various features to Shush.se
// ==UserScript==
// @name Shush.se - Extra Features
// @namespace https://gist.github.com/JCGrant/45fdb9a8a14d7c05dc6ac70123f2d7cb
// @version 0.5
// @description Adds various features to Shush.se
// @author JCGrant
// @match http://www.shush.se/index.php*
// @grant none
// @updateURL https://gist.github.com/JCGrant/45fdb9a8a14d7c05dc6ac70123f2d7cb/raw/shush.se-x.user.js
// ==/UserScript==
/*
* Copy and paste the following code after clicking
* NEW GAME at http://guessthecorrelation.com.
* Tested and works in Chrome. Not sure about other
* browsers due to usage of ES6 features.
*/
const parseTransformStringIntoPoint = (transformString) => {
let splitString = transformString.split(',');
let xString = splitString[0].substring(10, splitString[0].length);
@JCGrant
JCGrant / hide-youtube-comments.user.js
Created September 5, 2016 15:32
A User Script which hides the comments section on Youtube
// ==UserScript==
// @name Hide Youtube Comments
// @namespace https://gist.github.com/JCGrant/8b7c64c4ae38c28b26c01f55dea39468
// @version 0.1
// @description Hide Youtube Comments
// @author JCGrant
// @match https://www.youtube.com/watch*
// @grant none
// ==/UserScript==
@JCGrant
JCGrant / filter-proposals-by-allocation.js
Created November 11, 2016 20:41
A quick script to filter out any projects that have been fully allocated at https://project-portal.doc.ic.ac.uk/proposal_selection
const available = (tr) => {
let tds = tr.getElementsByTagName('td');
let title_td = tds[2];
let title_text = title_td.textContent;
let num_allocated_str = title_text[title_text.length - 2];
let num_allocated = parseInt(num_allocated_str);
let num_places_available_td = tds[5];
let num_places_available_str = num_places_available_td.textContent;
let num_places_available = parseInt(num_places_available_str);
@JCGrant
JCGrant / Improving the Halite Random Bot (Python 3)
Last active November 12, 2016 04:17 — forked from benjaminfspector/Improving the Halite Random Bot (Python 3)
Halite Random Improvement Sample Code (Python 3)
This Gist contains the sample code for improving the sample Halite random bot in Python 3.
using System;
using System.IO;
using System.Collections.Generic;
namespace SemanticEvolution {
public class Program {
private static List<double> GetValuesFromCsv(string filePath, char delimiter=',') {
List<double> values = new List<double>();
@JCGrant
JCGrant / sunflower.pde
Created May 30, 2017 18:37
Drawing sunflowers with Processing
color petalColor = #FFC608;
color seedsColor = #2A1B12;
color stemColor = #6C7D36;
color backgroundColor = #89B4EA;
void setup() {
size(1920, 1080);
frameRate(5);
background(backgroundColor);
}