Skip to content

Instantly share code, notes, and snippets.

@springmeyer
springmeyer / degress2meters.js
Last active June 12, 2023 22:50
convert from long/lat to google mercator (or EPSG:4326 to EPSG:900913)
// See https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames for more details.
var degrees2meters = function(lon,lat) {
var x = lon * 20037508.34 / 180;
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
return [x, y]
}
x= -77.035974
@atinfinity
atinfinity / oclMat_custom_kernel.cpp
Last active September 14, 2023 07:26
sample code to execute custom OpenCL kernel on OpenCV 2.4.9
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/ocl/ocl.hpp>
// cl_mem構造体を参照するためにインクルード
#if defined __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
@thomasdarimont
thomasdarimont / KeycloakAdminClientExample.java
Created January 12, 2016 19:15
Some Keycloak client examples
package de.tdlabs.training.keycloak;
import static java.util.Arrays.asList;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.representations.idm.CredentialRepresentation;
@colophonemes
colophonemes / create_triggers
Last active February 17, 2024 15:15
Postgres TRIGGER to call NOTIFY with a JSON payload
CREATE TRIGGER person_notify AFTER INSERT OR UPDATE OR DELETE ON income
FOR EACH ROW EXECUTE PROCEDURE notify_trigger(
'id',
'email',
'username'
);
CREATE TRIGGER income_notify AFTER INSERT OR UPDATE OR DELETE ON income
FOR EACH ROW EXECUTE PROCEDURE notify_trigger(
'id',
@fernandoc1
fernandoc1 / CMakeLists.txt
Created January 23, 2017 15:29
GeniCam image grabbing with Pleora SDK on Ubuntu 16.04
cmake_minimum_required(VERSION 2.8.3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -g3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -fPIC")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC")
find_package(OpenCV 2.4 REQUIRED opencv_core opencv_highgui opencv_imgproc opencv_calib3d opencv_video opencv_features2d opencv_objdetect opencv_ocl)
set(PLEORA_BASE_DIR /opt/pleora/ebus_sdk/Ubuntu-14.04-x86_64/)
set(PLEORA_INCLUDE_DIR ${PLEORA_BASE_DIR}/include/)
@fernandoc1
fernandoc1 / openlayers_kml_plot.html
Created August 11, 2017 14:05
This code plots, lines, markers and loads KML files in OpenLayers.
<!DOCTYPE html>
<!-- Code from https://bootswatch.com/slate/ -->
<!-- Using OpenLayers version from https://github.com/mapgears/ol3-google-maps -->
<html ondragstart="return false;" ondrop="return false;" lang="pt" style="-webkit-user-select: none; user-select: none; cursor: default;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>KML Load test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./css/bootstrap.css" media="screen">
<link rel="stylesheet" href="./css/custom.min.css">
@fernandoc1
fernandoc1 / geo_helper.cpp
Created August 11, 2017 18:10
This code calculates intersection between arcs in the sphere surface and between arcs and a route.
#include "geo_helper.hpp"
#include <cmath>
//It assumes radius as 1.
QVector3D GeoHelper::QGeoCoordinate2QVector3D(QGeoCoordinate coord)
{
double radlat = qDegreesToRadians(coord.latitude());
double radlon = qDegreesToRadians(coord.longitude());
@asimshankar
asimshankar / README.md
Last active April 13, 2024 15:50
Training TensorFlow models in C

Training TensorFlow models in C

Python is the primary language in which TensorFlow models are typically developed and trained. TensorFlow does have bindings for other programming languages. These bindings have the low-level primitives that are required to build a more complete API, however, lack much of the higher-level API richness of the Python bindings, particularly for defining the model structure.

This gist demonstrates taking a model (a TensorFlow graph) created by a Python program and running the training loop in a C program.

The model

@fernandoc1
fernandoc1 / curl_http_get.cpp
Created December 6, 2017 21:44
This code is to perform http request that requires Digest authentication.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include <vector>
#include <chrono>
@fernandoc1
fernandoc1 / convert_to_tiff.cpp
Created May 4, 2018 20:50
This code is to convert raw data buffer acquired from Flir camera to a TIFF image, using libtiff
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <tiffio.h>
int main(int argc, char** argv)
{
if(argc < 2)