Skip to content

Instantly share code, notes, and snippets.

@wyyqyl
wyyqyl / type_assertion.go
Created December 4, 2014 15:24
Example of type assertion failure
package main
import (
"fmt"
)
type Aer interface {
DoA()
}
@wyyqyl
wyyqyl / base64.cpp
Last active August 29, 2015 14:10
Base64 Encoding and Decoding
std::string base64_encode(const std::string& in) {
BUF_MEM *bptr;
BIO* b64 = BIO_new(BIO_f_base64());
BIO* bio = BIO_new(BIO_s_mem());
bio = BIO_push(b64, bio);
BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
BIO_write(bio, in.c_str(), (int)in.size());
BIO_flush(bio);
BIO_get_mem_ptr(bio, &bptr);
@wyyqyl
wyyqyl / 189cm.go
Created November 21, 2014 12:36
send packets to server to emulate user operation
package main
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"math/rand"
"net/http"
"net/url"
@wyyqyl
wyyqyl / icmp.go
Last active August 29, 2015 14:09
ping request
package main
import (
"bytes"
"encoding/binary"
"fmt"
"net"
"time"
)
@wyyqyl
wyyqyl / port.py
Created October 28, 2014 01:42
port occupation demo
import socket
HOST = '127.0.0.1'
try:
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s1.bind((HOST, 13748))
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.bind((HOST, 15428))
@wyyqyl
wyyqyl / run_process.cpp
Created July 18, 2014 06:15
run_process
void run_process(const wchar_t* name, const wchar_t* param) {
SHELLEXECUTEINFOW info;
info.cbSize = sizeof(SHELLEXECUTEINFOW);
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.hwnd = NULL;
info.lpVerb = NULL;
info.lpFile = name;
info.lpParameters = param;
info.lpDirectory = NULL;
info.nShow = SW_HIDE;
@wyyqyl
wyyqyl / cpplint.py
Last active August 29, 2015 14:02
This is automated checker to make sure a C++ file follows Google's C++ style guide (http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml).
#!/usr/bin/python
#
# Copyright (c) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
@wyyqyl
wyyqyl / 0_reuse_code.js
Created June 13, 2014 15:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@wyyqyl
wyyqyl / download_crx.go
Created April 29, 2014 13:24
Download .crx file from web server, and don't let chrome display yellow bar at the top of the page
package main
import (
"log"
"net/http"
"os"
"strconv"
)
func handler(w http.ResponseWriter, r *http.Request) {
@wyyqyl
wyyqyl / SimpleWinMain.cpp
Created April 16, 2014 06:38
simple winmain application
// bsm.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "bsm.h"
HINSTANCE hInst;
TCHAR szTitle[] = TEXT("");
TCHAR szWindowClass[] = TEXT(" ");