Skip to content

Instantly share code, notes, and snippets.

package sequence
import scala.annotation.tailrec
import scala.util.Random
/**
* Created by Owner on 10/21/14.
*
* Problem: In an array of uniformly distributed digits from 0-9 find two sequences such that
* the first sequence and second sequence add to the same sum and that sequence 1 and sequence 2 are
@ilantoren
ilantoren / dclab_report.xsl
Created September 10, 2015 14:08
stylesheet experiment
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:template match="/data">
<xsl:element name="html">
<head>
<title>OCLC matching to CARS files</title>
<style type="text/css">
@ilantoren
ilantoren / map-region.R
Created July 20, 2021 14:21
Mongo Loves Data - Using the map-region.py code to create a map
library( reticulate)
library(ggplot2)
library( dplyr )
# As in the call-python.R script the structure remains unchanged
# A) load the python file
# B) use the function to return a data.frame
# i) name is the neighborhood name
# ii) restaurants
# iii) region_lng and region_at
@ilantoren
ilantoren / map-region.py
Last active July 21, 2021 05:53
Mongo-Loves-Data part 2 Plotting a region on a map with individual markers
from pymongo import MongoClient
import pandas as pd
def get_data( neighborhood ):
data = {}
client = MongoClient('mongodb+srv://restaurantAppUser:restaurantAppPwd@mflix.beal2.mongodb.net/test?authSource=admin&replicaSet=atlas-a7tqy4-shard-0&readPreference=primary&appname=MongoDB%20Compass&ssl=true')
restaurants = client['sample_restaurants']['restaurants']
# Sometimes all the work is in getting your data into the format your program requires
# In this example there are two queries: a) get the region coordinates for the neighborhood selected, and b) use that set of coordinates to
# find the restaurants within that region.
@ilantoren
ilantoren / restaurantsByName.js
Created July 21, 2021 07:00
Code for a Realm function to find restaurants within a given neighborhood and to extract the data for further code steps
/*
* restaurantsByNeighborhood
* @param string neighborhood
* @returns object
*/
exports = function(neighborhood){
// A simple function to create an average coordinate
// for centering the map.
@ilantoren
ilantoren / realm-function.js
Last active October 4, 2021 14:27
Revised Realm function for integration into Flutter application
/*
* restaurantsByNeighborhood
* @param string neighborhood
* @returns object
*/
exports = function(neighborhood){
// A simple function to create an average coordinate
// for centering the map.
@ilantoren
ilantoren / realm_neighborhood.dart
Last active October 7, 2021 16:09
serialization/deserialization code for the Realm JSON
import 'dart:convert';
import 'package:flutter/services.dart' show rootBundle;
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:http/http.dart' as http;
import 'package:json_annotation/json_annotation.dart';
import 'package:logging/logging.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
// RUN THIS COMMAND TO CREATE the g.dart files
@ilantoren
ilantoren / mongodb_aggregate.rs
Created November 16, 2021 08:00
Defining struct for serde
#[derive(Serialize,Deserialize, Debug)]
pub struct Restaurant {
cuisine: String,
borough: String,
name: String,
address: Address
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Address {
building: String,
@ilantoren
ilantoren / mongo_requests_a.rs
Created November 16, 2021 08:34
serde as used in Rocket
/**
For a web server objects are sent serialized into json, but a client
could create an object from the http call response
**/
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(crate = "rocket::serde")]
pub struct Restaurant {
cuisine: String,
borough: String,
name: String,
@ilantoren
ilantoren / mongo_requests_c.rs
Last active November 16, 2021 09:45
Creating and using a mongodb Client
/** This is not compiler ready
from cargo.toml:
dependencies.mongodb]
version = "2.0.0"
default-features = false
features = ["sync"]
**/
use mongodb::{bson::Bson, bson::doc, bson::Document, options::ClientOptions, options::FindOptions, sync::Client, sync::Collection};
use mongodb::options::AggregateOptions;