Skip to content

Instantly share code, notes, and snippets.

Ken Takagiwa giwa

Block or report user

Report or block giwa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View giwa_lcdclient.py
import json
import time
from itertools import islice
import requests
door_endpoint = 'http://localhost/api/v1/word_rank'
lcd_endpoint = 'http://192.168.1.2:5000/api/lcd'
View file0.txt
import falcon
class CORSMiddleware:
def process_request(self, req, resp):
resp.set_header('Access-Control-Allow-Origin', '*')
class Todo:
def on_get(self, req, resp):
resp.status = falcon.HTTP_200
@giwa
giwa / client.c
Last active May 21, 2016
simple unix domain socket
View client.c
#include <stdio.h>
#include <sys/socket.h>
#include <sys/un.h>
int main() {
int fd;
struct sockaddr_un addr;
int ret;
char buff[8192];
struct sockaddr_un from;
View file0.txt
Which means if x = 10101001010100
^
|
|
|
First set bit from the end
View file0.txt
>>> def compare(a, b):
... """Comparison that ignores the first letter"""
... return cmp(a[1:], b[1:])
>>> names = ['Adam', 'Donald', 'John']
>>> names.sort(cmp=compare)
>>> names
['Adam', 'John', 'Donald']
View file0.txt
[
"abcdefgh",
"aefghijk",
"abcefgh"
]
@giwa
giwa / file0.txt
Last active Apr 26, 2016
Fetch PR from Github filtered by labels using PyGithub ref: http://qiita.com/giwa/items/50167309774927a5a203
View file0.txt
from github import Github
token = 'YOUR_TOKEN'
g = Github(token)
repos = ['YOUR_REPO', 'YOUR_REPO']
# You can change get_organization to get_user()
org = g.get_organization('YOUR_ORG')
View file0.go
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/go-sql-driver/mysql"
"github.com/gocraft/dbr"
)
@giwa
giwa / file0.txt
Created Apr 14, 2016
EP 26 Use Multiple Inheritance Only for Mix-in Utility Classes ref: http://qiita.com/giwa/items/a3a92b56049b84b9965a
View file0.txt
import time
class ToDictMixin:
def to_dict(self):
return self._traverse_dict(self.__dict__)
def _traverse_dict(self, instance_dict):
output = {}
for key, value in instance_dict.items():
output[key] = self._traverse(key, value)
@giwa
giwa / file0.txt
Created Apr 13, 2016
EP 25 Initialize Parent Classes with `super` ref: http://qiita.com/giwa/items/1e8bc71050a2490ce95c
View file0.txt
from pprint import pprint
class MyBaseClass:
def __init__(self, value):
self.value = value
class TimesTwo:
def __init__(self):
self.value *= 2
You can’t perform that action at this time.