Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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

Siwat Kaolueng perjerz

🏠
Working from home
View GitHub Profile
const TMDB_IMAGE_BASE_URL = 'https://image.tmdb.org/t/p/';
addEventListener("fetch", e => {
const url = new URL(e.request.url);
if (url.pathname === "/image") {
e.respondWith((async () => {
const width = url.searchParams.get("width");
const path = url.searchParams.get("path");
try {
return await fetch(`${TMDB_IMAGE_BASE_URL}/w${width}${path}`, {mode: "no-cors"});
@perjerz
perjerz / data-table.component.html
Created November 27, 2022 05:38 — forked from pjlamb12/data-table.component.html
Angular Data Table Component
<content-section
[csTitle]="title"
[collapsible]="collapsible"
[state]="state"
[locked]="locked"
[noButtons]="noButtons"
[buttons]="_buttons"
>
<!-- Custom controls -->
<ng-content></ng-content>
@perjerz
perjerz / README.md
Created September 14, 2022 05:38 — forked from peerreynders/README.md
µsignal 0.4.0 performance comparison

Sample run on Ubuntu 22.04 LTS [i7-4900MQ CPU @ 2.80GHz/32GB] Chromium 105.0.5195.102

Solid (solid.html)

Created 205760 nodes.
  1 ms; sum: 4.55651722365801e+305
278 ms; sum: 9.11303444731602e+305

@preact/signals (preactive.html)

@perjerz
perjerz / canvas color picker.html
Created August 9, 2022 10:19 — forked from lovasoa/canvas color picker.html
JS color picker: HTML5 & javascript color picker that uses HTML5 canvas. User can choose hue and value, saturation is set to 1. It has color history management.
<!doctype html>
<html>
<head>
<meta charset="utf8" />
<title>Canvascolor</title>
<style>
body {
background-image:url(http://github.com/favicon.ico); /*Just for fun*/
}
main {
@perjerz
perjerz / elasticsearch.json
Created July 25, 2022 15:58
elasticsearch query
GET _search
{
"query": {
"match_all": {}
}
}
GET _cat/indices
GET dev-content
@perjerz
perjerz / binding.gyp
Created July 10, 2022 09:04
node-gyp with icu4c
# https://github.com/perjerz/node-icu-tokenizer
{
'targets': [
{
'target_name': 'node-icu-tokenizer',
'sources': [ 'node-icu-tokenizer.cpp' ],
'cflags_cc': [
'-std=c++17',
'-fexceptions',
'-Wall',
@perjerz
perjerz / binding.gyp
Created July 10, 2022 09:03
node-gyp with icu4c
{
'targets': [
{
'target_name': 'node-icu-tokenizer',
'sources': [ 'node-icu-tokenizer.cpp' ],
'cflags_cc': [
'-std=c++17',
'-fexceptions',
'-Wall',
'-O3'
/**
* @param {number[]} nums
* @return {number}
*/
var removeDuplicates = function(nums) {
const length = nums.length;
let i = 1;
let startIndex = 0;
let count = 0;
while(i < nums.length && nums[i] != undefined) {
@perjerz
perjerz / merge-two-sorted-lists.js
Created June 26, 2022 08:30
Merge Two Sorted Lists -- Leetcode
// https://leetcode.com/problems/merge-two-sorted-lists/submissions/
/**
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode} list1
/**
* @param {string[]} strs
* @return {string}
*/
var longestCommonPrefix = function(strs) {
const length = strs.length;
if (length == 0) {
return '';
} else if (length == 1) {
return strs[0];