Skip to content

Instantly share code, notes, and snippets.

View crazyguitar's full-sized avatar
🎯
Focusing

CHANG-NING TSAI crazyguitar

🎯
Focusing
View GitHub Profile
@crazyguitar
crazyguitar / gdb-trace.py
Created January 2, 2020 23:34 — forked from Houdini/gdb-trace.py
Trace all function calls using gdb
#!/usr/bin/env python
try:
import gdb
inside_gdb = True
except ImportError:
inside_gdb = False
if inside_gdb:
@crazyguitar
crazyguitar / mapread.c
Created January 17, 2020 16:43 — forked from marcetcheverry/mapread.c
mmap and read/write string to file
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
int main(int argc, const char *argv[])
{
@crazyguitar
crazyguitar / Timer.cpp
Created February 2, 2020 23:46 — forked from mcleary/Timer.cpp
C++ Timer using std::chrono
#include <iostream>
#include <chrono>
#include <ctime>
#include <cmath>
class Timer
{
public:
void start()
{
@crazyguitar
crazyguitar / custom_iterator.cpp
Created February 5, 2020 14:31 — forked from jeetsukumaran/custom_iterator.cpp
Sample C++/STL custom iterator
// Sample custom iterator.
// By perfectly.insane (http://www.dreamincode.net/forums/index.php?showuser=76558)
// From: http://www.dreamincode.net/forums/index.php?showtopic=58468
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cassert>
@crazyguitar
crazyguitar / http_client.cc
Created February 13, 2020 01:23 — forked from Tosainu/http_client.cc
[WIP] An asynchronous HTTP client using Boost.Asio's stackful coroutines.
#include <iostream>
#include <istream>
#include <ostream>
#include <boost/asio.hpp>
#include <boost/asio/spawn.hpp>
class client {
public:
client(boost::asio::io_service& io_service, const std::string& server, const std::string& path)
: resolver_(io_service), socket_(io_service) {
@crazyguitar
crazyguitar / phoronix-cmd.md
Created September 15, 2020 04:58 — forked from anshula/phoronix-cmd.md
Phoronix Test Suite Cheat Sheet
@crazyguitar
crazyguitar / event.cpp
Created September 18, 2020 01:20 — forked from darkf/event.cpp
Simple event system in C++
#include <functional>
#include <map>
#include <typeinfo>
#include <iostream>
struct Event {
virtual ~Event() {}
};
struct TestEvent : Event {
std::string msg;
Run this command to install MG-CLI:
sudo apt-get update && wget https://minergate.com/download/deb-cli -O minergate-cli.deb && sudo dpkg -i minergate-cli.deb
to start miner (4 cores for BCN) use this command:
minergate-cli -user <[email protected]> -bcn 4
Feel free to send some of your earnings to me:
BTC (Don't attempt to send other coins to this address!): 17f77AYHsQbdsB1Q6BbqPahJ8ZrjFLYH2j
@crazyguitar
crazyguitar / example.cpp
Created October 14, 2020 17:19 — forked from dflemstr/example.cpp
A C++ implementation of fixed point math
#include "fixedp.h"
#include <iostream>
int main(int, char **)
{
fixedp<true, 16, 16> x(0); //32-bit signed 16.16 fixed-point number
fixedp<false, 8, 8> y(10); //16-bit unsigned 8.8 fixed-point number
std::cout << (fixedp<false, 4, 4>(3.5) + fixedp<false, 4, 4>(4.5)).toFloat() << std::endl;
//prints "8"