Skip to content

Instantly share code, notes, and snippets.

View Xion's full-sized avatar

Karol Kuczmarski Xion

View GitHub Profile
EffectAsset {
name: "particle_swirl",
capacity: 8192,
spawner: Spawner {
num_particles: Single(
spawn_time: Single(
Xion /
Last active October 18, 2022 18:00
Count installed Bevy plugins
// License: BSD-3
use std::io::{self, Write};
use std::string::FromUtf8Error;
use std::sync::Arc;
use antidote::RwLock;
use bevy::prelude::*;
use bevy::reflect::FromReflect;
use bevy::utils::tracing::{self, Dispatch};
curl | python -c '
import re, sys
for line in sys.stdin.readlines():
m ="""class="def">([^<]+)</a> ::""", line)
if m:
print([1:-1].replace("&lt;", "<").replace("&amp;", "&").replace("&gt;", ">"))
' | sort | uniq | wc -l
Xion /
Last active November 1, 2017 18:12 — forked from anonymous/
Rust code shared from the playground
extern crate serde_derive;
extern crate toml;
use std::borrow::Cow;
use std::fs::File;
use std::io::Read;
#[derive(Debug, Serialize, Deserialize)]
pub struct Config<'a> {
Xion /
Created May 8, 2016 00:12
Fix for Mock.configure_mock
Extensions to the standard Python mock library.
Use it instead of the library itself.
from __future__ import absolute_import
from unittest.mock import *
except ImportErorr:
from mock import *
Xion /
Last active November 23, 2023 03:59
Retrieve source code of a (short) lambda --
import ast
import inspect
import os
def get_short_lambda_source(lambda_func):
"""Return the source of a (short) lambda function.
If it's impossible to obtain, returns None.
Xion /
Created November 4, 2015 06:39
Base class for Celery tasks running inside Flask request context
from celery import Task
from flask import has_request_context, make_response, request
from myapp import app
__all__ = ['RequestContextTask']
class RequestContextTask(Task):
Xion /
Created October 25, 2015 23:02
SQLAlchemy column type for storing Python enums
from enum import Enum
from inspect import isclass
import re
from sqlalchemy.types import TypeDecorator, TypeEngine
__all__ = ['EnumType']
Xion /
Last active May 13, 2021 05:16
Regular expression filters in SQLAlchemy
Module implementing an enhanced string column type for SQLAlchemy
with a support for regular expression operators in Postgres and SQLite.
import re
from sqlalchemy import String as _String, event, exc
from sqlalchemy.engine import Engine
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import BinaryExpression, func, literal
Xion / purge_memcache.exp
Created September 20, 2015 03:14
Flush all keys from memcached server
#!/usr/bin/expect --
# Purge local memcache, flushing all the keys & values
set escapechar !; # easier to send than default ^]
set host [lindex $argv 1];
if { ![string length $host] } {
set host "localhost";