Skip to content

Instantly share code, notes, and snippets.

Avatar

Santiago Gaviria santiago

View GitHub Profile
View leastDistance.js
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) => {
View geotiff-to-geojson.sh
#!/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 Apr 9, 2019
Basic BigQuery with Go
View BigQuery.go
package main
import (
"cloud.google.com/go/bigquery"
"context"
"fmt"
"google.golang.org/api/iterator"
"log"
"math/rand"
"os"
View al.go
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 / AesUtil.js
Created Nov 14, 2018 — forked from AndiDittrich/AesUtil.js
Node.js - AES Encryption/Decryption with AES-256-GCM using random Initialization Vector + Salt
View AesUtil.js
// 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 |
View gist:f14c96337c0e2fe2779e83a604d85d2b
<!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.
View App.js
import React, { Component } from 'react';
import Sidebar from '../Sidebar/Sidebar';
import GoogleMap from '../GoogleMaps/GoogleMap';
class App extends Component {
render() {
return (
<div>
<Sidebar />
View camera.cpp
#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;
View payment.jsx
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;