Skip to content

Instantly share code, notes, and snippets.

@MatMoore
MatMoore / gist:6948662
Last active December 25, 2015 08:39
Finds the maximum sum possible from picking a contiguous subsequence of an array in linear time
def highest_consecutive_sum(intarray):
if not intarray:
return None
current_sum = intarray[0]
current_start = 0
current_end = 0
highest_sum = current_sum
highest_start = current_start
highest_end = current_end
package wlhacknight
import scala.io.Source
import java.io.File
import java.util.Arrays
import scala.collection.mutable.ArrayBuffer
import scala.collection.immutable.HashMap
import scala.util.Random
/**
@MatMoore
MatMoore / hacknight.py
Last active August 29, 2015 14:05
West London Hack Night 14/08/14 - Soundex Algorithm
import sys
import soundex
import random
import pickle
soundalikes = {}
def load_dict():
with open('/usr/share/dict/words') as f:
for line in f:
@MatMoore
MatMoore / Tetris.scala
Created November 14, 2014 20:36
West london hack night november 2014
package tetris
/**
* Created by mat on 12/11/2014.
*/
abstract class shape {
var orientation: Int = 0
val orientations: Array[Array[Point]]
def rotate(direction: Int): Array[Point] = {
@MatMoore
MatMoore / RDCP.scala
Created December 8, 2014 21:24
West London Hack Night December 2014
/**
* Created by mat on 08/12/2014.
*/
import java.net._
import java.io.{Console => _, _}
import scala.collection.mutable
import scala.io._
object RDCP extends App {
@MatMoore
MatMoore / battleship.erl
Created January 19, 2016 22:23 — forked from danielerapati/battleship.erl
Erlang battleship: January 2016 West London Hacknight
-module(battleship).
-import(sets,[new/0, add_element/2, is_element/2]).
-import(lists,[foldl/3]).
-export([new_grid/0]).
-export([new_grid/2]).
-export([fill_cell/2]).
@MatMoore
MatMoore / dry_run
Created April 25, 2016 09:44
Restoring policy links (dry run)
Dry run of restore_policy_links task on local database.
Note: everything is duplicated on the 21st because I applied the changes locally at the time.
Dry run
Found 219 destructive events
17e4ab26-ee1f-4383-a345-d165c0b75fbf PatchLinkSet 2016-03-14 12:04:31 UTC {:organisations=>[], :lead_organisations=>[], :people=>[], :working_groups=>[], :related=>[], :email_alert_signup=>["135ab6fc-cda6-4dc7-852a-0fbddc2472e6"], :policy_areas=>[]}
3f1dc53a-732b-41ff-83ae-8d93fffb1a7c PatchLinkSet 2016-03-14 12:02:38 UTC {:organisations=>[], :lead_organisations=>[], :people=>[], :working_groups=>[], :related=>[], :email_alert_signup=>["d59b3b97-a9ed-4e5b-afaf-1edd599dcc43"], :policy_areas=>[]}
453affe4-5ebb-4f44-9f0a-44cfd32dc934 PatchLinkSet 2016-03-14 12:04:30 UTC {:organisations=>[], :lead_organisations=>[], :people=>[], :working_groups=>[], :related=>[], :email_alert_signup=>["de631142-8027-458b-bfa9-b77582939294"], :policy_areas=>[]}
5c6497db-7631-11e4-a3cb-005056011aef PatchLinkSet 2016-03-14 12:03:36 UTC {:organisat
@MatMoore
MatMoore / sanitize_data.rake
Last active April 25, 2016 12:52
Verifier script WIP
require 'gds_api/rummager'
require 'set'
desc "Sanitize access limited data"
task sanitize_data: :environment do
Tasks::DataSanitizer.delete_access_limited(STDOUT)
end
task compare_policies_to_rummager: :environment do
policy_query = Queries::GetContentCollection.new(
@MatMoore
MatMoore / format_finder.py
Created August 4, 2016 10:56
Format finder
"""
Use the integration search API to figure out formats for a list of pages
Usage: USERNAME=??? PASSWORD=??? python format_finder.py
"""
import csv
import requests
from os import environ
from requests.auth import HTTPBasicAuth
@MatMoore
MatMoore / Link types
Created September 13, 2016 11:00
Link types on GOV.UK