Skip to content

Instantly share code, notes, and snippets.

View mehdimehdi's full-sized avatar

Mehdi Ait Oufkir mehdimehdi

View GitHub Profile
DELETE FROM `django_session` WHERE `session_key` IN ('96ef0d60c319ede132c8de8885f63c5a', '96e4626aa69d9985867ad5514a4c00cc', '96d5188056118a99c13855a7da02d028', '96d254a4813e1fdfe9913b59e65bf85a', '96d22e236088cf93731a827a61bbf6e0', '96c63f7119e82a2ca3729d3ae76d3d51', '96b8996dcf4c192947d7f2e64d4c2476', '96aec7a2bdd47bf4c895bfb7520a9ec0', '96ad2a6caf9243abee04cb49aadbfe8f', '96a626af0581bdfa4e7ce3d26dff80f2', '96a388927a42b1261ca6e1551748ef8f', '96a054fe6ed54db4e3e82dc2a4a3e63c', '969c5830a37344727d90e7d449d5eb19', '969738a65fe61061ddef4818bf3cf73f', '969660ba7c2f1f786136cd43d75b0a87', '969292457c962a0402edaab9056e07fa', '9691309b10360be90830023588ed94c1', '9680c9ce3c8d504d7a6eb42d226d178d', '96808b78ecf93c11a33fd31a6014f5d1', '966f9c2cf56baa92a2e2e982b66d2999', '966d7b13800a9cb3af5c8aefe4d6d460', '966158f2383cd635e299098b382fc40f', '965e0191b1aaa02f19b030bcdf58bfa2', '965025517f804893cd00ddd8ae30f99b', '964afb5803fb57ed7fe5072efd62d776', '962452ea8c07b5ce6caa4ab542af443a', '9612a172041940469c7b537197493a0d',
from django.db import transaction
from django.contrib.sessions.models import Session
Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
transaction.commit_unless_managed()
<script type="text/javascript" charset="utf-8">
var _ptq = _ptq || [];
var _punchtab_settings = {
key: "<YOUR KEY>",
display: "tab",
position: {x:"left", y:"bottom"}
};
(function() {
var pt = document.createElement('script'); pt.type = 'text/javascript'; pt.async = true;
var _ptq = _ptq || []; // define or reuse the queue
// pushing a "purchase" action which will be rewarded only once in a lifetime, this needs to be trigger onload.
_ptq.push(['purchase', {ref_id: <order number>}]);
Delivered-To: mehdi.aitoufkir@gmail.com
Received: by 10.64.236.98 with SMTP id ut2csp3287972iec;
Thu, 30 Apr 2015 11:07:36 -0700 (PDT)
X-Received: by 10.236.23.42 with SMTP id u30mr4764701yhu.194.1430417256557;
Thu, 30 Apr 2015 11:07:36 -0700 (PDT)
Return-Path: <marcusmarcus@me.com>
Received: from st11p01mm-asmtp001.mac.com (st11p01mm-asmtp001.mac.com. [17.172.204.239])
by mx.google.com with ESMTPS id uu4si5103474vdc.11.2015.04.30.11.07.36
for <mehdi.aitoufkir@gmail.com>
(version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128);
Delivered-To: mehdi.aitoufkir@gmail.com
Received: by 10.64.236.98 with SMTP id ut2csp3291479iec;
Thu, 30 Apr 2015 11:13:53 -0700 (PDT)
X-Received: by 10.107.4.196 with SMTP id 187mr7446259ioe.6.1430417633051;
Thu, 30 Apr 2015 11:13:53 -0700 (PDT)
Return-Path: <pm_bounces@pm.mtasv.net>
Received: from sc-ord-mta118.mtasv.net (sc-ord-mta118.mtasv.net. [50.31.156.118])
by mx.google.com with ESMTPS id m15si1876435igt.42.2015.04.30.11.13.52
for <mehdi.aitoufkir@gmail.com>
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
@mehdimehdi
mehdimehdi / gist:898496
Created April 1, 2011 17:14
Punchtab script for hescar
<script type="text/javascript" charset="utf-8">
var is_ssl = ("https:" == document.location.protocol);
var asset_host = is_ssl ? "https://www.punchtab.com/" : "http://www.punchtab.com/";
document.write(unescape("%3Cscript src='" + asset_host + "s/js/pt.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript" charset="utf-8">
var _ptq = _ptq || [];
var reward_widget_options = {};
@mehdimehdi
mehdimehdi / blogger.js
Created April 14, 2011 23:37
How to get the latest comment.
var commentURL;
var links = document.getElementsByTagName("link");
for (var i=0; i < links.length; i++) {
var href = links[i].href;
//look for the comment feed
if (href.match(/^http:\/\/\w+.blogspot.com\/feeds\/\d+\/comments\/default$/)) {
commentURL = href;
break;
}
}
@mehdimehdi
mehdimehdi / gist:973354
Created May 15, 2011 17:41
Mongo db results command
> db.activity.find({'publisher_id':746,'user_id':2425,'points':{'$ne':0}},{'user_id':1,'points':1,'date_created':1})
{ "_id" : ObjectId("4dcd50e50db4495925000681"), "user_id" : 2425, "points" : 100, "date_created" : "Fri May 13 2011 08:40:21 GMT-0700 (PDT)" }
{ "_id" : ObjectId("4dcd50e50db4495925000682"), "user_id" : 2425, "points" : 100, "date_created" : "Fri May 13 2011 08:40:21 GMT-0700 (PDT)" }
{ "_id" : ObjectId("4dcd523f0db4495925000697"), "user_id" : 2425, "points" : 100, "date_created" : "Fri May 13 2011 08:46:07 GMT-0700 (PDT)" }
{ "_id" : ObjectId("4dce3f190db4495ba30000a0"), "user_id" : 2425, "points" : 100, "date_created" : "Sat May 14 2011 01:36:41 GMT-0700 (PDT)" }
{ "_id" : ObjectId("4dcee2fc0db4495ba30007ac"), "user_id" : 2425, "points" : 100, "date_created" : "Sat May 14 2011 13:15:56 GMT-0700 (PDT)" }
> db.activity.group({key:{'user_id':true},cond:{'publisher_id': 746},reduce:function(doc, prev) {prev.points+=doc.points;},initial:{'points': 0}})
[
{
"user_i
@mehdimehdi
mehdimehdi / gist:1068555
Created July 6, 2011 23:08
blogger comment
/* blogger comment integration */
function onBlogSpotComment(data) {
if (data && data.feed && data.feed.entry.length > 0) {
//Get the datetime
var datetime = data.feed.entry[0].published.$t.split("T");
var date = datetime[0];
var time = datetime[1];
var dateSplitted = date.split("-");
var timeSplitted = time.split(":");