Skip to content

Instantly share code, notes, and snippets.

@RomanIakovlev
RomanIakovlev / lotto.py
Last active September 27, 2022 13:35
A simple lotto game in Python
"""
A simple lotto game.
It creates random lotto tickets according to a user-defined shape, and then draws numbers at random
to check which ticket has all of its numbers matched first, becoming the winner.
"""
import random
import platform
import os
Failed: -35 EAGAIN
[error] java.lang.RuntimeException: Nonzero exit code: 1
[error] at scala.sys.package$.error(package.scala:27)
[error] at scala.scalanative.sbtplugin.ScalaNativePluginInternal$.$anonfun$scalaNativeConfigSettings$45(ScalaNativePluginInternal.scala:432)
[error] at scala.Option.foreach(Option.scala:257)
[error] at scala.scalanative.sbtplugin.ScalaNativePluginInternal$.$anonfun$scalaNativeConfigSettings$44(ScalaNativePluginInternal.scala:432)
[error] at scala.scalanative.sbtplugin.ScalaNativePluginInternal$.$anonfun$scalaNativeConfigSettings$44$adapted(ScalaNativePluginInternal.scala:417)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:39)
[error] at sbt.std.Transform$$anon$4.work(System.scala:66)
#My first Sonic Pi thingy!
live_loop :lead_bass do
with_fx :reverb, room: 1 do
with_fx :echo do
p = [1, -1].choose
sample :bass_thick_c, pan: p
sample :bd_boom, amp: 4, rate: 1, pan: -p
sample :loop_garzul, rate: [0.5, 1].choose
sleep 8
trait Parser[A] {
def apply(s: String): Option[A]
}
import scala.util.Try
implicit val stringParser: Parser[String] = new Parser[String] {
def apply(s: String): Option[String] = Some(s)
}
@RomanIakovlev
RomanIakovlev / ExecuteOnCaller.java
Created January 21, 2014 13:52
On Android, this can be used to schedule callbacks back on the caller thread, if it has a Looper installed, or to the UI thread otherwise.
package com.example.concurrent;
import android.os.Handler;
import android.os.Looper;
import java.util.concurrent.Executor;
/**
* When the calling thread has a Looper installed (like the UI thread), an instance of ExecuteOnCaller will submit
* Runnables into the caller thread. Otherwise it will submit the Runnables to the UI thread.
# --- !Ups
CREATE TABLE users(
email VARCHAR(255) NOT NULL PRIMARY KEY,
name VARCHAR(255)
);
CREATE TABLE subjects(
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
title LONGTEXT NOT NULL,