Skip to content

Instantly share code, notes, and snippets.

@lamberta
lamberta / camshifting.c
Created November 11, 2009 05:18
OpenCV example for face detection with Haar and tracking with CamShift.
#include "camshifting.h"
/* Create a camshift tracked object from a region in image. */
TrackedObj* create_tracked_object (IplImage* image, CvRect* region) {
TrackedObj* obj;
//allocate memory for tracked object struct
if((obj = malloc(sizeof *obj)) != NULL) {
//create-image: size(w,h), bit depth, channels
obj->hsv = cvCreateImage(cvGetSize(image), 8, 3);
@yinyin
yinyin / endian.h
Created March 13, 2012 09:51
BSD/Linux-like <endian.h> for MacOS X
#ifndef __FINK_ENDIANDEV_PKG_ENDIAN_H__
#define __FINK_ENDIANDEV_PKG_ENDIAN_H__ 1
/** compatibility header for endian.h
* This is a simple compatibility shim to convert
* BSD/Linux endian macros to the Mac OS X equivalents.
* It is public domain.
* */
#ifndef __APPLE__
@yoggy
yoggy / SerialPort.cpp
Created August 11, 2012 10:58
SerialPort class sample using boost::asio::serial_port
#include "StdAfx.h"
#include <Setupapi.h>
#pragma comment(lib, "Setupapi.lib")
#include "SerialPort.h"
SerialPort::SerialPort(void) : end_of_line_char_('\n')
{
}
@trustin
trustin / pf.conf
Created November 15, 2012 06:52
Trustin's /etc/pf.conf for Mac OS X
# 1. Put this file to /etc/pf.conf
# 2. Install init boot scripts using IceFloor then - http://www.hanynet.com/icefloor/
# I tried to use IceFloor to configure everything but it didn't work very well.
# 3. Once done, you can confirm the rules were loaded with 'sudo pfctl -sr'
# 4. At System Preferences -> Security -> Firewall -> Firewall Options,
# check 'Block all incoming connections' to prevent annoying per-app dialogs.
set skip on lo0
set block-policy drop
@reagent
reagent / .gitignore
Created April 1, 2013 14:51
Implementation of realloc / malloc
realloc
*.o
*.dSYM
@legnaleurc
legnaleurc / telnet_client.c
Last active May 23, 2024 02:32
Simple Telnet Client
/* http://l3net.wordpress.com/2012/12/09/a-simple-telnet-client/ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <termios.h>
#include <fcntl.h>
@niksumeiko
niksumeiko / git.migrate
Last active July 19, 2024 21:32
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@asmagill
asmagill / gist:4b792359c7a01da46b2d
Last active November 19, 2021 10:14
Bash resize terminal function

I forget where I found this, so if anyone wants to claim attribution, let me know and I'll add a line here. If put into /etc/profile.d/serial-console.sh, the following will auto size a serial terminal windows size and create a function for manually adjusting later. Since I access RPIs and BBBs via the serial console, their tty names are already listed in the case statement; add others if your system is different. rsz helps when you later reconnect and minicom or screen is in a different sized window...

    rsz() {
        if [[ -t 0 && $# -eq 0 ]];then
                local IFS='[;' escape geometry x y
                echo -ne '\e7\e[r\e[999;999H\e[6n\e8'
                read -sd R escape geometry
                x=${geometry##*;} y=${geometry%%;*}
                if [[ ${COLUMNS} -eq ${x} && ${LINES} -eq ${y} ]];then

echo "${TERM} ${x}x${y}"

@kevinelliott
kevinelliott / 1-macOS-10.12-sierra-setup.md
Last active February 5, 2024 07:22
macOS 10.12 Sierra Setup

macOS 10.12 Sierra Setup

Custom recipe to get macOS 10.12 Sierra running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.11 El Capitan setup recipe and 10.10 Yosemite setup recipe. I am currently tweaking this for 10.12 Sierra and expect to refine this gist over the next few weeks.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. I generally reinstall each computer from scratch every 6 months, and I do not perform upgrades between releases.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your o

@racerxdl
racerxdl / c2write.ino
Created April 13, 2017 03:08
EFM8 C2 Write Port to Arduino
/**
Based on https://github.com/jaromir-sukuba/efm8prog/
Use his SW to program EFM8 using arduino.
This needs some work though (but it works)
**/
#define C2D 2
#define C2CK 3
#define LED 13
#define INBUSY 0x02