Skip to content

Instantly share code, notes, and snippets.

View fengyfei's full-sized avatar
🏠
Working from home

Feng Yifei fengyfei

🏠
Working from home
View GitHub Profile
@fengyfei
fengyfei / main.go
Created June 23, 2022 10:11
[Go] Sudo execution
package main
import (
"bytes"
"io"
"log"
"os/exec"
"strings"
"sync"
"time"
@fengyfei
fengyfei / main.go
Created June 23, 2022 10:10
[Go] SSH Password Mode
package main
import (
"bytes"
"fmt"
"log"
"golang.org/x/crypto/ssh"
)
@fengyfei
fengyfei / main.go
Created June 19, 2022 05:33
[Go] Command Input
package main
import(
"log"
"os/exec"
"os"
"io"
)
func main() {
@fengyfei
fengyfei / main.go
Created June 19, 2022 05:31
[Go] Command Output
package main
import(
"log"
"os/exec"
"io"
)
func main() {
process := exec.Command("ls", "-la")
@fengyfei
fengyfei / main.c
Created June 17, 2022 08:26
[C] Linked List
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
struct node *next;
int value;
} node_t, *node_ptr;
typedef struct list {
node_ptr head;
@fengyfei
fengyfei / index.js
Created March 23, 2021 14:09
[P5][Particles]
let systems;
function setup() {
createCanvas(710, 400);
systems = [];
}
function draw() {
background(51);
background(0);
@fengyfei
fengyfei / index.js
Created March 23, 2021 10:33
[P5][Sin]
let x = 0;
const xAxis = 480;
const yAxis = 360;
function setup() {
createCanvas(xAxis, yAxis);
stroke('purple');
strokeWeight(4);
frameRate(16);
}
@fengyfei
fengyfei / main.go
Last active September 24, 2019 03:08
[Go][Struct][Selector] Collection
package main
import (
"fmt"
)
type Sample interface {
Any()
Some()
}
@fengyfei
fengyfei / main.go
Created July 20, 2019 07:27
[Go][Reflect] AssignableTo & ConveribleTo
package main
import (
"fmt"
"reflect"
)
func EnforcePtr(obj interface{}) (reflect.Value, error) {
v := reflect.ValueOf(obj)
if v.Kind() != reflect.Ptr {
@fengyfei
fengyfei / main.go
Created July 20, 2019 07:11
[Go][Reflect] Enforce Pointer & CanSet
package main
import (
"fmt"
"reflect"
)
func EnforcePtr(obj interface{}) (reflect.Value, error) {
v := reflect.ValueOf(obj)
if v.Kind() != reflect.Ptr {