Skip to content

Instantly share code, notes, and snippets.

View LianSheng197's full-sized avatar
๐ŸŽ‰
ๆ”ฏๆŒๆœ‰ๆ„็พฉ็š„ไบ‹ / Support meaningful things.

b0ring LianSheng197

๐ŸŽ‰
ๆ”ฏๆŒๆœ‰ๆ„็พฉ็š„ไบ‹ / Support meaningful things.
  • Home
  • 12:36 (UTC +08:00)
View GitHub Profile
@LianSheng197
LianSheng197 / ast-parser-example.js
Created October 25, 2023 19:44
ไธ€ๅ€‹ๅƒ…ๆ”ฏๆŒ HTML ็š„ <html>, <head>, <body>, <title>, <h1>, <p> ๅ…ญ็จฎๆจ™็ฑค็š„ๆฅต็ฐก่ชžๆณ•ๅˆ†ๆž็ฏ„ไพ‹๏ผŒไธๅซๅฑฌๆ€งใ€่‡ช้–‰ๅˆๆจ™็ฑคใ€้Œฏ่ชคๆขๅพฉ็ญ‰ๅธธ่ฆ‹ HTML ๅŠŸ่ƒฝใ€‚ไปฅ JavaScript ็ทจๅฏซใ€‚
function lexer(input) {
const regex = /<\/?(title|h1|html|head|body|p)>|[^<]+/g;
let result, tokens = [];
while ((result = regex.exec(input)) !== null) {
tokens.push(result[0]);
}
return tokens;
}
function parser(tokens) {
@LianSheng197
LianSheng197 / __upload_file.md
Created December 10, 2022 01:20 — forked from maxivak/__upload_file.md
PHP upload file with curl (multipart/form-data)

We want to upload file to a server with POST HTTP request. We will use curl functions.


// data fields for POST request
$fields = array("f1"=>"value1", "another_field2"=>"anothervalue");

// files to upload
$filenames = array("/tmp/1.jpg", "/tmp/2.png");
const linkEl = document.createElement('link');
linkEl.rel = 'prefetch';
linkEl.href = urlWithYourPreciousData;
document.head.appendChild(linkEl);
@LianSheng197
LianSheng197 / base64url.php
Created December 27, 2021 10:21 — forked from nathggns/base64url.php
base64url functionality for php
<?php
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
function base64url_decode($data) {
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
@LianSheng197
LianSheng197 / OFCReportAnalysisCore.js
Created April 1, 2021 17:14
ๆˆ‘ๅ€‘็š„ๆตฎๆธธๅŸŽๆˆฐๅ ฑ่งฃๆžๆ ธๅฟƒ้‚่ผฏ๏ผˆไปฅ็Žฉๅฎถ็ˆฒไพ‹๏ผ‰
// ๅŽŸๆœฌๆƒณ่ชช่ฆ้–‹ๆบ๏ผŒ็ตๆžœๅพŒไพ†่ฆบๅพ—ๅฏฆๅœจๅฏซๅพ—ๅคชๅ™็ˆ›
// ๅ†ๅŠ ไธŠไธไน…ๅพŒๆœƒๆœ‰ๆ›ฟไปฃ็š„ๅฐˆๆกˆ๏ผˆไธๆ˜ฏๆˆ‘ๅฏซ็š„๏ผ‰
// ๆ‰€ไปฅ้€™่ฃกๅชๆ”พไธŠๆ ธๅฟƒ็‰‡ๆฎต
class Report {
static year = 2021;
static month = 3;
static day = 5;
static hour = 19;
static saveData = (faction, value) => {
Level โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰โ–‘โ–‘Lv.18/90%
Coding โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘5000/0
----------------------------------------
https://codestats.net/users/LianSheng
@LianSheng197
LianSheng197 / linux-kill-pts.md
Created June 26, 2020 13:59 — forked from holmberd/linux-kill-pts.md
Kill tty/pts sessions in Linux

Kill user tty/pts sessions in Linux

Commands

  • w: show who is logged on and what they are doing
  • who: show who is logged on
  • tty: show current users pseudo terminal
  • ps -ft pts/1: get process id for the pseudo terminal
  • pkill: signal process based on name and other attributes
@LianSheng197
LianSheng197 / bash_and_ansi_escape_sequence.md
Created June 18, 2020 11:59 — forked from JoshCheek/bash_and_ansi_escape_sequence.md
Explanation of a confusing line of bash code / ANSI escape sequences.
echo "\[\033[${2:-37};60m\]${1}\[\033[0m\]"

Echo is the program echo that you can run from the terminal. (eg $ echo hello world) it works here because the output of the function is being captured and put into a string.


@LianSheng197
LianSheng197 / curl.md
Created April 14, 2020 05:03 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@LianSheng197
LianSheng197 / ๐Ÿ“Š Weekly development breakdown
Last active April 3, 2021 00:07
๐Ÿ“Š Weekly development breakdown
Java 2 hrs 41 mins โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 37.5%
JSON 1 hr 47 mins โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Žโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 25.0%
JavaScript 1 hr 10 mins โ–ˆโ–ˆโ–ˆโ–โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 16.4%
PHP 24 mins โ–ˆโ–โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 5.6%
Python 23 mins โ–ˆโ–โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 5.5%