Skip to content

Instantly share code, notes, and snippets.

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://api.nationalcrimeagency.gov.uk/sars/submission/v1.0/schemas/sar_submission.json",
"type": "object",
"title": "SAR Submission API",
"description": "National Crime Agency Suspicious Activity Report Submission API.",
"$comment": "Schema v1.2 (based on Business Data Model v0.43).",
"additionalProperties": false,
"additionalItems": false,
"properties": {
import csv
from itertools import product
from requests import get
from time import sleep
from json import dump
from os import path, makedirs, cpu_count
from datetime import datetime
from multiprocessing import Pool
from enum import Enum
@rubcuadra
rubcuadra / chance.min.js
Last active December 3, 2020 02:11
Pedestrian Simumlation
!function(){function a(e){if(!(this instanceof a))return e||(e=null),null===e?new a:new a(e);if("function"==typeof e)return this.random=e,this;arguments.length&&(this.seed=0);for(var n=0;n<arguments.length;n++){var i=0;if("[object String]"===Object.prototype.toString.call(arguments[n]))for(var r=0;r<arguments[n].length;r++){for(var o=0,t=0;t<arguments[n].length;t++)o=arguments[n].charCodeAt(t)+(o<<6)+(o<<16)-o;i+=o}else i=arguments[n];this.seed+=(arguments.length-n)*i}return this.mt=this.mersenne_twister(this.seed),this.bimd5=this.blueimp_md5(),this.random=function(){return this.mt.random(this.seed)},this}function e(a,e){if(a=a||{},e)for(var n in e)void 0===a[n]&&(a[n]=e[n]);return a}function n(a,e){if(a)throw new RangeError(e)}function i(a){return function(){return this.natural(a)}}function r(a,e){for(var n,i=p(a),r=0,o=i.length;r<o;r++)e[n=i[r]]=a[n]||e[n]}function o(a,e){for(var n=0,i=a.length;n<i;n++)e[n]=a[n]}function t(a,e){var n=Array.isArray(a),i=e||(n?new Array(a.length):{});return n?o(a,i):r(a,i),i}
from random import randint,sample,random
from time import sleep
import os, platform
MAX_VELOCITY = 9
MAX_CARS_PER_ROAD=10 #Can change this, always < ROAD_SIZE
P_RANDOM_STOP = 0.15 #Probab Car reduces velocity randomly
MAX_ROA = 1.0 #Rate of Appearance
EMPTY_CHAR = '.'
WAIT_BETWEEN_SIMULATIONS = 1 #Seconds
//Recibe un arreglo
function buscaMayor(a){
//Para regresar
var f = 0;
var l = 0;
//Temporales
var tc = f;
var te = l;
//Iterar
for (var i = 1; i < a.length; i++) {
@rubcuadra
rubcuadra / bts.py
Created August 25, 2017 20:50
Simple getTicker for an specific book from bitso
from requests import get
class Bitso(object):
"""Bitso"""
def __init__(self, version='v3'):
super(Bitso, self).__init__()
self.api = 'https://api.bitso.com/%s'%version
'''
Valid books: btc_mxn, eth_mxn, xrp_btc, xrp_mxn, eth_btc, bch_btc
'''
@rubcuadra
rubcuadra / example.cpp
Last active August 25, 2017 20:48
Cpp endpoint, download https://github.com/rubcuadra/crow/blob/master/amalgamate/crow_all.h and rename it to crow.h, you must install g++ and boost library, if you are using a Mac you can do it with brew and after the installation you can compile it using : g++ example.cpp -std=c++11 -I/usr/local/include -L/usr/local/lib -lboost_system
#include "crow.h"
int main()
{
crow::SimpleApp app;
CROW_ROUTE(app, "/")
([]() {
return "Quick example using crow!";
});
@rubcuadra
rubcuadra / regresion.py
Created August 15, 2017 16:43
Script 15min en clase para obtener la regresión con una linea, usa la lógica de multiplicar matrices A-1*y = thetas
#Regresion lineal, solo jala con linea, implementar el solicitar un grado de polinomio
import matplotlib.pyplot as plt
import numpy as np
x = [ 500,1300,2000,3800,4000,5500,6800,7400,10000]
y = [ 1000,2000,3000,4500,5000,5100,5300,5400,6000 ]
m = len(x)
@rubcuadra
rubcuadra / blue.ino
Created July 20, 2017 17:48
Parte del script usado en Campus Party para detectar ritmo cardiaco y mandarlo por bluetooth a una app Android, de momento solo envía, la lectura de HR es en la linea 72 y ahi debería leer de un sensor
#include <CurieBLE.h>
/* */
BLEPeripheral blePeripheral; // BLE Peripheral Device (the board we're programming)
BLEService HeartRateService("180D"); // heart rate Service
BLECharacteristic HeartRateChar("2A35", // standard 16-bit characteristic UUID
BLERead | BLENotify, 2); // remote clients will be able to
// get notifications if this characteristic changes
int oldHeartRate = 0; // last heart rate reading from analog input
@rubcuadra
rubcuadra / gist:902dd8fc8fce69bf82c6a8753012614c
Last active July 11, 2017 22:57
Script para convertir los códigos postales de sepomex a JSON http://www.sepomex.gob.mx/lservicios/servicios/CodigoPostal_Exportar.aspx (Descargar como TXT pero es un CSV delimitado por '|') . Cambiar el nombre del descargado a cp.csv
import csv, json
cp = {}
with open('cp.csv', 'r') as f:
reader = csv.reader(f, delimiter='|')
prev = ""
for row in reader:
current = row[0]
if current == prev:
cp[current]["Colonias"].append( row[1] )