Skip to content

Instantly share code, notes, and snippets.

@i5on9i
i5on9i / view.py
Created January 13, 2016 06:39
Simple Django TemplateView which can support csrf variable
# coding=utf-8
from django.template.context_processors import csrf
from django.views.generic import TemplateView
class TemplateViewWithCsrf(TemplateView):
"""
This set the csrf which could be called by the Django template
"""
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
# coding=utf-8
import re
from lxml import etree
import requests
__author__ = 'namh'
package com.hbwhale.seedmoney.tabs;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
from subprocess import Popen, PIPE
# This is the exact same as running: ls -al | sort
p1 = Popen(["ls", "-al"], stdout=PIPE)
p2 = Popen(["sort"], stdin=p1.stdout, stdout=PIPE)
output = p2.communicate()[0]
####################################
def iterxlsx(sheet, startRow=0):
row = startRow
nrows = sheet.nrows
ncols = sheet.ncols
while row < nrows:
col = 0
colvals = []
while col < ncols:
//------------------------------------------------
//
// Gruntfile.js
//
//------------------------------------------------
require('load-grunt-tasks')(grunt);
grunt.initConfig({
import ipdb; ipdb.set_trace()
import requests
from pyquery import PyQuery
headers = {
'user-agent': "Mozilla/5.0 (Windows NT 6.1) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/50.0.2661.87 Safari/537.36"
}
baseUrl = "http://google.com"
// sublime project configuration file
{
"folders":
[
{
"file_exclude_patterns":
[
"*.gitignore",
@i5on9i
i5on9i / NaiveBayes.py
Created June 16, 2016 14:08
Summary: A Naive Bayes classifier Home-page: http://www.cbs.dtu.dk Author: Kasper Jensen Author-email: kasjens@cbs.dtu.dk
from math import exp, pi
class NaiveBayes:
def __init__(self):
self.labels = []
self.stat_labels = {}
self.numof_instances = 0
self.attributes = []
self.attvals = {}