Skip to content

Instantly share code, notes, and snippets.

@simolus3
simolus3 / AchievementName.java
Last active February 7, 2017 02:45
English Name of Bukkit API Achievements
import java.util.HashMap;
import org.bukkit.Achievement;
public class AchievementName {
private static HashMap<Achievement, String> names = new HashMap<Achievement, String>();
static {
names.put(Achievement.OPEN_INVENTORY, "Taking inventory");
names.put(Achievement.MINE_WOOD, "Getting Wood");
@simolus3
simolus3 / LoreFriendlyString.java
Last active August 29, 2015 14:18
Util to create small lines from a string. Useful when having to create item lores.
public static List<String> itemLoreFriendly(String text) {
final int maximumCharsPerLine = 50;
final char space = ' ';
final char newLine = '\n';
List<String> lines = new ArrayList<String>();
while (text.length() > maximumCharsPerLine) {
StringCharacterIterator it = new StringCharacterIterator(text);
//Find the last location of a space befor the character limit.
@simolus3
simolus3 / add_iteratively.pas
Last active October 13, 2016 12:35
Rekursionsaufgaben
procedure TForm1.btnAddItClick(Sender: TObject);
var sum, i: integer;
begin
sum := 0;
for i := 1 to 4 do begin
sum := sum + (random(6) + 1);
end;
ShowMessage(IntToStr(sum));
end;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.util.Base64;
public class PasswordHasher {
private static final int HASHING_ITERATIONS = 128_000;
@simolus3
simolus3 / main.dart
Created March 28, 2019 18:16
Displays the current balance of a given ethereum address
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:web3dart/web3dart.dart';
void main() {
runApp(MaterialApp(
home: EthApp(),
theme: ThemeData(
primaryColor: Colors.orange,
typography: Typography(
import 'package:moor_flutter/moor_flutter.dart';
part 'database.g.dart';
class Rooms extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get desc => text()();
}
@UseMoor(tables: [Rooms])
@simolus3
simolus3 / main.dart
Created July 12, 2019 07:31
Download file in dart
import 'dart:convert';
import 'dart:html';
import 'dart:typed_data';
void main() {
final content = '["general kenobi", "you are a bold one"]';
download('message.json', utf8.encode(content) as Uint8List, type: 'application/json');
}
void download(String filename, Uint8List data, {String type = 'octet/stream'}) {
@simolus3
simolus3 / dao.dart
Created August 5, 2019 09:32
Reproduce moor dao issue
import 'package:moor/moor.dart';
import 'database.dart';
part 'dao.g.dart';
@UseDao(tables: [Users])
class SomeDao extends DatabaseAccessor<Database> with _$SomeDaoMixin {
SomeDao(Database db) : super(db);
}
@simolus3
simolus3 / shopping_cart.dart
Last active November 21, 2023 12:27
Shopping carts in moor
import 'package:moor/moor.dart';
import 'package:moor/moor_vm.dart';
import 'package:rxdart/rxdart.dart';
part 'shopping_cart.g.dart';
class ShoppingCarts extends Table {
IntColumn get id => integer().autoIncrement()();
}
@simolus3
simolus3 / database.dart
Created August 26, 2019 15:22
Unsucessful attempt at reproducing moor#121
import 'dart:convert';
import 'package:moor_flutter/moor_flutter.dart';
part 'database.g.dart';
@DataClassName("Journal")
class Journals extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text().withLength(min: 1, max: 50)();
TextColumn get description => text().withLength(min: 1, max: 100)();