Skip to content

Instantly share code, notes, and snippets.

View mcleary's full-sized avatar

Thales Sabino mcleary

View GitHub Profile
@mcleary
mcleary / cpp-object-to-python.cpp
Created February 16, 2016 16:33
This is a code snippet that exports an existing Cpp object to python
#include <iostream>
#include <string>
#include <boost/python.hpp>
using namespace std;
using namespace boost::python;
class World
{
@mcleary
mcleary / qt-properties.cpp
Created February 23, 2016 18:57
Show how to iterate through properties declared with Q_PROPERTY macro of a QObject
#include <QApplication>
#include <QDebug>
#include <QMetaProperty>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
@mcleary
mcleary / qt-automatic-property-connection.cpp
Created February 23, 2016 18:59
This functions show how to connect to a signal defined by a QMetaProperty. This is usefull to create editor for an object without knowing the object itself.
QWidget *ProjectWidget::_createBoolTreeEntry(QObject *cloudData, QMetaProperty property)
{
auto checkbox = new QCheckBox(this);
checkbox->setChecked(property.read(cloudData).toBool());
connect(checkbox, &QCheckBox::clicked, [=](bool checked)
{
property.write(cloudData, checked);
});
@mcleary
mcleary / graph.cpp
Last active March 21, 2016 22:29
Problemas com typedef
#include "graph.h"
Node::Node(int f1, int f2)
{
field1 = f1;
field2 = f2;
next = 0;
}
Node::~Node()
@mcleary
mcleary / Timer.cpp
Last active March 27, 2024 02:42
C++ Timer using std::chrono
#include <iostream>
#include <chrono>
#include <ctime>
#include <cmath>
class Timer
{
public:
void start()
{
from multiprocessing import Pool
import math
import time
def func(param):
print 'Iniciando funcao para param=' + str(param)
k = 0.0
for i in range(0, 1000000*param):
k += math.sin(i) * math.sqrt(i) * math.pow(i, 20)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Teste de Input</title>
</head>
<body>
<input id="textinput" type="text"></input>
<input id="textoutput" type"text"></input>
</body>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
#if 0
// Assossiative operations
@mcleary
mcleary / LU.cpp
Created May 2, 2016 13:24 — forked from bergolho/LU.cpp
// Resolve um sistema linear pela substituição LU.
double* LU (double **A, double *b)
{
int i, j, k, p;
double *pivot = new double[n];
double Amax, t, m, r, Mult;
// 1 PASSO: Transformar a matriz A do problema em duas matrizes triangulares L e U.
for (i = 0; i < n; i++)
pivot[i] = i;
for (j = 0; j < n-1; j++)
@mcleary
mcleary / install-clang.sh
Created May 20, 2016 12:30
Script do download, compile and install clang
#!/bin/sh
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
cd ../..
mkdir llvm-build
cd llvm-build