Skip to content

Instantly share code, notes, and snippets.

@hirokuma
hirokuma / gist:1087031
Created July 17, 2011 02:07
libusb-1.0 search endpoint
for(int inf = 0; inf < pConfig->bNumInterfaces; inf++) {
const libusb_interface& inter = pConfig->interface[inf];
for(int alt = 0; alt < inter.num_altsetting; alt++) {
const libusb_interface_descriptor& idesc = inter.altsetting[alt];
for(int desc = 0; desc < idesc.bNumEndpoints; desc++) {
const libusb_endpoint_descriptor& EndPnt = idesc.endpoint[desc];
assert(EndPnt.bDescriptorType == LIBUSB_DT_ENDPOINT);
if(EndPnt.bEndpointAddress & LIBUSB_ENDPOINT_IN) {
m_EndPntIn = EndPnt.bEndpointAddress;
}
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define M_HOSTNAME_NTP "ntp.nict.jp"
#define M_LOCAL_PORT (123)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
#!/bin/bash
boot=new
app=1
spi_speed=40
spi_mode=QIO
spi_size_map=6
echo "gen_misc.sh version 20150911"
//
// $ git clone https://github.com/jedisct1/libsodium
// $ cd libsodium
// $ mkdir mylib
// $ ./autogen.sh
// $ ./configure --prefix=`pwd`/mylib --disable-shared
// $ make
// $ make install
// $ cd mylib
// $ gcc -Iinclude -o tst test_chacha20.c -Llib -lsodium
@hirokuma
hirokuma / msgqueue_max.c
Created May 25, 2017 13:56
linux msgsnd() max
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <unistd.h>
@hirokuma
hirokuma / lmdb_mtest.c
Created May 27, 2017 09:58
lmdbのmtest.c
/* mtest.c - memory-mapped database tester/toy */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
@hirokuma
hirokuma / lmdb_multi_fail.c
Last active February 24, 2019 03:21
lmdb multithread open fail
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include "lmdb.h"
static void *thread_func(void *pArg)
{
int code = (int)pArg; //warningが出るが、気にしない
// キャラクタデバイスのGPIOデバイスドライバ(cdev)
#define SUCCESS 0
#define NODE_NAME "Ext_GPIO"
#define MY_BUFF_SIZE 4096
#define MAP_SIZE (0x10000)
#define MAP_BASE_ADDR (0x41200000)
#define BTN_PIO_BASE (0x00000)
#define LED_PIO_BASE (0x10000)
@hirokuma
hirokuma / clock_gettime.c
Created August 18, 2017 01:12
clock_gettime()
#include <stdio.h>
#include <time.h>
int main(void)
{
struct timespec ts;
int ret = clock_gettime(CLOCK_REALTIME, &ts);
if (ret == 0) {
printf("tv_sec=%lu, tv_nsec=%ld\n", (unsigned long)ts.tv_sec, ts.tv_nsec);
} else {