Skip to content

Instantly share code, notes, and snippets.

View santiago's full-sized avatar

Santiago Gaviria santiago

  • Ontoworks
  • Planet Earth
View GitHub Profile
@santiago
santiago / AesUtil.js
Created November 14, 2018 16:27 — forked from AndiDittrich/AesUtil.js
Node.js - AES Encryption/Decryption with AES-256-GCM using random Initialization Vector + Salt
// AES Encryption/Decryption with AES-256-GCM using random Initialization Vector + Salt
// ----------------------------------------------------------------------------------------
// the encrypted datablock is base64 encoded for easy data exchange.
// if you have the option to store data binary save consider to remove the encoding to reduce storage size
// ----------------------------------------------------------------------------------------
// format of encrypted data - used by this example. not an official format
//
// +--------------------+-----------------------+----------------+----------------+
// | SALT | Initialization Vector | Auth Tag | Payload |
// | Used to derive key | AES GCM XOR Init | Data Integrity | Encrypted Data |
function leastDistance(input) {
const rowDim = input[0].length
const colDim = input.length
const isValidInput = !input.find(r => r.length !== rowDim)
// Track all positions for 1 and 2s;
// the 1 will be the first element
const positions = []
input.forEach((row, i) => {
Array.from(row).forEach((s, j) => {
#!/bin/bash
#
# Requires:
# - gdal_sieve.py
# - ogr2ogr (GDAL)
# - topojson (node.js)
# Grab the relative directory for source file.
SRC_DIR=`dirname $0`
@santiago
santiago / BigQuery.go
Created April 9, 2019 15:55
Basic BigQuery with Go
package main
import (
"cloud.google.com/go/bigquery"
"context"
"fmt"
"google.golang.org/api/iterator"
"log"
"math/rand"
"os"
mux := http.NewServeMux()
mux.HandleFunc("/projects/", project.Project(session))
func Project(session *mgo.Session) func(w http.ResponseWriter, req *http.Request) {
return func(w http.ResponseWriter, req *http.Request) {
middleware.DebugLogger.Println("Inside project controller")
switch req.Method {
@santiago
santiago / createUser.sql
Created January 24, 2019 23:54
Postgres
SELECT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Set up a new password for {{ product_name }}</title>
<!--
The style block is collapsed on page load to save you some scrolling.
Postmark automatically inlines all CSS properties for maximum email client
compatibility. You can just update styles here, and Postmark does the rest.
@santiago
santiago / App.js
Last active February 22, 2018 21:12
import React, { Component } from 'react';
import Sidebar from '../Sidebar/Sidebar';
import GoogleMap from '../GoogleMaps/GoogleMap';
class App extends Component {
render() {
return (
<div>
<Sidebar />
#include <CameraC328R.h>
#include <SoftwareSerial.h>
#define LED_PIN 13
#define PAGE_SIZE 64
#define USB_BAUD 115200
#define CAMERA_BAUD 115200
SoftwareSerial mySerial(2, 3);
CameraC328R camera(&mySerial);
uint16_t pictureSizeCount = 0;
import React from 'react';
import Scroll from 'react-scroll';
export default class Component extends React.Component {
state = {showNew: false};
save = (step, card) => {
let update = {step, type: 'SET_CHECKOUT'};
if (card) {
update.payment = card;