Instantly share code, notes, and snippets.

View TodoListRepository.java
public class TodoListRepository {
public Observable<List<Todo>> findTodosForToday(String userId) {
return findAllByUser(userId)
.flattenAsObservable(todoLists -> todoLists)
.flatMap(todoList -> findTodosForTodayByTodoList(todoList.getId()).toObservable());
}
public Single<List<Todo>> findTodosForTodayByTodoList(UUID listId) {
return Single.create(emitter -> this.firestore.collection(COLLECTION_TODO_LISTS)
.document(listId.toString())
View backup.php
<?php
ini_set('max_execution_time', -1);
ini_set('memory_limit', '-1');
ini_set('display_errors', 1);
error_reporting(E_ALL);
$source = '<directory>';
$destination = 'backup.zip';
$result = zip($source, $destination);
View wpa_supplicant.conf
country=CH
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
# Generate NTLM password hash with: echo -n plaintext_password_here | iconv -t utf16le | openssl md4
# LAN - IEEE8021X authentication
#network={
# key_mgmt=IEEE8021X
# identity="<username>@zhaw.ch"
View a
%[root,xit,n] = Moreno_Santiago_IT17aZH_S4_Aufg2(@(x) sin(x)*cos(x), 1.5, 2, eps)
function [root,xit,n] = Moreno_Santiago_IT17aZH_S4_Aufg2(func,a,b,tol)
if func(a)*func(b)>0
error('invalid: no null point')
end
n=1;
xit=[];
while abs(a-b)>tol&&abs(a-b)>eps
root=(a+b)/2;
View MultiArgumentLambda.java
import java.util.function.BiFunction;
import java.util.stream.IntStream;
import java.util.stream.Stream;
class MultiArgumentLambda {
public static void main(String[] args) {
String[] firstnames = new String[]{"Herbert", "Johnny", "Paul"};
String[] lastnames = new String[]{"Meier", "Mueller", "Schmid"};
zip(firstnames, lastnames, (first, last) -> String.format("%s, %s", last, first))
.forEach(System.out::println);
View README.md

shebang support in Java 11

Seit Java 11 muss ein einzelnes Java-File nicht kompilliert werden, sondern kann direkt von java ausgeführt werden. Mehr noch: Es können Files, analog wie Shell-Scripts, direkt ausgeführt werden: dazu gibt's den shebang-Support. Damit das funktioniert, muss die Datei "executable" sein, d.h.: chmod u+x dateiname

Beispiel:

    #!/usr/bin/java --source 11
View Main.java
import android.util.Log;
/**
* author hute
* created 09.08.2018
* this is made for android environement
*/
public class Main {
protected final String TAG = this.getClass().getName();
View CCP2-DVOP3-p2c-stage
stage('Deploy using push2cloud') {
when { branch 'p2c' }
steps {
echo "Deploying ${env.GIT_BRANCH} branch (${env.GIT_COMMIT}) ..."
echo 'Prepare push2cloud'
sh '''
cd ${WORKSPACE}/p2c
npm install
'''
View ackermann.js
//Usage:
//node ackermann.js {n} {m}
//E.g.:
//node ackermann.js 2 1
//5
var arg1 = process.argv[2];
var arg2 = process.argv[3]
console.log(ackermann(arg1, arg2));