Skip to content

Instantly share code, notes, and snippets.

View czs0x55aa's full-sized avatar

czs0x55aa czs0x55aa

  • Huawei
  • shenzhen,China
View GitHub Profile
@czs0x55aa
czs0x55aa / win_wol.c
Created April 6, 2020 06:11
wake on lan using ethernet frame in windows
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <pcap.h>
u_char char_to_hex(char c)
{
if (c >= '0' && c <= '9')
{
return c - '0';

Python

def singleton(cls):
    instance = cls()
    instance.__call__ = lambda: instance
    return instance

@singleton
class Highlander:
 x = 100
@czs0x55aa
czs0x55aa / SortingAlgorithms.md
Last active October 1, 2017 03:56
Sorting Algorithms with Python

QuickSort

def quickSort(arr):
	if len(arr) < 2:
		return arr

	pivot = arr[0]
	i = 0
	for j in range(len(arr)-1):
 if arr[j+1] &lt; pivot:
@czs0x55aa
czs0x55aa / print_model_parameters.py
Created September 12, 2017 14:08
print model parameters in pytorch
for name, param in model.state_dict().items():
print(name, param.size())
@czs0x55aa
czs0x55aa / addition.py
Last active September 6, 2017 09:21
use rnn to fit addition operator
# coding=utf8
import random
import torch
import torch.nn as nn
from torch import optim
from torch.autograd import Variable
batch_size = 64
n_epochs = 2000
learning_rate = 0.001