Skip to content

Instantly share code, notes, and snippets.

View javagg's full-sized avatar
🌴
On vacation

javagg javagg

🌴
On vacation
View GitHub Profile
@javagg
javagg / gist:f02b4058ba757bdf2da3
Created June 17, 2014 13:08
Get Mac Address in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
@javagg
javagg / parse_connection_string
Created September 27, 2012 07:36
parse connection string
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <boost/lambda/lambda.hpp>
using namespace std;
using namespace boost::lambda;
int main()
@javagg
javagg / gist:3714006
Created September 13, 2012 12:29
transform vector<string> to char* array
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
int main() {
std::vector<std::string> symbols = {"IF1209", "IF1210"};
std::vector<const char *> chars(symbols.size());
std::for_each(symbols.begin(), symbols.end(), [](std::string& s) {
@javagg
javagg / qtdownloadfile.cpp
Created August 29, 2012 05:41
qtdownloadfile
#include <QtCore/QCoreApplication>
#include <QtNetwork>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QNetworkAccessManager manager;
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("http://www.tiexue.net")));
@javagg
javagg / sig functions
Created July 4, 2012 11:23
quantstrat signal generation
x1 <- seq(from=1, to=10, by=0.5)
x2 <- seq(from=13, to=4, by=-0.5)
x <- xts(matrix(c(x1=x1, x2=x2), ncol=2), order.by=Sys.time()+1:length(x1))
colnames(x) <- c("x1", "x2")
x$comparison <- sigComparison(label="", data=x, columns=c("x1", "x2"), relationship="gt")
x$crossover <- sigCrossover(label="", data=x, columns=c("x1", "x2"), relationship="gt")
x$threshold1 <- sigThreshold(label="", data=x, column="x1", threshold=2.3, relationship="gt", cross=T)
x$threshold2 <- sigThreshold(label="", data=x, column="x1", threshold=2.3, relationship="gt", cross=F)
x
@javagg
javagg / beerules.r
Created July 4, 2012 10:04 — forked from milktrader/beerules.r
quantstrat implementation of bumblebee rules
bee <- add.rule(
strategy = bee,
name='ruleSignal',
arguments = list(sigcol="fast.gt.up",
sigval=TRUE,
orderqty=100,
ordertype='market',
orderside='long',
osFUN='osMaxPos'),
@javagg
javagg / NSManagedObject+DeepCopying.m
Created April 16, 2012 02:15
Copy and deep copy for NSManagedObject graphs.
/*
This makes some assumptions about your code, for example that you’ve got ownership rules set up properly. If a relationship to another entity uses the cascade deletion rule, it’s considered to be owned by the receiver, and thus will be copied by -deepCopyWithZone:.
*/
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface NSManagedObject (RXCopying) <NSCopying>
-(void)setRelationshipsToObjectsByIDs:(id)objects;