Skip to content

Instantly share code, notes, and snippets.

View mehdimehdi's full-sized avatar

Mehdi Ait Oufkir mehdimehdi

View GitHub Profile
@mehdimehdi
mehdimehdi / gist:1363236
Created November 14, 2011 04:31
fire _ptq.push after 5 page views
var ptReady = ptReady || [];
ptReady.push(function(){
PT.event.bind('dom.ready', function(){
var route, c = PT.cookie.get('_ptroute');
if (c){
route = PT.serializer.jsonDecode(c);
} else {
route = [];
}
if (PT.util.indexOf(route, window.location.pathname) == -1){
@mehdimehdi
mehdimehdi / base.html
Created November 29, 2011 01:14
rewarding users for doing 10 page views with 200 points.
//Don't include it if you already have it.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.2.min.js"><\/script>')</script>
@mehdimehdi
mehdimehdi / gist:1403800
Created November 29, 2011 07:01
JS Snippet
<script type="text/javascript" charset="utf-8">
var _ptq = _ptq || [];
var _punchtab_settings = {
key: "ef256e0242a3448d8986b57e559c3cc8",
display: "tab",
position: {x:"left", y:"bottom"}
};
(function() {
var pt = document.createElement('script'); pt.type = 'text/javascript'; pt.async = true;
@mehdimehdi
mehdimehdi / gist:1435466
Created December 5, 2011 21:32
Bind function with the action of earning points
window.ptAsyncInit = function(){
var j = function(activity) {
console.log(activity);
}
PT.events.bind("earned",j);
};
@mehdimehdi
mehdimehdi / gist:1449796
Created December 9, 2011 02:09
Mongo Grou query
{
"ts": {
"$date": "2011-12-08T01:40:21Z"
},
"info": "query punchtab.$cmd ntoreturn:1 command: { group: { $reduce: function (doc, prev) {\n if (doc.points > 0) {\n prev.total_po..., ns: \"activity\", cond: { date_created: { $gte: new Date(1320715369546) }, points: { $ne: 0.0 }, user_id: { $nin: [ 26039.0, 26715.0, 44624.0, 57951.0, 61329.0, 61604.0, 84368.0, 85620.0, 86239.0, 86247.0, 86262.0, 86412.0, 100464.0, 129716.0, 142514.0 ] }, publisher_id: 7573.0 }, key: { user_id: 1.0 }, initial: { total_points_earned: 0.0, redeemable_points: 0.0 } } } reslen:108097 476ms",
"millis": 476
}
<script type="text/javascript" charset="utf-8">
var _ptq = _ptq || [];
var _punchtab_settings = {
key: "a954d62bc5f0414fdf452cdbb224b0b3",
display: "tab",
position: {x:"left", y:"bottom"}
};
(function() {
var pt = document.createElement('script'); pt.type = 'text/javascript'; pt.async = true;
@mehdimehdi
mehdimehdi / with-the-ne-0
Created December 13, 2011 07:38
test mongo
mehdi-ait-oufkirs-MacBook-Air:more_mongo_test mehdi$ cat timeop.js
var collectionName = "activity";
var startTime = new Date();
var docs = db[collectionName].find({publisher_id:17,date_created:{'$gte':new Date(2011,10,13) },points:{'$ne':0}});
docs.forEach(function(doc) {
/*print(doc);*/
});
var endTime = new Date();
hu Dec 15 07:31:00 2011 - DAMN ! worker 3 (pid: 24888) died :( trying respawn ...
Thu Dec 15 07:31:00 2011 - Respawned uWSGI worker 3 (new pid: 24918)
Thu Dec 15 07:31:00 2011 - added /home/dotcloud/current/ to pythonpath.
Thu Dec 15 07:31:00 2011 - WSGI application 1 (SCRIPT_NAME=) ready on interpreter 0x695610 pid: 24918 (default app)
Thu Dec 15 07:31:09 2011 - *** HARAKIRI ON WORKER 2 (pid: 24900) ***
Thu Dec 15 07:31:09 2011 - HARAKIRI: --- uWSGI worker 2 (pid: 24900) WAS managing request /mast/2666/registration?installation=standard since Thu Dec 15 07:31:09 2011 ---
Thu Dec 15 07:31:11 2011 - *** HARAKIRI ON WORKER 1 (pid: 24907) ***
Thu Dec 15 07:31:11 2011 - HARAKIRI: --- uWSGI worker 1 (pid: 24907) WAS managing request /api/v1/user/action?token=AAACKSNTxJiMBAFZC8mm92nTPnl9S5iOBYMWmYkVVND2q77Aq4FYwbYEmMizqai3ONeOjAMHZBAxE2zofcq6kOOLCYXBrHbZCc478l2pW7IbDbNSQc4m&key=5dec4708d3854a149d91c8f4ad02f714 since Thu Dec 15 07:31:11 2011 ---
Thu Dec 15 07:31:12 2011 - *** HARAKIRI ON WORKER 4 (pid: 24906) ***
Th
<script type="text/javascript" charset="utf-8">
var _btq = _btq || [];
var _ptq = _ptq || [];
var _punchtab_settings = {
key: "b95aab305b602f88cd6e869cb232c3d8",
display: "tab",
position: {x:"right",y:"bottom"}
};
(function() {
<script type="text/javascript" charset="utf-8">
var _ptq = _ptq || [];
var _punchtab_settings = {
key: "082337a0209b5728f81ff4b763617a9d",
display: "inline",
position: {x:"left", y:"bottom"}
};
(function() {
var pt = document.createElement('script'); pt.type = 'text/javascript'; pt.async = true;