Skip to content

Instantly share code, notes, and snippets.

View hackel's full-sized avatar

Ryan Hayle hackel

  • Minneapolis, USA
View GitHub Profile
@kgaughan
kgaughan / first_day.sql
Created November 13, 2012 13:34
Function to get the first day of the month. Why doesn't this already exist in MySQL?!
CREATE FUNCTION FIRST_DAY(dt DATE)
RETURNS DATE DETERMINISTIC
RETURN LAST_DAY(dt - INTERVAL 1 MONTH) + INTERVAL 1 DAY;
@chrisckchang
chrisckchang / dupe-finder.js
Last active February 16, 2017 15:11
Aggregation query to find duplicate key values
// Desired unique index:
// db.collection.ensureIndex({ firstField: 1, secondField: 1 }, { unique: true})
db.collection.aggregate([
{ $group: {
_id: { firstField: "$firstField", secondField: "$secondField" },
uniqueIds: { $addToSet: "$_id" },
count: { $sum: 1 }
}},
{ $match: {
@msurguy
msurguy / list.md
Last active January 26, 2018 15:16
List of CMSs built with Laravel (stable and in dev)