Skip to content

Instantly share code, notes, and snippets.

View agungkes's full-sized avatar
🎯
Tancap Gan

Agung agungkes

🎯
Tancap Gan
View GitHub Profile
// Below code is for internal process manager and it not expose to internet or directly accessable.
// Before using for production please validation all inputs to prevent exec injection.
import dotenv from "dotenv";
dotenv.config();
import pm2 from "pm2";
import fs from "fs";
import Fastify from "fastify";
import { execSync } from "child_process";
const fastify = Fastify({
@ChemaCLi
ChemaCLi / pdf-charts-generator.js
Last active May 7, 2025 11:44
Generate PDF with ChartJS and PDFKit
const fs = require('fs')
const tmp = require("tmp");
const PDFDocument = require('pdfkit');
const MemoryStream = require('memorystream');
const { ChartJSNodeCanvas } = require('chartjs-node-canvas');
export async function generatePDFWithCharts() {
// Sample chart with ChartJS
const chartJSNodeCanvas = new ChartJSNodeCanvas({ type: 'png', width: 800, height: 600 });
const configuration = {
@dkvadratu
dkvadratu / http_headers_security.htaccess
Last active March 25, 2026 00:26
{HTACCESS} HTTP headers for security in .htaccess file
# Check your website headers here: https://www.serpworx.com/check-security-headers/ or https://gf.dev/
# This configuration works for WP, WC on LiteSpeed server. Be careful. Test site after installing. All lines are explained are in serpworx.com tester.
# More docs:
# https://www.netsparker.com/whitepaper-http-security-headers/#XFrameOptionsHTTPHeader
# https://owasp.org/www-project-secure-headers/
# https://www.keycdn.com/blog/http-security-headers
# WordPress plugin for Headers setup https://wordpress.org/plugins/http-headers/
# Main security options in .htaccess file:
@kleysonr
kleysonr / face_liveness.html
Last active October 16, 2025 12:40
Mediapipe facemesh eye blink for face liveness detection example
<html>
<head>
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Require the peer dependencies of facemesh. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@2.6.0/dist/tf-core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-converter@2.6.0/dist/tf-converter.min.js"></script>
@nikolasburk
nikolasburk / nextjs-and-prisma.md
Last active July 1, 2023 22:59
Fullstack Apps with Next.js and Prisma (PostgreSQL, MySQL & SQLite)

🚀 Fullstack Apps with Next.js and Prisma

Next.js blurs the lines between client and server. It supports pre-rendering pages at build time (SSG) or request time (SSR). Prisma is the perfect companion if you need to work with a database in a Next.js app.

Here is a list of example apps that are based on Next.js and use Prisma on the server to access data from a database:

✍️ Language 🤖 Server 🔐 Authentication 🔗 URL
TypeScript API Routes Yes (via NextAuth.js) URL
TypeScript API Routes No
@hiorws
hiorws / face-detection.py
Created May 12, 2020 16:43 — forked from bookjan/face-detection.py
Using python opencv to detect face and send the frames to FFmpeg to create HLS(HTTP Live Streaming)
import numpy as np
import cv2
import sys
cap = cv2.VideoCapture(0)
face_cascade = cv2.CascadeClassifier('<PATH_TO_CASCADES_FOLDER>/haarcascade_frontalface_default.xml')
while(True):
# Capture frame-by-frame
@derindutz
derindutz / use-persistent-swr.ts
Last active January 6, 2023 08:11
useSWR with localforage as a persistent cache
import useSWR from '@zeit/swr';
import localForage from 'localforage';
import { ConfigInterface } from '@zeit/swr/dist/src/types';
import { useState, useEffect } from 'react';
export function usePersistentSWR(key: string, fn?: Function, config?: ConfigInterface) {
let handleSuccess;
if (config !== undefined && config.onSuccess !== undefined) {
const { onSuccess } = config;
handleSuccess = (data: any, key: string, config: ConfigInterface) => {
@laravel-shift
laravel-shift / .php-cs-fixer.php
Last active March 13, 2026 09:10
PHP CS Fixer - Laravel Coding Style Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
@nasrulhazim
nasrulhazim / .htaccess
Last active December 5, 2024 01:43
Laravel .htaccess with Security & Optimisation
# Directory Listing
Options -Indexes
<IfModule mod_security.c>
# Server Information Disclosure
ServerTokens Prod
ServerSignature Off
SecServerSignature " "
</IfModule>
@FMCorz
FMCorz / requests.js
Last active October 24, 2022 06:58
Axios with a custom cache adapter. It handles setting cache to groups to permit invalidating a bunch at once, and it returns cache data when there is an error with the request.
import Axios from 'axios';
import { setupCache } from 'axios-cache-adapter';
import localforage from 'localforage';
import find from 'lodash/find';
import isEmpty from 'lodash/isEmpty';
const CACHE_MAX_AGE = 2 * 60 * 60 * 1000;
// Extracting 'axios-cache-adapter/src/exclude' as importing it leads to webpack not compiling it.
function exclude(config = {}, req) {