This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lets you destructure ranges. | |
val (start, end) = (0..10) | |
private operator fun <T:Comparable<T>> ClosedRange<T>.component1(): T = this.start | |
private operator fun <T:Comparable<T>> ClosedRange<T>.component2(): T = this.endInclusive |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20.times { | |
println(it) | |
} | |
private fun Int.times(function: (Int) -> Unit) { | |
for (i in 0 until this) { | |
function(i) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int numberOfCharacter = 5 | |
def stats = ['str', 'dex', 'con', 'wis', 'int', 'cha'] | |
stats.each { | |
print it + "\t" | |
} | |
println() | |
numberOfCharacter.times { | |
for (String stat : stats) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') | |
echo "updating $branch to the new master" | |
git fetch | |
git checkout master | |
git pull | |
git checkout $branch | |
git rebase -i master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name New Userscript | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.reddit.com/robin/ | |
// @grant none | |
// ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public RandomAsteroidBuilder makeBall(float radius) { | |
int x2 = width / 2; | |
int y2 = height / 2; | |
int z2 = depth / 2; | |
float radiusShare = 8; | |
float randomShare = 2; | |
for (int x = 0; x < width; x++) { | |
for (int y = 0; y < height; y++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This sends messages as slackbot to slack using groovy | |
*/ | |
String.metaClass.encodeURL = { | |
java.net.URLEncoder.encode(delegate, "UTF-8") | |
} | |
def address = "https://slack.com/api/" | |
def method = "chat.postMessage" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.imageio.ImageIO | |
import java.awt.image.BufferedImage | |
int tileSize = 32 | |
BufferedImage source = ImageIO.read(new File("fantasy-tileset.png")) | |
assert source | |
for (int x = 0; x < source.width / tileSize; x++) { | |
for (int y = 0; y < source.height / tileSize; y++) { | |
BufferedImage output = source.getSubimage(tileSize * x, tileSize * y, tileSize, tileSize) |