Skip to content

Instantly share code, notes, and snippets.

@banterCZ
banterCZ / number_guessing.BAS
Last active October 25, 2023 18:27
Number Guessing Game
5 INPUT "ENTER UPPER LIMIT FOR GUESS ";LI
10 NM = INT(LI*RND(1))+1
15 CN = 0
20 PRINT "I'VE GOT THE NUMBER. " :PRINT
30 INPUT "WHAT'S YOUR GUESS"; GU
35 CN = CN + 1
40 IF GU > NM THEN PRINT "MY NUMBER IS LOWER": PRINT: GOTO 30
50 IF GU < NM THEN PRINT "MY NUMBER IS HIGHER": PRINT: GOTO 30
60 PRINT "GREAT! YOU GOT MY NUMBER"
65 PRINT "IN ONLY "; CN ;"GUESSES. ":PRINT
@banterCZ
banterCZ / balloon_sprite.BAS
Last active September 25, 2023 04:44
Balloon Sprite for Commodore 64 Basic
10 V=53248 : REM START OF DISPLAY CHIP
11 POKE V+21,4 : REM ENABLE SPRITE 2
12 POKE 2042,13 : REM SPRITE 2 DATA FROM 13TH BLK
20 FOR N = 0 TO 62: READ Q : POKE 832+N,Q: NEXT
30 FOR X = N TO 209
40 POKE V+4,X: REM UPDATE X COORDINATES
50 POKE V+5,X: REM UPDATE Y COORDINATES
60 NEXT X
70 GOTO 30
200 DATA 0,127,0,1,255,192,3,255,224,3,231,224
public class SecureRandomTest {
public static void main(String[] args) {
System.out.println("SecureRandom Test");
final SecureRandom random = new SecureRandom(); // Default: Win - SHA1PRNG, Linux/maxOS - NativePRNG
// final SecureRandom random = SecureRandom.getInstance("NativePRNGNonBlocking");
System.out.println("Algorithm: " + random.getAlgorithm());
for (int i = 0; i < 100; i++) {
System.out.print('.');
final byte[] seed = random.generateSeed(2 * 8);
}
@banterCZ
banterCZ / data.json
Created September 20, 2017 12:27
JSON filter (no order), test at http://jsonpath.com/
{
"traceId": "491a1826-0fa1-46d8-970d-704027a2548b",
"code": "validation.error",
"message": "Validation failed",
"errors": [
{
"attributeCode": "firstName",
"messageCode": "validation.empty"
},
{
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
/**
@banterCZ
banterCZ / filter_reduce.clj
Last active July 5, 2017 21:08
Get me the average age of the older than 50. (def ages [55 20 75])
(= 65
(/
(reduce + (filter #(> % 50) ages))
(count (filter #(> % 50) ages))
)
)
@banterCZ
banterCZ / SPeL.java
Created June 15, 2017 07:33
SPeL and propety placeholder using default value
/**
* Optional property <code>myApp.node-name</code>, hostname otherwise.
*/
@Value("#{'${myApp.node-name:}'?:T(java.net.InetAddress).getLocalHost().getHostName()}")
private String nodeName;
public class JTSK {
private double x;
private double y;
public JTSK(double x, double y) {
this.x = x;
this.y = y;
}
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.By;