Skip to content

Instantly share code, notes, and snippets.

View Fantasim's full-sized avatar

Fantasim

View GitHub Profile
{
"fingerprint": {
"screen": {
"availHeight": 790,
"availWidth": 1440,
"pixelDepth": 30,
"height": 900,
"width": 1440,
"availTop": 25,
"availLeft": 0,
@Fantasim
Fantasim / populate.ts
Last active February 24, 2022 07:05
Populate example on Elzeard
import { Model, Joi, Collection } from 'elzeard'
export class UserModel extends Model {
static schema = Joi.object({
id: Joi.number().autoIncrement().primaryKey()
username: Joi.string().min(3).max(20).lowercase().required().unique(),
})
constructor(initialState: any, options: any){
@Fantasim
Fantasim / s.py
Created September 5, 2021 10:01
last word on mnemonic
import mnemonic
english = ["abandon", "ability", "able", "about", "above", "absent", "absorb", "abstract", "absurd", "abuse", "access", "accident", "account", "accuse", "achieve", "acid", "acoustic", "acquire", "across", "act", "action", "actor", "actress", "actual", "adapt", "add", "addict", "address", "adjust", "admit", "adult", "advance", "advice", "aerobic", "affair", "afford", "afraid", "again", "age", "agent", "agree", "ahead", "aim", "air", "airport", "aisle", "alarm", "album", "alcohol", "alert", "alien", "all", "alley", "allow", "almost", "alone", "alpha", "already", "also", "alter", "always", "amateur", "amazing", "among", "amount", "amused", "analyst", "anchor", "ancient", "anger", "angle", "angry", "animal", "ankle", "announce", "annual", "another", "answer", "antenna", "antique", "anxiety", "any", "apart", "apology", "appear", "apple", "approve", "april", "arch", "arctic", "area", "arena", "argue", "arm", "armed", "armor", "army", "around", "arrange", "arrest", "arrive", "arrow", "art", "artefac
@Fantasim
Fantasim / byte-array-to-big-int.ts
Last active February 7, 2021 22:37
Bytes array to BigInt in Typescript
const MAX_UINT_8 = BigInt(256)
const MAX_UINT_16 = BigInt(65536)
const MAX_UINT_32 = BigInt(4294967296)
const MAX_UINT_64 = BigInt(18446744073709551616)
export const ByteArrayToInt = (value: Uint8Array, isNegative: boolean): BigInt => {
let n = BigInt(0);
let MAX = MAX_UINT_8
switch(value.length){
case 1:
@Fantasim
Fantasim / int-to-byte-array.ts
Last active February 7, 2021 09:39
BigInt to bytes array in TS
const TWO = BigInt(2)
const ONE = BigInt(1)
const ZERO = BigInt(0)
const MINUS = BigInt(-1)
const MAX_UINT_8 = BigInt(256)
const MAX_UINT_16 = BigInt(65536)
const MAX_UINT_32 = BigInt(4294967296)
const MAX_UINT_64 = BigInt(18446744073709551616)
@Fantasim
Fantasim / binary
Last active February 6, 2021 12:30
Binary, bitwise and bytes.
BASIC BINARY SYSTEM
There are 4 types of int:
- Int8 : 8 bytes | 1 octet. [max: (2^8) / 2 - 1, min: (2^8) / 2 * -1]
- Int16 : 16 bytes | 2 octets. [max: (2^16) / 2 - 1, min: (2^16) / 2 * -1]
- Int32 : 32 bytes | 4 octets [max: (2^32) / 2 - 1, min: (2^32) / 2 * -1]
- Int64 : 64 bytes | 8 octets [max: (2^64) / 2 - 1, min: (2^64) / 2 * -1]
Examples with Int8:
@Fantasim
Fantasim / example.js
Last active August 27, 2020 16:51
Model's local storage cycle explained
import LocalStore from 'acey-node-store'
import { Model, config } from 'acey'
class M extends Model {
constructor(initialState, options){
super(initialState, options)
}
getRandomValue = () => this.state.random
@Fantasim
Fantasim / nested-models-acey.ts
Last active September 8, 2021 05:01
How to make nested models with Acey, and how it works.
import { Model, IModelOptions } from 'acey'
class Device extends Model {
constructor(initialState: any, options: IOptions){
super(initialState, options)
}
brand = (): string => this.state.brand
serie = (): string => this.state.serie