This file contains 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 Monthly Payments for Buying a Home | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description show monthly payments (Hausgeld + mortgage rate) given a sales expose and user-definable down payment | |
// @author [email protected] | |
// @match https://www.immobilienscout24.de/* | |
// @grant none | |
// @require http://code.jquery.com/jquery-latest.js | |
// ==/UserScript== |
This file contains 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 java.util.HashMap; | |
import java.util.Map; | |
public class AnagramDetector { | |
public Map<Character, Integer> countLetters(String s) { | |
Map<Character, Integer> result = new HashMap<>(); | |
for (char c : s.toLowerCase().toCharArray()) { | |
result.put(c, result.getOrDefault(c, 0) + 1); | |
// alternative, not reading as nicely, but using one less Map lookup: | |
// result.compute(c, (ignored, oldCount) -> oldCount == null ? 1 : oldCount+1); |
This file contains 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
#!/usr/bin/env ts-node | |
/* | |
You can run simple scripts in TypeScript without compiling or any other other | |
additional steps! | |
npm i -g typescript ts-node | |
chmod 755 test.ts | |
./test.ts |
This file contains 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
// "release version" of script is at https://openuserjs.org/scripts/matey-jack/rot17 | |
// ==UserScript== | |
// @name tatta | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description mangle text so user can appreciate the layout better! | |
// @author You |
This file contains 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
function gradle() { | |
local path=$(pwd) | |
while | |
test ! -f $path/gradlew -a / != "$path" -a -n "$path" | |
do | |
path=$(dirname $path) | |
done | |
if | |
test -f $path/gradlew | |
then |
This file contains 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
'use strict'; | |
function scope() { | |
var i = 0; | |
var s = "original"; | |
var b = true; | |
var o = { field: 0 }; | |
return { | |
inc: function () { i++; }, |
This file contains 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
#!/usr/bin/node --experimental-modules | |
// fetch the dependency with: yarn add re2 | |
// I tested with [email protected] | |
import RE2 from "re2"; | |
const emailRegex = new RE2("^[A-Za-z0-9_%+-](\.?[A-Za-z0-9_%+-]+)+@[A-Za-z0-9-](\.?[A-Za-z0-9-]+)+\.[A-Za-z]{2,6}$"); | |
console.log("This is fine: " + emailRegex.test("robert.jack.frederic.manfred.otto.hermann.luis.egon.erwin@friday.de")); |
This file contains 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<title>This regex is so slow</title> | |
</head> | |
<body> | |
<p> | |
Be careful! Adding a space in the email address will freeze this page and the entire browser tab. |
This file contains 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
package example; | |
import java.lang.reflect.InvocationHandler; | |
import java.lang.reflect.Method; | |
import java.lang.reflect.Proxy; | |
/** | |
* Allows "duck typing" or dynamic invocation based on method signature rather | |
* than type hierarchy. In other words, rather than checking whether something | |
* IS-a duck, check whether it WALKS-like-a duck or QUACKS-like a duck. |
This file contains 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
// Java - has not changed since Java 1.0 up until Java 11. | |
// yes, you need to name each field exactly four times and its type two times. | |
class Location { | |
final double lon; | |
final double lat; | |
Location(double lon, double lat) { | |
this.lon = lon; | |
this.lat = lat; | |
} |
OlderNewer