Skip to content

Instantly share code, notes, and snippets.

View SET001's full-sized avatar
🇺🇦

Kostiantyn Kostiuk SET001

🇺🇦
View GitHub Profile
{
YellowLaser: BulletConfig(
damage: 234.0,
shoot_rate: 12.0,
speed: 123.0,
assets: BulletAssets(
animations: BulletAnimations(
hit_splash: Directional((
left: Animation(
sprite_sheet: SpriteSheetDescriptor(
use bevy_editor_pls::prelude::*;
use bevy::prelude::*;
use leafwing_input_manager::{InputManagerBundle, prelude::{ActionState, InputMap}, Actionlike, plugin::InputManagerPlugin};
#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug)]
pub enum PlayerAction {
Fire,
MoveLeft,
MoveRight,
MoveUp,
@SET001
SET001 / eatallmemory.js
Created September 6, 2020 13:18
eat all memory in node.js
const chunkSize = 1000
const bufs = []
try {
do {
bufs.push(Buffer.alloc(chunkSize * 1024 * 1024, 'x'))
} while (true)
} catch (e) {
console.log('stopping and ', Math.round(process.memoryUsage().rss / (1024 * 1024)))
}
use amethyst::{
assets::{AssetStorage, Handle, Loader, ProgressCounter},
prelude::*,
renderer::{formats::texture::ImageFormat, SpriteSheet, SpriteSheetFormat, Texture},
};
use crate::menu::MenuState;
#[derive(Debug)]
pub struct HandleDesc {
@SET001
SET001 / bitwiseTruncator.js
Last active February 5, 2020 07:32
truncate number to size in bytes
const bitwiseTruncator = length => number => number & (Math.pow(2, length)-1);
((length, cTestNumbers, cTestNumbersMaxSize=999999)=>{
const numbers = Array.from({length: cTestNumbers}).map(()=>Math.ceil(Math.random()*cTestNumbersMaxSize))
const truncatedNumbers = numbers.map(bitwiseTruncator(length))
numbers.map((number)=>console.log(`was: ${number.toString(2)}`))
truncatedNumbers.map((number)=>console.log(`now: ${number.toString(length).padStart(length, "0")}`))
})(3, 7)
// tslint:disable
export type UnpackPromise<T> = T extends Promise<Array<infer U>> ? U[] : T extends Promise<infer D> ? D : T;
type DeltaFn<ARG extends any[], R> = (...args: UnpackPromise<ARG>) => R | PromiseLike<R>;
type RiverFn<ARG, R> = (arg: UnpackPromise<ARG>) => R | PromiseLike<R>;
function pipe<A extends any[]>(): (...args: A) => UnpackPromise<A>;
function pipe<A extends any[], R1>(f1: DeltaFn<A, R1>): (...args: A) => Promise<R1>;
function pipe<A extends any[], R1, R2>(f1: DeltaFn<A, R1>, f2: RiverFn<R1, R2>): (...args: A) => Promise<R2>;
function pipe<A extends any[], R1, R2, R3>(
f1: DeltaFn<A, R1>,
f2: RiverFn<R1, R2>,
const jsLangs = (context, error) => node => node.arguments.map((arg) => {
if (arg.type === 'Identifier') {
context.report({
node,
messageId: error,
data: { name: arg.name }
});
}
});
const noDynTranslationKeys = require('./no-dyn-translation-keys')
module.exports = {
rules: {
'no-dynamic-translation-keys': noDynTranslationKeys
}
};
const dataStream = Rx.Observable.create((observer)=>{
setInterval(()=>{
const value = Math.ceil(Math.random()*100)
observer.next(value)
}, 1000)
})
dataStream.subscribe((o)=>console.log(o))
dataStream
.filter(a=>a<10)
.subscribe(d=>console.log("--->", d))
class Cursor{
position: Core.Point = new Core.Point()
onChangePosition = new Phaser.Signal()
place(position: Core.Point){
this.position = position
this.onChangePosition.dispatch(this.position)
}