Skip to content

Instantly share code, notes, and snippets.

View Jezza's full-sized avatar
🤔
Rewriting all of the things...

Jezza

🤔
Rewriting all of the things...
  • Germany
View GitHub Profile
@Jezza
Jezza / telefig.rs
Created May 16, 2022 15:34
Just a very basic teloxide base for bots.
use std::future::Future;
use std::time::Duration;
use teloxide_core::prelude::*;
use teloxide_core::types::{ChatId, MediaKind, MediaText, MessageKind, Update, UpdateKind};
pub const WAIT_TIME: Duration = Duration::from_secs(5);
pub const MAX_ATTEMPTS: u32 = 5;
pub fn extract_text(update: Update) -> Option<(ChatId, MediaText)> {
let msg = match update.kind {
public final class RunningAverage {
private final int[] values;
private float average;
private int index;
public RunningAverage(int capacity) {
values = new int[capacity];
average = 0;
index = 0;
}
public interface CheckedFunction<I, O, T extends Throwable> {
O apply(I input) throws T;
}
private static <I, O, R, T extends Throwable> CheckedFunction<I, R, T> combine(CheckedFunction<I, O, T> left, CheckedFunction<O, R, T> right) {
return input -> right.apply(left.apply(input));
}
public static final class DBRow {
final String query;
@Jezza
Jezza / about.md
Created May 2, 2017 17:50 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
// Implicit declarations
ALPHA_LOWER := [a-z]
ALPHA_UPPER := [A-Z]
ALPHA := [{ALPHA_LOWER}|{ALPHA_UPPER}]
NUM := [0-9]
HEX := [{NUM}|a|b|c|d|e|f|A|B|C|D|E|F]
ALPHA_NUM := [{ALPHA}|{NUM}]
-- resource: the value that will be used when creating the entity. Such as 'stone', or 'iron-ore'
-- length: the length of one side of the square that will be generated, the player will be the top left of the square. Default is 20.
-- amount: the quantity per ore. Default is 50000.
-- to: The value that will be used when generating the base land within the area. Default is 'grass'
function create(resource, length, amount, to)
if (resource == nil)
return "Please specify a resource to use. Eg: /c create('stone') or /c create('iron-ore')"
end
local r = length or 20; -- If no length is provided, just assume a small 20, that way it doesn't destroy massive areas of land.
public class IO {
public static final int EOL = -1;
public static final int DEFAULT_BUFFER_SIZE = 4096;
public static final String SCANNER_END_OF_FILE_TOKEN = "\\A";
public static String toString(Reader in) throws IOException {
char[] arr = new char[DEFAULT_BUFFER_SIZE];
StringBuilder buffer = new StringBuilder();
int numCharsRead;
while ((numCharsRead = in.read(arr, 0, DEFAULT_BUFFER_SIZE)) != EOL)
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Random;
/**
* General fuckery.
*
* @author jezza
* @date Oct 1, 2015
*/
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"