Skip to content

Instantly share code, notes, and snippets.

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

lucas lixin9311

🏠
Working from home
View GitHub Profile
@lixin9311
lixin9311 / hw2pcap.go
Created April 21, 2024 15:35
Convert Huawei OMCI debug output to pcap
package main
import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
"io"
"log"
"os"
SU_WAP>display system info
local telnet flag is , diag source is telnet
Begin to collect the data
Open device /dev/pts/4 OK! iFile = 5.
=======================================================
Start run collect command:WAP:display version
display version
hardware version = 2022.A
@lixin9311
lixin9311 / chan.swift
Created June 2, 2022 16:14
Golang like channel in swift
import Foundation
enum ChanError: Error {
case ChannelClosed(String)
}
precedencegroup ChanSendRecv {
associativity: left
}
@lixin9311
lixin9311 / driver.go
Created May 12, 2022 09:23
Go generic datastore db driver
package dbdriver
import (
"context"
"errors"
"reflect"
"cloud.google.com/go/datastore"
)
@lixin9311
lixin9311 / referrer-override.js
Created June 30, 2021 07:26
Tampermokey script overriding document.referrer
// ==UserScript==
// @name Referrer override
// @namespace https://example.com
// @description Override the document.referrer
// @author Lucas Li
// @match https://example.com/*
// @icon https://www.google.com/s2/favicons?domain=example.com
// @grant none
// ==/UserScript==
@lixin9311
lixin9311 / fan.sh
Created June 3, 2021 10:35
idrac fan control
#!/bin/bash
## T620 Fan Script Inspired by https://github.com/NoLooseEnds/Scripts/tree/master/R710-IPMI-TEMP
## Require user (non-sudo) access to ipmitool (essentially /dev/ipmi0)
## Possible solution: chown :sudo `which ipmitool`; chmod u+s `which ipmitool`
## To disable dynamic fan control: ipmitool -I lanplus -H $IDRACIP -U $IDRACUSER -P $IDRACPASSWORD raw 0x30 0x30 0x01 0x00
IDRACIP="192.168.1.xxx"
IDRACUSER="root"
@lixin9311
lixin9311 / marshaler.go
Created September 8, 2020 14:41
converting a grpc-gateway server stream to server-sent event
/*
Copy & paste from grpc-gateway JSONPb marshaler.
Only the ContentType(), Marshal() and Delimiter() was modified.
Don't enable indent, it will break SSE.
*/
package sse
import (
"bytes"
"encoding/json"
from keras.models import Model
from keras.layers import Conv2D, Input, UpSampling2D, Lambda, Layer
from keras.optimizers import *
from keras import backend as K
from keras.applications import VGG19
from ops import *
class UNet():
def __init__(self):
self.imgshape = (None, None, 3)
package dummy
import (
"fmt"
"os"
"os/signal"
"syscall"
"testing"
"time"
package main
import (
"flag"
"fmt"
"io/ioutil"
"strings"
"sync"
)