Skip to content

Instantly share code, notes, and snippets.

View ibreathebsb's full-sized avatar
🤠

Isaac Young ibreathebsb

🤠
View GitHub Profile
@ibreathebsb
ibreathebsb / package.json
Last active November 28, 2018 13:03
webpack 4 config for react
{
"name": "whitealbum.io",
"description": "whitealbum.io",
"version": "1.0.0",
"keywords": [
"blog"
],
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server",
@ibreathebsb
ibreathebsb / upload.js
Last active April 5, 2023 04:43
file upload from dataUrl with axios
// Note: only for modern browser
import axios from 'axios'
// helper function: generate a new file from base64 String
const dataURLtoFile = (dataurl, filename) => {
const arr = dataurl.split(',')
const mime = arr[0].match(/:(.*?);/)[1]
const bstr = atob(arr[1])
let n = bstr.length
const u8arr = new Uint8Array(n)
@ibreathebsb
ibreathebsb / serviceWorkerUpdate.js
Created April 8, 2018 10:03
serviceWorker update
/**
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ibreathebsb
ibreathebsb / NumberFlip.ts
Last active June 25, 2018 10:34
NumberFlip
// NumberFlip.ts
import * as React from 'react';
import cStyle from './NumberFlip.scss'
class NumberFlip extends React.Component {
private static Nums = Array.from({ length: 11 }).map((v, i) => i % 10);
private num: number = 0;
private $content: HTMLElement | null;
private $scroller: HTMLElement | null;
private height: number = 0;
// tree node
class TreeNode {
constructor(value) {
this.value = value
this.parent = null
this.left = this.right = null
}
insert(newNode) {
const {
value

SUID

  1. 只对二进制程序有效,对shell脚本或者目录无效
  2. 拥有者的权限执行位改为s
  3. 执行者拥有x权限
  4. 执行者在运行程序过程中将获得改文件拥有者的权限

SGID

which

在用户的目录($PATH)下查找指定的可执行文件

~ which ifconfig
/sbin/ifconfig

组成

  1. inode 用于记录文件的权限信息,以及对应的data block编号,每个文件占用一个inode
  2. data block 用于存放文件的内容,每个文件至少占用一个
  3. superblock 用于记录整个文件系统的inode block用量以及文件系统相关信息

索引式文件系统,inode和block都有自己的编号,可以根据inode直接获取所有data block 的编号并直接访问,访问效率高

filesystem = boot sector + block group * n

df

df 列出文件系统的使用情况 df /somepath 会自动匹配该目录对应的文件系统并列出该文件系统的使用情况

du

du 列出文件大小

配置文件

cat /etc/fstab

# filesystem | mount point | type | mount option | dump | fsck
/dev/loop15 /snap/gnome-logs/37 squashfs ro,nodev,relatime 0 0
/dev/nvme0n1p1 /boot/efi vfat rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
/dev/nvme0n1p2 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0