Skip to content

Instantly share code, notes, and snippets.

View secf4ult's full-sized avatar

Yu Xiao secf4ult

View GitHub Profile
@secf4ult
secf4ult / Oracle.sql
Last active June 21, 2024 03:20
SQL cheatsheet
-- Get the execution plan for the last command
SELECT * FROM dbms_xplan.display_cursor();
-- Get the hinted plan for the last command
SELECT * FROM dbms_xplan.display_cursor(format=>'+outline'));
pipeline {
agent any
parameters {
string(name: "myStringParam", description: "String Parameter")
choice(choices: ["Choice 1", "Choice 2"], name: "myChoiceParam", description: "Choice Parameter")
booleanParam(defaultValue: false, name: "myBooleanParam", description: "Boolean Parameter")
}
environment {
# jenkins
docker run -d -p 8081:8080 \
-p 50000:50000 \
--name jenkins \
-v jenkins-vol:/var/jenkins_home \
jenkins/jenkins:lts
@secf4ult
secf4ult / arrow-pointer.svg
Last active January 7, 2023 07:53
arrow-pointer svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@secf4ult
secf4ult / ackmann.c
Created February 23, 2021 10:30
Ackermann Function
#include <stdio.h>
int ack(int m, int n)
{
int ans;
if (m == 0) ans = n + 1;
else if (n == 0) ans = ack(m - 1, 1);
else ans = ack(m - 1, ack(m, n - 1));
return (ans);
}
@secf4ult
secf4ult / vue_reactivity.js
Last active February 23, 2021 10:32
Simple Vue reactivity.
const targetMap = new WeakMap()
let activeEffect = null
function track(target, key) {
let depsMap = targetMap.get(target)
if (!depsMap) {
targetMap.set(target, (depsMap = new Map()))
}
@secf4ult
secf4ult / setup_linux
Created February 23, 2021 07:22
Environment setup scripts.
#!/bin/sh
# Getting Ready
LOGDIR="~/log"
DOTFILES="~/.dotfiles"
# Update & Upgrade
sudo apt-get update -y
sudo apt-get upgrade -y
# Setup Prerequisite
@secf4ult
secf4ult / y.js
Last active February 9, 2021 08:34
Y Combinator in JavaScript
// from Crockford's talk: https://www.youtube.com/watch?v=ya4UHuXNygM
function Y(le) {
return (function (f) {
return f(f)
}(function (f) {
return le(function (x) {
return f(f)(x)
})
}))
}
@secf4ult
secf4ult / downloader.js
Last active December 8, 2020 08:37
Download file using JavaScript
const downloader = function (url, filename) {
// change these two variables
if (!url) throw new Error('url is needed!')
filename = filename || 'newfile'
fetch(url)
.then(res => res.blob())
.then(blob => {
const url = URL.createObjectURL(blob)
const anchor = document.createElement('a')
@secf4ult
secf4ult / set_npm_mirror
Created July 28, 2020 13:02
Setup npm mirror in China
# taobao mirror
npm config set registry https://registry.npm.taobao.org/
npm config set disturl https://npm.taobao.org/mirrors/node/
# thrid-party module
MIRROR_HOST=https://npm.taobao.org/mirrors
npm config set sass_binary_site $MIRROR_HOST/node-sass/
npm config set sharp_dist_base_url $MIRROR_HOST/sharp-libvips/
npm config set electron_mirror $MIRROR_HOST/electron/
npm config set puppeteer_download_host $MIRROR_HOST/puppeteer/