Skip to content

Instantly share code, notes, and snippets.

View LianSheng197's full-sized avatar
🎉
支持有意義的事 / Support meaningful things.

b0ring LianSheng197

🎉
支持有意義的事 / Support meaningful things.
  • Home
  • 06:43 (UTC +08:00)
View GitHub Profile
@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 / 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.