Skip to content

Instantly share code, notes, and snippets.

@fernandoc1
fernandoc1 / list_environment_vars.cpp
Created January 31, 2019 20:36
List all environment variables
#include <cstdio>
int main(int argc, char** argv, char** envp)
{
for(char** env = envp; *env != 0; env++)
{
char* currentEnv = *env;
printf("%s\n", currentEnv);
}
return 0;
@fernandoc1
fernandoc1 / search_data.py
Created February 21, 2019 00:37
Search and sort data by ratings
#! /usr/bin/python
import csv
print ("Loading list...")
basicsFp = open('basics.tsv')
ratingsFp = open('ratings.tsv')
basicsReader = csv.reader(basicsFp, delimiter='\t')
#! /usr/bin/python
import csv
basicsFp = open('basics.tsv')
ratingsFp = open('ratings.tsv')
basicsReader = csv.reader(basicsFp, delimiter='\t')
ratingsReader = csv.reader(ratingsFp, delimiter='\t')
@fernandoc1
fernandoc1 / draw_radiant.cpp
Created March 1, 2019 15:41
Draw a radiant halo.
float directionDistance(cv::Mat& img, cv::Point center, float angle)
{
angle = (M_PI * angle) / 180;
int x0 = center.x;
int y0 = center.y;
int x1 = center.x + 1000 * cos(angle);
int y1 = center.y + 1000 * sin(angle);
//std::cout << "[" << x0 << " " << y0 << "][" << x1 << " " << y1 << "]" << std::endl;
@fernandoc1
fernandoc1 / Makefile
Created March 1, 2019 20:18
This code plays sound of shapes
all:
g++ morph_descriptor.cpp -o MorphDescriptor -lao -lopencv_core -lopencv_highgui -lopencv_imgproc
@fernandoc1
fernandoc1 / Makefile
Created April 4, 2019 21:28
Create fake 16bit raw image from PNG/JPG
all:
g++ main.cpp -o Main -lopencv_core -lopencv_highgui -lopencv_imgproc
@fernandoc1
fernandoc1 / Makefile
Created April 8, 2019 17:03
Quick code to apply Flir iron palette to images.
all:
g++ apply_flir_palette.cpp -o Main -lopencv_core -lopencv_highgui -lopencv_imgproc
@fernandoc1
fernandoc1 / python_test.cpp
Created April 23, 2019 14:29
Access std::vector in boost::python
#include <iostream>
#include <vector>
#include <memory>
#include <boost/shared_ptr.hpp>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
#include <Python.h>
template<typename T> inline std::vector<T> pyListToStdVector(const boost::python::object& iterable)
{
@fernandoc1
fernandoc1 / findUnique.cpp
Last active May 21, 2019 02:15
Exercício Eldorado
char findUnique(std::string str)
{
std::vector<int> data(256, 0);
std::vector<int> firstPos(256, -1);
for(int i = 0; i < (int)str.size(); i++)
{
int currentChar = (int)str[i];
if(data[currentChar] == 0)
{
<?php
header('Content-type: image/png');
$urlBegin = 'https://4.aerial.maps.api.here.com/maptile/2.1/maptile/d1700f0f76/hybrid.day';
$x = $_GET['x'];
$y = $_GET['y'];
$z = $_GET['z'];
$urlEnd = '/512/png8?app_id=VgTVFr1a0ft1qGcLCVJ6&app_code=LJXqQ8ErW71UsRUK3R33Ow&lg=eng&ppi=72&pview=DEF';