Skip to content

Instantly share code, notes, and snippets.

View m-vdb's full-sized avatar

Maxime Vdb m-vdb

  • Rasa
  • Berlin
View GitHub Profile
@m-vdb
m-vdb / mongo_dbref_migration.js
Last active April 8, 2022 19:41
A quick example to migrate DBRef's to ObjectId's directly in MongoDB shell.
/*
A quick example to migrate DBRef's to ObjectId's directly in MongoDB shell.
Suppose we have 2 collections:
- db.authors
- db.books, with books like {title: "My book", writer: DBRef("authors", ObjectId("anyID"))}
*/
@m-vdb
m-vdb / strategy_ads_url_migration.log
Created February 23, 2017 22:13
strategy_ads_url_migration.log
Updating strategy 5899d86cbaeb406652862ec3, Facebook campaign 6069469346641
12 ads to process.
Updating strategy 56e694ee539cc0432800158b, Facebook campaign 6045272103641
5 ads to process.
Updating strategy 5728b3564a6e5d6b340d286c, Facebook campaign 6048874836441
9 ads to process.
Updating strategy 576a66207f70ff4157416453, Facebook campaign 6055105248841
11 ads to process.
Updating strategy 576a81194a6e5d68aa1a4987, Facebook campaign 6055071385441
18 ads to process.
@m-vdb
m-vdb / original.raven.js
Created August 17, 2016 23:36
Cloudflare minification error
/*! Raven.js 3.4.1 (380d7d0) | github.com/getsentry/raven-js */
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Raven=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;d.length>g;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a,b,c,d){return JSON.stringify(a,e(b,d),c)}function e(a,b){var c=[],d=[];return null==b&&(b=function(a,b){return c[0]===b?"[Circular ~]":"[Circular ~."+d.slice(0,c.indexOf(b)).join(".")+"]"}),funct
@m-vdb
m-vdb / french_dep_coords.py
Created January 29, 2014 10:34
Retrieve the french department coordinates using wikipedia and google geolocation API.
from collections import OrderedDict
from itertools import tee
import time
from xml.etree import ElementTree as ET
from pygeocoder import Geocoder
import requests
wiki_url = u"http://fr.wikipedia.org/wiki/Liste_des_pr%C3%A9fectures_de_France"
{"version":3,"file":"job_pipe/static/js/interface_app/build.min.js","sources":["job_pipe/static/js/interface_app/build.js"],"names":["e","t","n","r","s","o","u","a","require","i","Error","f","exports","call","length",1,"Pipe","ExporterCollection","PipeCollection","ScrapedItemCollection","spiders","Router","window","Interface","eventAggregator","_","extend","Backbone","Events","initialize","this","on","domChangeTitle","loadedDashboard","toastr","options","positionClass","exporterCollection","pipeCollection","scrapedItemCollection","spiderCollection","SpiderCollection","processorCollection","ProcessorCollection","validatorCollection","ValidatorCollection","reset","exportersJSON","pipeList","sortPipeList","fetch","router","history","start","pushState","bindAll","setDefaultsForPipe","default_exporter","where","name","prototype","defaults","exporters","exporter","title","document","info","message","ms","timeOut","success","dashboard","fadeOut","error","redirect","onHidden","back","$","evt","href","attr","protocol"
@m-vdb
m-vdb / paramForm.js
Created June 4, 2013 15:37
Param form (Backbone.Form)
var ParamForm = window.Interface.BaseForm.extend({
initialize: function(options){
options.schema = {
client_name: {type: 'Text', title: 'Client Name', validators: ['required'], editorClass: 'client_name'},
name: {type: 'Text', title: 'Short Name', editorClass: 'name', fieldClass: 'hidden'},
urls: {type: 'List', title: 'Source urls', validators: ['url']},
exporters: {type: 'List', title: 'Facebook Pages', itemType: 'InlineObject', validators: [this.validateListExporter],
subSchema: {
name: {type: 'Text', title: 'Name', validators: ['required']},
exporter: {type: 'Exporter', title: 'Type',
@m-vdb
m-vdb / script.sql
Created October 26, 2015 21:03
Rename job:apply:success events to job:apply:tentative
BEGIN;
LOCK events;
UPDATE events SET type = 'job:apply:tentative' WHERE type = 'job:apply:success' and date >= '2015-09-01';
END;
@m-vdb
m-vdb / backbone-forms-ListKeyValue.css
Created December 14, 2012 08:08
backbone-forms-ListKeyValue.css
.bbf-field .bbf-keyvalue-editor input {
width: 45%;
}
@m-vdb
m-vdb / backbone-forms-ListKeyValue-Editors.js
Created December 13, 2012 14:07
Backbone.Forms editors for List accepting objects, and rendering them as key-value pairs
/*
Currently, the Object ItemType is not supported.
*/
var Form = Backbone.Form,
editors = Form.editors;
Form.setTemplates({
listKeyValueItem: '\
<li>\
@m-vdb
m-vdb / backbone-forms-validators.js
Created December 11, 2012 12:58
Backbone forms validator
(function(){
var validators = Backbone.Form.validators;
//a validator verifying if an element is not in a given list
validators.errMessages.notInList = 'Must not be in list {{list}}';
validators.notInList = function(options) {
if (!options.list) throw new Error('Missing required "list" options for "notInList" validator');
options = _.extend({
type: 'notInList',