Skip to content

Instantly share code, notes, and snippets.

View sophec's full-sized avatar
🖤
[[maybe_unused]]

Sophie Eccles sophec

🖤
[[maybe_unused]]
View GitHub Profile
@sophec
sophec / methoding.java
Last active August 26, 2015 22:00
an even better way to pass methods as parameters
public static void main(String[] args) {
// this uses a java 8 feature called method references (i think)
// it looks for method "aThingToDo" in class "methoding" (the name of this class)
// aThingToDo must match the pattern, as doAThing says
doAThing(methoding::aThingToDo);
}
// define a pattern for what type of method we want
// we want a method with String s as input and no return (void)
public interface voidMethod {
@sophec
sophec / pass a method to a method.java
Created August 14, 2015 22:48
This is how to pass a method to another method in Java 8+.
// while this is not technically a method, a Runnable is close enough for me.
// this method wants a "method" as an input
void canHazMethod(Runnable methodToRun) {
// run the method passed in
methodToRun.run();
}
// this is the method I will use:
Runnable myMethod = () -> {
/// test #1
#define u using
#define n namespace
#define s std
// so can this work?
u n s;
// yes indeed it can!
/// test #2
@sophec
sophec / gist:25684fd010b5f71353f0
Last active August 29, 2015 14:24
Make a div round
/* to make a div round, the width and height must be the same (a square)
also, the border radius must be half of the w/h
so for a div 42x42, the radius should be 21. */
.my-round-div {
background-image: url("my-square-or-round-image.png");
display: block;
height: 42px;
width: 42px;