Skip to content

Instantly share code, notes, and snippets.

View chnirt's full-sized avatar
🦦
On vacation

Chnirt chnirt

🦦
On vacation
View GitHub Profile
@chnirt
chnirt / app.module.ts
Last active June 19, 2019 03:49
NestJs
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { GraphQLModule } from '@nestjs/graphql';
import { UserModule } from './user/user.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { join } from 'path';
@Module({
imports: [
@chnirt
chnirt / machine.js
Last active April 3, 2020 08:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@chnirt
chnirt / machine.js
Last active April 3, 2020 08:17
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@chnirt
chnirt / machine.js
Last active April 3, 2020 09:12
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
import React, {createContext, useEffect, useContext} from 'react';
import Realm from 'realm';
const HomeServiceSchema = {
name: 'HomeService',
properties: {
channel_url: 'string',
channel_image: 'string',
channel_type: 'string',
channel_name: 'string',
@chnirt
chnirt / switch-version.sh
Last active May 16, 2022 03:26
Switch version
#!/bin/bash
echo "Switch version by Chnirt";
# * node v16.14.2
# * ruby 3.1.2
# * cocoapod 1.11.3
node_version_default=16.14.2
ruby_version_default=3.1.2
@chnirt
chnirt / EnscriptDescriptByGPG.sh
Created May 9, 2022 06:38
Encrypt & Descrypt by GPG
echo "Encrypt & Decrypt with PGP by Chnirt"
# install gpg
# https://gpgtools.org/
# gpg --full-generate-key
choice="Encrypt Decrypt Exist"
select option in $choice
do
echo "$option"
@chnirt
chnirt / formatLargeNumber.js
Last active May 23, 2022 03:45
format large number 9.939515029213079e+40
import numeral from 'numeral';
export const formatCurrency = (number, symbol = '$') => {
const formatScientificNotationNumber = Number(number).toFixed(8); // format for case number = 9.322320693172514e-12
if (formatScientificNotationNumber.includes('e+')) {
var formatter = new Intl.NumberFormat('en-AU', {
style: 'currency',
currency: 'AUD',
minimumFractionDigits: 0,
@chnirt
chnirt / run.swift
Created May 21, 2022 08:51
Binary numbers with N digits and k 1s
// You are trying to figure out how many binary numbers there are that have N digits and k 1s, and are multiples of 3. Binary numbers that have N digits also include ones that start with 0.
// Suppose that N = 3 and K = 2. Binary numbers with three digits in this case include the following: 000, 001, 010, 011, 100, 101, 110, and 111--8 binary numbers in total. Among these numbers, the ones that have two 1s are 011, 101, and 110. Among these three numbers, two--011 and 110--are multiples of 3.
// Suppose parameters N and K are given, where N represents the number of digits of the given binary number(s) and K the number of 1s in these binary numbers. Please write a function solution that returns the number of binary numbers that have N digits and k 1s and are multiples of 3
// Constraints
// N is a natural number between 1 and 50.
// K is a natural number between 1 and N.
// Examples
@chnirt
chnirt / run.swift
Created May 21, 2022 08:54
Balanced Brackets with multiple conditions
// There are strings that are made of brackets—[,], braces—{,}, and parentheses—(,). A string is regarded as a valid string of brackets when it meets the following conditions:
// In brackets, there can be brackets, braces, and parentheses.
// In braces, there can only be braces and parentheses.
// 2-1. "{[]()}" is invalid, because brackets are in braces.
// In parentheses, there can only be other parentheses.
// 3-1. "({()})" is invalid, because braces are in parentheses.
// All open brackets, braces, and parentheses must be closed by the corresponding number of brackets, braces, and parentheses.