Skip to content

Instantly share code, notes, and snippets.

View dipsywong98's full-sized avatar
👶
Teletubbies say hello

Dipsy Wong dipsywong98

👶
Teletubbies say hello
View GitHub Profile
@dipsywong98
dipsywong98 / run_with_timeout.bat
Created January 6, 2018 05:06
php execute program with timeout using batch file in windows server
::param 1 is executable, param 2 is timeout seconds
echo "running %1 with timeout %2"
start %1
set time=0
:check
tasklist /FI "IMAGENAME eq %1" 2>NUL | find /I /N "%1">NUL
::time limit exceed
if "%time%"=="%2" goto kill
::program is running
if "%ERRORLEVEL%"=="0" ( ping 127.0.0.1 -n 2 >nul & set /a time=%time%+1 & goto check) else ( goto end)
@dipsywong98
dipsywong98 / 路亞闖關(BETA).lua
Created March 23, 2018 14:47
路亞闖關(BETA)的模板
--play at http://tw.gamelet.com/mission.do?code=csArena&gltParam=%7B%27mode%27%3A%27userMission%27%2C+%27id%27%3A%27270136%27%7D
--請不要更改第1至第1行的程式碼
require "sys.game"
if level == nil then
--請在此初始化你的程式
elseif level == 1 then
--第一關目標:說出 hello world
@dipsywong98
dipsywong98 / 路亞闖關(BETA)_ans.lua
Created October 27, 2018 16:00
路亞闖關(BETA)的答案
--play at http://tw.gamelet.com/mission.do?code=csArena&gltParam=%7B%27mode%27%3A%27userMission%27%2C+%27id%27%3A%27270136%27%7D
--請不要更改第1至第1行的程式碼
require "sys.game"
if level == nil then
--請在此初始化你的程式
elseif level == 1 then
--第一關目標:說出 hello world
@dipsywong98
dipsywong98 / Setup-new-subdomain-on-NginX-with-redirected-SSL.md
Last active June 12, 2019 14:27
Setup new subdomain on NginX with redirected SSL

Config root login for server

  1. add ssh public key to /root/.ssh/authorized_keys

  2. Refer to the following to set root login:

sudo -s (to become root)
vi /root/.ssh/authorized_keys

Apollo Notes

Resolver

fieldName: (parent, args, context, info) => data;

Lazy query in graphql

Sometimes we are not interested in getting all values of a node, we can do some tricks to prevent loading extra contents or generating infinite circular structure. Below example the users have many books, and each book have one owner, which is a user again. How can we query the user without returning the books, or reuse the node resolver if we want to return the books?

KDE screenshot with copy

  1. install xclip
sudo apt-get install xclip
  1. create a new shortcut
@dipsywong98
dipsywong98 / auto-love.js
Created March 27, 2020 12:12
FB 直播全自動俾心
window.setInterval(() => document.querySelector('[aria-label="勁正"]').click(), 1000)
@dipsywong98
dipsywong98 / ThreeViewer.tsx
Created August 31, 2020 11:51
React Component of three.js
import React, { useCallback, useEffect, useRef, useState } from 'react'
import * as THREE from 'three'
export const ThreeViewer = () => {
const root = useRef<HTMLDivElement>(null)
const [{ renderer, camera }, set3] = useState<{ renderer?: THREE.Renderer, camera?: THREE.PerspectiveCamera }>({})
const resize = useCallback((): void => {
const div = root.current
if (div !== null && renderer !== undefined && camera !== undefined) {
camera.aspect = div.clientWidth / div.clientHeight