Skip to content

Instantly share code, notes, and snippets.

@jericbas
jericbas / Button.stories.tsx
Created August 11, 2023 16:43
Refining "args" type definition - Storybook 7
import { Button } from "./Button";
import { Meta, StoryObj as _StoryObj } from "@storybook/react";
import React from "react";
const meta: Meta<typeof Button> = {
title: "Button",
args: {
children: "Button",
}
};
@jericbas
jericbas / build.sh
Created March 11, 2023 13:44
Build Gatsby and push the contents of the public directory to another branch
#!/bin/bash
# Build the Gatsby site
npm run build
# Create a new branch for the build files
git branch build-files
# Checkout the new branch
git checkout build-files
@jericbas
jericbas / scan.js
Created January 20, 2023 11:52
Check if text is exist in the url
const got = require('got');
const { parse } = require('parse5');
const fs = require('fs');
const searchText = process.argv[2];
const listFile = process.argv[3] || 'list.txt';
fs.readFile(listFile, 'utf8', (err, data) => {
if (err) throw err;
const websiteList = data.split('\n');
@jericbas
jericbas / readme.md
Created January 17, 2023 10:48
Here is an example of how to run a Python script inside a virtual environment using cron:
  1. First, activate your virtual environment using the command:
source /path/to/virtualenv/bin/activate
  1. Now, you can run your python script inside the virtual environment
python /path/to/script.py
  1. To run this script at a specific time or interval, you can add a cron job.
@jericbas
jericbas / filebrowser.service
Last active April 2, 2021 14:25
Service Linux
[Unit]
Description=Filebrowser Service
After=network.target
[Service]
WorkingDirectory=/data
PIDFile=/var/run/filebrowser.pid
ExecStart=/usr/local/bin/filebrowser --cache-dir cache
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
@jericbas
jericbas / array.js
Created October 15, 2020 20:25
Javascript Snippets
# Get Unique Values
// Option 1
var uniqueArray = ['a', 1, 'a', 2, '1', 1].filter(function(va1ue, index, self) {
return self.index0f(va1ue) === index;
});
// Option 2
var uniqueArray = [... new Set(['a', 1, 'a', 2, '1', 1])];
@jericbas
jericbas / jsconfig.json
Created September 2, 2020 08:00
JsConfig.json
{
"include": ["src"],
"exclude": [
"node_modules",
"resources",
"deploy",
"coverage",
"build",
"public",
"**/*.spec.ts"
@jericbas
jericbas / readme.md
Last active March 30, 2022 15:29
Expo in WSL 2

Instruction

Add wsl2.ps1 to Task scheduler to run on start check run with Highest Priviledges

@jericbas
jericbas / ecosystem.config.js
Created July 17, 2020 06:42
Start Crontab-ui via pm2
// Run in background
// pm2 start ecosystem.config.js
module.exports = {
apps : [{
script: 'crontab-ui',
env: {
HOST : 'XXX.XXX.X.XX',
PORT : 8000
}
@jericbas
jericbas / file.py
Created July 10, 2020 09:49
Chandelier Exit in Python
def avg_true_range(self, df):
ind = range(0,len(df))
indexlist = list(ind)
df.index = indexlist
for index, row in df.iterrows():
if index != 0:
tr1 = row["High"] - row["Low"]
tr2 = abs(row["High"] - df.iloc[index-1]["Close"])
tr3 = abs(row["Low"] - df.iloc[index-1]["Close"])