Skip to content

Instantly share code, notes, and snippets.

@sukinull
sukinull / arduino_i2c_scanner.c
Created March 8, 2016 04:59
List connected I2C devices
// http://www.arduinoecia.com.br/2014/09/sensor-gy-80-acelerometro-bussola-barometro.html
// Read this for I2C wiring - https://www.arduino.cc/en/Reference/Wire
// --------------------------------------
// i2c_scanner
//
// Version 1
// This program (or code that looks like it)
// can be found in many places.
// For example on the Arduino.cc forum.
// The original author is not know.
// https://www.bananarobotics.com/shop/How-to-use-the-HG7881-%28L9110%29-Dual-Channel-Motor-Driver-Module
/*
HG7881_Motor_Driver_Example - Arduino sketch
This example shows how to drive a motor with using HG7881 (L9110) Dual
Channel Motor Driver Module. For simplicity, this example shows how to
drive a single motor. Both channels work the same way.
This example is meant to illustrate how to operate the motor driver
and is not intended to be elegant, efficient or useful.
@sukinull
sukinull / LGPS.c
Last active October 30, 2020 02:57
Linkit One Corrected GPS
#include <LGPS.h>
gpsSentenceInfoStruct info;
char buff[256];
char gmaps_buff[50];
static unsigned char getComma(unsigned char num,const char *str)
{
unsigned char i,j = 0;
int len=strlen(str);
@sukinull
sukinull / gist:502402038ee5add81fe3
Last active February 15, 2016 18:02
Express 4(when use app.use()) + passport-http-oauth req.url is not req.originalUrl
/**
* There is a pull request, but not merged, https://github.com/jaredhanson/passport-http-oauth/pull/10
* I think
* ,path = req.originalUrl || req.url || '';
* may solve the problem. whatever.
*/
function originalUrlHack(req, res, next) {
if (typeof (req.originalUrl) != 'undefined' && req.url != req.originalUrl)
req.url = req.originalUrl;
/*
* function: kernel_3a_stats
* input: image2d_t as read only
* output: XCamGridStat, stats results
*/
typedef struct
{
unsigned int avg_y;
@sukinull
sukinull / ImageFilter2D.cl
Created January 3, 2016 02:35
OpenCV + OpenCL, modified from OpenCL(R) Programming Guide
// Gaussian filter of image
__kernel void gaussian_filter(__read_only image2d_t srcImg,
__write_only image2d_t dstImg,
sampler_t sampler,
int width, int height)
{
// Gaussian Kernel is:
// 1 2 1
@sukinull
sukinull / fakeaudiocapturemodule.cc
Last active August 29, 2015 13:56 — forked from pstjuste/l2capsender.c
webrtc_cmd.cc - using libjingle/webrtc in console
/*
* libjingle
* Copyright 2012, Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
//
// Created by sukinull on 2/14/14.
// Copyright (c) 2014 sukinull. All rights reserved.
//
// With libuv
//
// based on nopoll_w_cb.c - https://gist.github.com/sukinull/9328010#file-nopoll_w_cb-c
// and integrated with libuv
//
//
// Created by sukinull on 2/14/14.
// Copyright (c) 2014 sukinull. All rights reserved.
//
// based on nopoll_pure.c - https://gist.github.com/sukinull/9327937#file-nopoll_pure-c
// add callback function for receive
//
#include <stdio.h>
#include <nopoll.h>
//
// Created by sukinull on 2/14/14.
// Copyright (c) 2014 sukinull. All rights reserved.
//
// Simplest websocks example using nopoll - http://www.aspl.es/nopoll/
// remark nopoll_conn_set_sock_block (session, nopoll_false); in nopoll_conn_sock_connect under OS X
// use nopoll_conn_set_sock_block to set sock non-block after connect
//
#include <stdio.h>