Skip to content

Instantly share code, notes, and snippets.

View WaffleLapkin's full-sized avatar
🧇
exhaused and vaguely burned

Waffle Maybe WaffleLapkin

🧇
exhaused and vaguely burned
View GitHub Profile
import asyncio
from typing import Optional
import aiohttp
from aiohttp import ClientSession
class KittensQueue(asyncio.Queue):
def __init__(self, config, loop: asyncio.AbstractEventLoop, maxsize=15, mime_types: Optional[str] = "jpg"):
self.config = config
10:43:50,844 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
10:43:50,845 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
10:43:50,845 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/home/waffle/projects/repos/kotlogram/out/production/resources/logback.xml]
10:43:50,974 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeFilter scanning period to 5 minutes
10:43:50,975 |-INFO in ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter@c2e1f26 - Will scan for changes in file [/home/waffle/projects/repos/kotlogram/out/production/resources/logback.xml] every 300 seconds.
10:43:50,975 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
10:43:50,990 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.example] to TRACE
1
package test
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
data class Data<T>(val data: T, val smt: String)
fun main(args: Array<String>) {
val str = "{\"data\":\"some string\", \"smt\":\"some name\"}"
data class Handler<T: ITEvent>(
val filters: Array<out Filter<T>>,
val func: suspend (T) -> Unit,
val name: String? = null
) {
/**
* Test all [filters] of this handler
*
* @return true, if all filters passed, else false
*/
@WaffleLapkin
WaffleLapkin / filters.kt
Created December 20, 2018 08:02
Пытаюсь ловить ошибки в фильтрах...
abstract class Filter<T /*: ITEvent */> {
abstract suspend fun test(value: T): Boolean
}
class TrueFilter<T: ITEvent>(val sleep: Int, val num: Int, val throwable: Throwable? = null): Filter<T>() {
override suspend fun test(value: T): Boolean {
println("Enter $num filter, sleeping for $sleep seconds")
delay(sleep.seconds.inMilliseconds.longValue)
println("Success $num filter, returning `true`")
throw throwable ?: return true
private val aMutex = Mutex()
private var job: Job? = null
private fun getJob(from: Int) = launch {
try {
var counter = from
while (isActive) withContext(NonCancellable) {
println(counter++)
delay(100)
}
@WaffleLapkin
WaffleLapkin / 02_hello_world.rs
Last active June 13, 2019 14:10
example of `ggez::graphics::Font::new` leaking memory
//! Basic hello world example.
extern crate cgmath;
extern crate ggez;
use ggez::event;
use ggez::graphics;
use ggez::{Context, GameResult};
use std::env;
use std::path;
(gdb) run
Starting program: /home/waffle/projects/ggez_optimus/target/debug/ggez_optimus
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
before build
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7092800 in xcb_glx_query_server_string_string_length () from /usr/lib/libxcb-glx.so.0
(gdb) backtrace
#0 0x00007ffff7092800 in xcb_glx_query_server_string_string_length () from /usr/lib/libxcb-glx.so.0
@WaffleLapkin
WaffleLapkin / output
Created July 18, 2019 18:45
Output of `optirun -v glxinfo`
[39632.654570] [INFO]Response: Yes. X is active.
[39632.654596] [INFO]Running application using virtualgl.
name of display: :0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: VirtualGL
server glx version string: 1.4
server glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
@WaffleLapkin
WaffleLapkin / output
Created July 19, 2019 15:14
output of `ionice -c 2 -n 7 nice -19 ./build -bk "$(pwd)/backups/first"`
% ionice -c 2 -n 7 nice -19 ./build -bk "$(pwd)/backups/first"
+./build:6> sudo -v
+./build:13> local SHOULD_RESUME=false
+./build:7> true
+./build:14> local RESUME_PKG=''
+./build:15> local PACKAGES=( )
+./build:16> local EXCLUDED_PACKAGES=( )
+./build:17> local FIRST_PARAMS=( )
+./build:18> local EVERY_PARAMS=( )
+./build:19> local ONE_ONLY=false