Skip to content

Instantly share code, notes, and snippets.

🇺🇦

Konstantin Kostiuk SET001

🇺🇦
Block or report user

Report or block SET001

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View loader.rs
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 Feb 5, 2020
truncate number to size in bytes
View bitwiseTruncator.js
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)
View pipe.ts
// 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>,
View no-dyn-translation-keys.js
const jsLangs = (context, error) => node => node.arguments.map((arg) => {
if (arg.type === 'Identifier') {
context.report({
node,
messageId: error,
data: { name: arg.name }
});
}
});
View index.js
const noDynTranslationKeys = require('./no-dyn-translation-keys')
module.exports = {
rules: {
'no-dynamic-translation-keys': noDynTranslationKeys
}
};
View rxjs.test.js
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))
View cursor.ts
class Cursor{
position: Core.Point = new Core.Point()
onChangePosition = new Phaser.Signal()
place(position: Core.Point){
this.position = position
this.onChangePosition.dispatch(this.position)
}
View cursor.ts
class Cursor{
// @include components/d2.ts
create(){
}
}
@SET001
SET001 / textBox.js
Created Nov 11, 2016
PHASER.js textBox plugin
View textBox.js
class TextBox{
constructor(x, y, game){
this.lineHeight = 20
this.lineNumber = 0
this.game = game
this.x = x
this.y = y
}
write(text){
View antonsButthurt.js
const mkdirp = require('mkdirp')
const rmdir = require('rmdir')
const fs = require('fs')
rmdir('./media/01', (err)=>{
var path = './media/01/f1/'
mkdirp(path, (err)=>{
if (err) return err
const content = "asdasd"
fs.writeFile(path + 'file.jpg', content, (err)=>{
You can’t perform that action at this time.