Skip to content

Instantly share code, notes, and snippets.

@loggerhead
loggerhead / a.json
Last active October 25, 2023 13:40
diff-example
[
{
"recharge": 900000
},
{
"available": 0
}
]
@loggerhead
loggerhead / main.cpp
Last active October 11, 2020 05:25
producer-consumer
#include <atomic>
#include <condition_variable>
#include <iostream>
#include <mutex>
#include <queue>
#include <thread>
using namespace std;
const int nproducer = 4;
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <unistd.h>
#include "co_routine.h"
using namespace std;
int co_accept(int fd, struct sockaddr *addr, socklen_t *len);
@loggerhead
loggerhead / bwg-wacher.py
Created October 16, 2017 07:11
Notify you if there is update of stocks in https://bandwagonhost.com/cart.php
# -*- coding: utf-8 -*-
import os
import time
import requests
from datetime import datetime
from pyquery import PyQuery as pq
URL = 'http://bwh1.net/cart.php'
GAP = 3600

Keybase proof

I hereby claim:

  • I am loggerhead on github.
  • I am loggerhead (https://keybase.io/loggerhead) on keybase.
  • I have a public key ASCW0gT5PoNbkHrVE-vW5u6exOJTV0m76YVr93ERB60H5go

To claim this, I am signing this object:

/*
* 1. git clone https://github.com/tmk/tmk_keyboard.git
* 2. cp keymap_loggerhead.* tmk_keyboard/keyboard/hhkb/
* 3. make KEYMAP=loggerhead
* 4. run `dfu-programmer` commands with argument of "hhkb.hex", e.g:
*
* sudo dfu-programmer atmega32u4 erase
* dfu-programmer atmega32u4 flash hhkb.hex
* dfu-programmer atmega32u4 reset
*/
@loggerhead
loggerhead / ipc.c
Created April 14, 2017 08:23
Practices of IPC
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/un.h>
#include <sys/msg.h>
#include <sys/shm.h>
#include <sys/mman.h>
#include <sys/stat.h>
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@loggerhead
loggerhead / own_mut_each_other.rs
Last active August 2, 2016 09:50
A example of two object own each other.
use std::rc::Rc;
use std::cell::RefCell;
struct Foo {
// Owns multiple mut trait objects
bars: Vec<Rc<RefCell<Bar>>>,
}
impl Foo {
fn new() -> Foo {
@loggerhead
loggerhead / highlight.css
Created April 28, 2016 15:51
pygments used
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #808080 } /* Comment */
.highlight .err { color: #F00000; background-color: #F0A0A0 } /* Error */
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
.highlight .o { color: #303030 } /* Operator */
.highlight .cm { color: #808080 } /* Comment.Multiline */
.highlight .cp { color: #507090 } /* Comment.Preproc */
.highlight .c1 { color: #808080 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */