Skip to content

Instantly share code, notes, and snippets.

View nixjs's full-sized avatar
:octocat:
Thanks for visiting

Nghi Nguyen nixjs

:octocat:
Thanks for visiting
View GitHub Profile
@nixjs
nixjs / code.md
Created September 7, 2024 04:25
Changing file extensions for all files in a directory on OS X

If you're using the zsh shell

autoload -U zmv
zmv '(**/)(*).txt' '$1$2.md'
@nixjs
nixjs / index.ts
Last active August 9, 2024 03:43
Telegram Bot 6.0 Validating data received via the Web App node implementation
import crypto from 'crypto'
// Validation telegram mini app
function authWebApp(apiToken: string, telegramInitData: string) {
const initData = new URLSearchParams(telegramInitData)
const hash = initData.get('hash')
const dataToCheck: string[] = []
initData.sort()
initData.forEach((v, k) => k !== 'hash' && dataToCheck.push(`${k}=${v}`))
{"name":"jra1","description":"jra coin1","symbol":"jra1", "image":"https://cdn.joincommunity.xyz/clicker/moneta.png"}

14

That's what worked for me:

Generate ssh key github

  1. The Remotes

$ git remote rm origin $ git remote add origin git@github.com:/.git If your SSH key is already in use on another github rep, you can generate a new one.

class Queue<T = any> {
items: T[] = []
// Implementing various methods of javascript queue:
// 1. adding element to the queue
enqueue(item: T) {
this.items.push(item)
}
// 2. removing element from the queue
@nixjs
nixjs / doc.md
Created April 19, 2024 14:32
How to publish package on npmjs
  1. Create .npmrc.
  2. Add //registry.npmjs.org/:_authToken=${NPM_TOKEN} in .npmrc file.
  3. Generate access token from npmjs and put in zshrc, bashrc.
  4. Login npmjs by terminal npm adduser 5.1. pnpm --filter=package_name publish --no-git-checks // use pnpm and workspace 5.2. yarn npm publish // use yarn 5.3. npm publish // use npm
@nixjs
nixjs / toNotationObject.js
Created November 2, 2023 06:54
Convert javascript dot notation object to nested object
const obj = {
"start.headline": "1 headline",
"start.subHeadline": "subHeadline",
"start.accordion.headline": "2 headline",
"start.accordion.sections.0.content": "content 0",
"start.accordion.sections.0.iconName": "icon 0",
"start.accordion.sections.1.headline": "headline 1",
"start.accordion.sections.1.content": "content 1",
"start.accordion.sections.1.iconName": "icon 1",
"start.accordion.sections.2.headline": "headline 2",

How to fix node-gyp rebuild failed on MacOS

│ In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/string.h:141:
│ In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_rsize_t.h:30:
│ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/types.h:37:2: error: architecture not supported
│ #error architecture not supported
│  ^
│ fatal error: too many errors emitted, stopping now [-ferror-limit=]
│ 20 errors generated.
│ make: *** [Release/obj.target/validation/src/validation.o] Error 1
@nixjs
nixjs / swiper.ts
Created July 13, 2023 06:42
Resize slide per view in swiper
import React from 'react'
import { Randomize } from '@huula/utils'
import useSwiperRef from 'hooks/useSwiperRef'
import { Swiper, SwiperSlide, SwiperProps, SwiperRef } from 'swiper/react'
import SwiperCore, { Autoplay, Pagination, Navigation } from 'swiper'
import { Event } from './Event'
SwiperCore.use([Autoplay, Pagination, Navigation])
const slidesPerView = {
import BigNumber from 'bignumber.js'
export const accelerateNumber = (
target: number, // Input number
delay: number, // Delay timeout
duration: number, // Duration corresponding to each acceleration in s
decimals: number, // Decimals
onGetValue: (value: number) => void
) => {
let number = 0