Skip to content

Instantly share code, notes, and snippets.

#ifndef TASKTIMER_H
#define TASKTIMER_H
#include <QTImer>
#include <QString>
class TaskB : public QTimer
{
Q_OBJECT
/*
* valueOfBcdDigits takes an array of unsigned chars that is in BCD format, and
* convert the values into and int.
*
* Inputs -> digits: An unsigned char array
* digitSize: Size of digits
* Output -> Value of the BCD digits, or -1 if the digits are invalid.
*
*/
int valueOfBcdDigits(unsigned char *digits, int digitsSize)
#include <stdio.h>
#include <stdlib.h>
#define VALUES_PER_LINE 4
#define VALUE_LINES 2
char dataSource[] = "2.315 3.164 9.121 6.148\n2.134 93.124 12.313 1.264";
int main()
{
@uranusjr
uranusjr / nally.diff
Created August 22, 2011 17:58
SVN Patch for Nally to add Option-click "Open in background"
Index: YLView.mm
===================================================================
--- YLView.mm (revision 318)
+++ YLView.mm (working copy)
@@ -685,7 +685,16 @@
{
[[YLImagePreviewer alloc] initWithURL: [NSURL URLWithString: url]];
} else
- [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: url]];
+ {
@uranusjr
uranusjr / gist:1201421
Created September 7, 2011 19:07
Verbose Python RegExp Match
pattern = re.compile(r'''
\d{4}\-\d{2}\-\d{2} # yyyy-mm-dd
\s
\d{2}:\d{2}:\d{2} # HH:mm:ss
\s
(\d{1,3}\.){3}\d{1,3} # IP
\(via\sUDP:\s\[
(\d{1,3}\.){3}\d{1,3} # UDP IP
\]:
\d+ # UDP port?
@uranusjr
uranusjr / Test.h
Created September 14, 2011 01:03
Test for qApp argument reading
#include <QObject>
#include <QCoreApplication>
#include <QStringList>
#include <QDebug>
class Test : public QObject
{
public:
Test(QObject *parent = 0) : QObject(parent)
{
@uranusjr
uranusjr / PolymorphismProblem.cpp
Created October 11, 2011 20:30
How do I delete _object properly?
class SomeClass
{
private:
int someMember;
};
class Base
{
public:
Base()
@uranusjr
uranusjr / gist:1299077
Created October 19, 2011 17:45
Simply works, Mac OS X FTW.
#include <iostream>
int main() {
const char src[] = "\xE6\xAD\xA3\xE9\xAB\x94\xE4\xB8\xAD\xE6\x96\x87";
std::cout << src << std::endl;
return 0;
}
@uranusjr
uranusjr / main.m
Created November 20, 2011 06:24
Test of Unicode character output in NSLog
//
// main.m
// test
//
// Created by uranusjr on 20/11.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
f = open('MOON PHASE - ANIME.html', 'r')
o = open('output.txt', 'w')
line = True
while line:
line = f.readline().strip()
if line == '<tr>':
line = f.readline().strip() # Date cell
try:
date = line.split('>', 2)[2].split('<', 1)[0]