Skip to content

Instantly share code, notes, and snippets.

View byurhannurula's full-sized avatar
🏠
Working from home

Byurhan Nurula byurhannurula

🏠
Working from home
View GitHub Profile
@byurhannurula
byurhannurula / actor.js
Created March 11, 2024 09:36
ICP Canister usage
import fetch from 'isomorphic-fetch';
import { HttpAgent } from '@dfinity/agent';
import { TRACING_CANISTER_ID, FACADE_CANISTER_ID } from '../config';
import { createActor as createTracingActor } from './declarations/tracing';
import { createActor as createFacadeActor } from './declarations/facade';
import { custodianIdentity } from './identity';
const agent = new HttpAgent({
identity: custodianIdentity,
server {
server_name grvty-relay.recheck.io;
set $upstream 127.0.0.1:4001;
location / {
proxy_pass_header Authorization;
proxy_pass http://$upstream;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@byurhannurula
byurhannurula / index.js
Created November 4, 2021 08:33
Check string if it's a JWT token
const JWT_PATTERN = "(^[A-Za-z0-9-_]*\\.[A-Za-z0-9-_]*\\.[A-Za-z0-9-_]*\$)";
function isJWT(data) {
return new RegExp(JWT_PATTERN).matches(data);
}
function handleFiles(files) {
let file = files[0];
if (file === undefined) return;
let sizeDone = 0;
let counter = 0;
let dataHash = null;
let dataOriginalHash = null;
let chunkCount = parseInt(Math.ceil(fileSize / chunkSize));
@byurhannurula
byurhannurula / index.js
Last active January 17, 2021 10:25
Insert millions rows from CSV file into DB as chunks using Sequelize ORM's bulkCreate() function
const csv = require("csvtojson");
const { user } = require("./db/models")
let transaction = null;
let filePath = `${__dirname}/file.csv`;
const csvParseOptions = {
ignoreEmpty: true,
headers: ["field1", "field2", "field3", "field4", "field5"],
colParser: {
@byurhannurula
byurhannurula / setup.md
Last active May 17, 2021 08:14
ESLint/Prettier setup for VS Code

ESLint/Prettier setup for VS Code

Install dependencies

npm install --save-dev babel-eslint eslint eslint-config-airbnb eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks prettier

Configure ESLint .eslintrc.js

@byurhannurula
byurhannurula / use-color-mode.js
Created October 30, 2020 11:42
React.js hook for light/dark theme
import { useState, useEffect } from 'react'
export const useColorMode = () => {
const [theme, setTheme] = useState(
window.localStorage.getItem('theme') || 'light',
)
const setNewTheme = (newTheme) => {
setTheme(newTheme)
window.localStorage.setItem('theme', newTheme)
#!/bin/bash
set -euo pipefail
# Display message 'Setting up your Mac...'
echo "Setting up your Mac..."
sudo -v
# Installing XCodes cli tools...
if type xcode-select >&- && xpath=$( xcode-select --print-path ) &&
test -d "${xpath}" && test -x "${xpath}" ; then
@byurhannurula
byurhannurula / ubuntu_nginx_node_ssl.md
Last active May 30, 2020 15:34
Setup Nginx server with Node.js on Ubuntu Server

Node.js Deployment

Steps to deploy a Node.js app to Ubuntu Server VM using PM2, NGINX and an SSL from LetsEncrypt

1. Create VM

2. Install Curl

@byurhannurula
byurhannurula / gist:8cccce3da9ae527358ea76f507b8e505
Created May 1, 2020 12:33 — forked from kitek/gist:1579117
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");