Skip to content

Instantly share code, notes, and snippets.

View rob-work's full-sized avatar
💭
optimising all the paperclips

Rob Englebright rob-work

💭
optimising all the paperclips
View GitHub Profile
@rob-work
rob-work / gist:1fcc29ced64744577b68
Created August 1, 2014 08:40
redirect to activate - stick this in the head
<meta http-equiv="refresh" content="0; url=http://www.brighton.ac.uk/studying-here/activate-your-user-account.aspx" />
@rob-work
rob-work / gist:46482928c1ae1f8c721c
Last active August 29, 2015 14:03
min height nav bar
.navbar .container-fluid {
min-height: 83px;
background-color: #555555;
}
@rob-work
rob-work / email-match.php
Created February 26, 2013 13:46
php regex email matcher
("/^[_a-z0-9-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/i", $email)
@rob-work
rob-work / regex.java
Last active December 14, 2015 04:09
basic regex structure
import java.util.regex.Matcher;
import java.util.regex.Pattern;
//or import java.util.regex.*;
Pattern pattern = Pattern.compile("INSERT REGULAR EXPRESSION");
Matcher matcher = pattern.matcher("INSERT INPUT STRING TO SEARCH");
boolean found = false;
while (matcher.find()) {
...do something...
@rob-work
rob-work / century.java
Created February 22, 2013 17:04
FOOD 4.5.2 create an ArrayList, add numbers from 1 to 100, use set and get to double them, then output the sum of the elements
package unit4s5452;
import java.util.List;
import java.util.ArrayList;
/**
*
* @author rob_work
* Store the numbers from 1 to 100 in an ArrayList.
*
* Write some code to double every number in the list;
* you should use a standard for loop here,
@rob-work
rob-work / Main.java
Created February 21, 2013 11:12
FOOD Unit 4 exercise 4.5.1 - create some sets and remove elements till left with primes
/*
* Create two sets of numbers.
The first set will contain all the numbers from 2 to 100.
The second set will contain all the even numbers greater than 2
(i.e. 4, 6, 8, ...).
By using a single set operation, remove all these even numbers
from the first set.
Repeat the process to remove all multiples of 3 (i.e. 6, 9, 12 ...),
5, and 7 from the original set.
(Use the principle of DRY to make this process use a common set of methods.)
@rob-work
rob-work / plusOut.java
Created February 10, 2013 17:15
regex solution to codingbat plus out
public String plusOut(String str, String word) {
return str.replaceAll(
"(?<!(?=word).{0,M})."
.replace("word", java.util.regex.Pattern.quote(word))
.replace("M", String.valueOf(word.length()-1)),
"+"
);
}
@rob-work
rob-work / gist:4750005
Created February 10, 2013 15:56
Java Regex test harness - takes no command line parameters - loops taking regex
import java.io.Console;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class RegexTestHarness {
public static void main(String[] args){
Console console = System.console();
if (console == null) {
@rob-work
rob-work / TempConvertToFile.java
Last active December 12, 2015 08:39
#UH6COM1014- exercise 2.4.2.a Rewrite the code you used to output a table of temperature conversions so that the table is now output to a Writer instance. Modify your program so that it will output the table of temperature conversions to a filename provided by the user.
package tempconverttofile;
import java.io.*;
import java.math.BigDecimal;
/**
* @author rob_work
*/
public class TempConvertToFile {
/**
* Method to create a table of temp conversions given start, end and step
@rob-work
rob-work / ReadToArray.java
Last active December 12, 2015 08:38
#UH6COM1014- exercise 241 - A program to read each line of a file and store it in an array of strings. The code makes two passes through the file: the first to find the number of lines.
package exercise241;
import java.io.*;
/**
*
* @author rob_work
* Write a program to read each line of a file
* and store it in an array of strings.
* You will need to make two passes through
* the file: the first to find the number of lines.
*