Skip to content

Instantly share code, notes, and snippets.

View nuklehed's full-sized avatar

E Thomas Carroll nuklehed

  • Pennsylvania
View GitHub Profile
@nuklehed
nuklehed / gist:0de5d0c4dc3822b36a2350c253017dcf
Last active February 28, 2020 16:16
PHP version of Mongo fuzzy search
<?php
// This is based on a fuzzy search video of a lecture by John L. Page. I am implementing
// a version for 5.8M records in Mongo for a Laravel PHP app. This is working and should
// port to laravel-mongodb using the "raw" method. Not sure if we could do the same thing
// in Eloquent but it shouldn't matter (would only make it look cleaner!)
$m = new \MongoDB\Driver\Manager('mongodb://127.0.0.1:27017');
/*-- May not be using the proper terminology but it makes sense to me :) --
* 1. Match _id's using $or conditional. This means we only want a result if one of values match.
@nuklehed
nuklehed / Game.js
Last active February 11, 2017 06:43
Sails.js/MySQL example using the sails-mysql adapter
/**
* Location: /api/models/Game.js
*
* Virtual fields:
* - sponsor: Games have a one to one relationship with Sponsors
* - guesses: Games have a one to many relationship with Guesses
*
**/
module.exports = {