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
#![allow(non_snake_case)] | |
use derive_builder::Builder; // cargo add derive_builder | |
use std::time::{SystemTime, Duration}; | |
/// A pure function to reverse a string. | |
fn reverseString(input: &str) -> String { | |
let idxs = input.char_indices().rev(); | |
let mut output = String::new(); | |
for (_,c) in idxs { |
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 std::env; | |
use std::fs::File; | |
use std::io::{BufWriter, Write}; | |
use std::path::Path; | |
use quote::quote; | |
macro_rules! p { | |
($($tokens: tt)*) => { | |
println!("cargo:warning={}", format!($($tokens)*)) |
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.time.Duration; | |
import java.time.Instant; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.concurrent.*; | |
import java.util.function.Supplier; | |
import java.util.stream.IntStream; | |
public class Main { |
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 time | |
import gi | |
import threading | |
gi.require_version("Gtk", "3.0") | |
from gi.repository import Gtk, GLib | |
class SplashScreen(Gtk.Dialog): | |
__gtype_name__ = "SplashScreen" |
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 se.citerus; | |
import java.util.Optional; | |
import java.util.Scanner; | |
import java.util.concurrent.Flow; | |
import java.util.concurrent.SubmissionPublisher; | |
import java.util.stream.IntStream; | |
public class Java9Features { |
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
fun main() { | |
(1..100).forEach { | |
"".plus( | |
"fizz".repeat(it.rem(2).equals(0).compareTo(false)) // convert the bool to an int... | |
.plus("buzz".repeat(it.rem(3).equals(0).compareTo(false))) // ...and repeat the string 1 or 0 times | |
.plus(it.toString().repeat(Math.abs((it.rem(2).equals(0) || it.rem(3).equals(0)).compareTo(true))))) | |
.let { println(it) } | |
} | |
} |
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
if (maybeNumber is Number) { | |
maybeNumber = maybeNumber.plus(2) | |
} |
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
if (maybeNumber instanceof Integer) { | |
maybeNumber = ((Integer) maybeNumber).plus(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
data class Result(val result: Int, val status: String) | |
fun function(): Result { | |
return Result(200, “OK”) | |
} | |
val (result, status) = function() | |
println("$result $status") |
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
val myMap = mapOf("alfa" to 123, "beta" to 456, "gamma" to 789) | |
for ((key, value) in myMap) { | |
print(“$key: $value”) | |
} |
NewerOlder