Skip to content

Instantly share code, notes, and snippets.

@guyellis
guyellis / removeMongoField.js
Last active November 30, 2021 23:37
How to remove a field from a collection in MongoDB
// Params:
// 1. query (filter) if you only want to remove this field from some records. {} will select any.
// 2. $unset the field(s) that you want to remove. Here I've set them to null but the value doesn't matter as it's ignored.
// 3. multi must be set to true otherwise it will only operate on the first record that it finds.
//
// Run this command in the MongoDB shell
db.<collectionName>.update( {}, {$unset: {<fieldName1>: null, <fieldName2>: null}}, {multi: true});
@ciaranmahoney
ciaranmahoney / mixpanel-page-linktracking-wordpress.php
Last active March 24, 2017 15:12
This gist inserts MixPanel link click and pageview tracking scripts into a WordPress blog. It is intended to be included in footer.php so it can track pageview and clicks for all pages. In order for this to work, you must have a Mixpanel account and have Mixpanel tags setup on your website.
<!-- MixPanel Link click tracking - track clicks for all links -->
<script type="text/javascript">// <![CDATA[
mixpanel.track_links("a", "Link Click", {
"referrer": document.referrer
});
// ]]>
</script>
<!-- MixPanel Pageview tracking -->
<?php if( is_page()) { // Sets page type to Page for all pages ?>