Skip to content

Instantly share code, notes, and snippets.

View mmarcon's full-sized avatar
👋

Massimiliano Marcon mmarcon

👋
View GitHub Profile
@mmarcon
mmarcon / README.md
Created March 26, 2024 10:05
MongoDB Atlas Search Local Development

MongoDB Atlas Search local

This setup is loosely based on this except I removed the volumes used for data persistence as they were not needed here.

@mmarcon
mmarcon / gist:1323584
Last active December 7, 2022 17:15
iOS extend SQLite by adding functions
/*
Target: iOS, iOS5
Let's say you have a SQLite DB to index a number of files, resources, or items in general.
You want to perform a full-text search on this item. Example:
TABLE: Item
----------------------------------------------------------------------
ID | Name | Description
@mmarcon
mmarcon / CollectionUtils.java
Created September 22, 2013 14:31
Maps are not Parcelable and this is an issue in Android when they need to be passed to activities and services via Intents. The corresponding Map-like object in Android is the Bundle. Bundle is a more generic container, it doesn't enforce types via generics and isn't supported natively by JSON deserializers such as Gson. This utility class expos…
package es.cloudey.pagespeed.util;
import java.util.HashMap;
import java.util.Map;
import android.os.Bundle;
import android.os.Parcelable;
public class CollectionUtils {
public static Bundle toBundle(Map<String, ? extends Parcelable> input) {
@mmarcon
mmarcon / mongosh-fle-local-kms.js
Last active February 17, 2021 16:57
Simple mongosh script to insert a document into MongoDB with Client-side Field-level Encryption and a local KMS.
// To run this script you can start the shell with `mongosh --nodb`
// Wrap everything into a function so we don't
// affect the shell's scope
(function insertTestData() {
// Config DB and Collection names
const dbName = '<TEST_DBNAME>';
const collectionName = '<TEST_COLLNAME>';
const mongoDBConnectionString = '<MONGODB_CONNECTION_STRING>';
@mmarcon
mmarcon / mongosh-fle-gcp-kms.js
Last active February 17, 2021 16:56
Simple mongosh script to insert a document into MongoDB with Client-side Field-level Encryption and KMS in GCP.
// To run this script you can start the shell with `mongosh --nodb`
// Wrap everything into a function so we don't
// affect the shell's scope
(function insertTestData() {
// Config DB and Collection names
const dbName = '<TEST_DBNAME>';
const collectionName = '<TEST_COLLNAME>';
const mongoDBAtlasConnectionString = '<MONGODB_ATLAS_CONNECTION_STRING>';
// MongoDB Playground
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
// Make sure you are connected to enable completions and to be able to run a playground.
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
// Select the database to use.
use('mongodbVSCodePlaygroundDB');
// The drop() command destroys all data from a collection.
// Make sure you run it against proper database and collection.
@mmarcon
mmarcon / youtube-helium.js
Last active November 11, 2016 09:18
A bookmarklet to convert youtube video links into links that can be opened with Helium on macOS (http://heliumfloats.com/)
[].slice.apply(document.querySelectorAll('.yt-lockup-title a.spf-link')).forEach(l => {const h = l.getAttribute('href'); l.setAttribute('href', `helium://https://www.youtube.com${h}`)})
@mmarcon
mmarcon / MFArrayList.java
Created September 22, 2013 10:18
An extension of the ArrayList class that allows mapping and filtering similarly to Array.prototype.map and Array.prototype.filter in JavaScript.
package es.cloudey.webanalyzer.util;
import java.util.ArrayList;
import java.util.Collection;
public class MFArrayList<E> extends ArrayList<E> {
private static final long serialVersionUID = 7281673743494991943L;
public MFArrayList(){
@mmarcon
mmarcon / DateUtil.java
Last active December 23, 2015 14:58
milliseconds to pretty date in Java
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class DateUtil {
public static String getDate(long milliSeconds) {
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliSeconds);
return formatter.format(calendar.getTime());
find . -name "*.php" | while read line; do expand -t 4 $line > $line.new; mv $line.new $line; done