Skip to content

Instantly share code, notes, and snippets.

View beordle's full-sized avatar
💌
On vacation, oh..

Jindong Zhang beordle

💌
On vacation, oh..
  • Tencent
  • Beijing, China
View GitHub Profile
@pjobson
pjobson / 0.win10_phy_to_virtualbox_vm.md
Last active December 27, 2021 03:45
Windows 10 Physical Drive to VirtualBox VM

Windows Physical Drive to VirtualBox VM

What You Need

  • Windows Computer (I'm using Win10)
  • Linux Computer (I'm using Mint 20.1)
  • External Drive
    • The largest supported image size is 127GB, so if you have a bunch of personal files on your Windows computer, migrate it to a different drive..

Boot your Windows Machine

@ianlewis
ianlewis / sys_sum.go
Created May 25, 2019 16:42
Simple syscall in gVisor
// Copyright 2018 The gVisor Authors.
//
// 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
// distributed under the License is distributed on an "AS IS" BASIS,
#include <sys/socket.h>
#include <linux/memfd.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
void broadcaster( int socket )
{
@laobubu
laobubu / ABOUT.md
Last active March 23, 2024 05:28
A very simple HTTP server in C, for Unix, using fork()

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913
@nasitra
nasitra / backtrace.c
Created October 9, 2016 06:31
Print call stack by using libunwind
#include <libunwind.h>
#include <libunwind-ptrace.h>
#include "backtrace.h"
#define MAX_BACKTRACE_FRAMES 64
void unwind(pid_t pid) {
unw_addr_space_t addr_space = NULL;
struct UPT_info* upt_info = NULL;

最终实现效果:

  1. 无版本概念,任何本地文件均可增量升级到最新.服务器不用管理多版本
  2. 内存小,100M文件升级时只占用500KB内存.

使用流程:

  1. 制作新版本,上传HTTP File Server.
  2. Client自动计算差异,下载差异,合并差异.
  3. done!

#0.起源

@aero
aero / readline_ev.cpp
Created March 12, 2015 09:12
Example: Integrating readline with libev eventloop.
// g++ -o readline_ev -g readline_ev.cpp -g -lreadline -lev
//
#include <stdlib.h>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <ev.h>
#include <fcntl.h>
@gchudnov
gchudnov / cpp_utf8_utf16.cpp
Created November 6, 2014 19:33
C++ string conversion UTF8 <-> UTF16
#include <string>
#include <locale>
#include <codecvt>
//UTF-8 to UTF-16
std::string source;
//...
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
std::u16string dest = convert.from_bytes(source);
@andelf
andelf / EasyJSON.swift
Last active August 29, 2015 14:03
Swift JSON Helper
import Foundation
//let raw = String.stringWithContentsOfURL(NSURL(string: "http://www.weather.com.cn/data/sk/101010100.html"))
struct EasyJSON {
var _obj: AnyObject!
init(_ obj: AnyObject) {
//assert(NSJSONSerialization.isValidJSONObject(obj), "must be valid json object")
_obj = obj
@vincenting
vincenting / client.py
Last active February 5, 2021 06:42
微信公共平台脚本
# coding=utf-8
__author__ = 'Vincent Ting'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Vincent Ting'
import cookielib
import urllib2