Skip to content

Instantly share code, notes, and snippets.

View uchan-nos's full-sized avatar

Kota UCHIDA uchan-nos

View GitHub Profile
uint32_t Read32(const char* data) {
return static_cast<unsigned char>(data[0])
| (static_cast<unsigned char>(data[1]) << 8u)
| (static_cast<unsigned char>(data[2]) << 16u)
| (static_cast<unsigned char>(data[3]) << 24u);
}
int main() {
char b = -1;
cout << static_cast<int>(b) << endl;
cout << static_cast<uint32_t>(b) << endl;
cout << static_cast<uint32_t>(static_cast<unsigned char>(b)) << endl;
}
class Base;
class Sub;
shared_ptr<Base> create(Kind k) {
switch (k) {
case kHoge:
return shared_ptr<Base>(new Sub());
}
return shared_ptr<Base>();
}
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#!/usr/bin/python34
import codecs
import mistune
md_text = '''\
this is markdown.
```
@uchan-nos
uchan-nos / webapp.py
Last active August 29, 2015 14:27
web application for socat command.
#!/usr/bin/python3
import json
import re
from socket import gethostname
from subprocess import check_output
MEM_INFO_PATTERN = re.compile('^([^ ]+): *([0-9]+) ?([A-Za-z]+)?$')
@uchan-nos
uchan-nos / rpn.go
Created November 22, 2015 02:08
Reverse Polish Notation Calculator in Golang. (naive implementation)
package main
import (
"fmt"
"strconv"
"unicode"
"unicode/utf8"
)
func skipSpaces(s []byte) []byte {
$ dig www.iij.ad.jp. AAAA
; <<>> DiG 9.9.5-11ubuntu1.3-Ubuntu <<>> www.iij.ad.jp. AAAA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33579
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096