This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery snippet for changing HTML form into JSON | |
(function ($) { | |
$.fn.serializeFormJSON = function () { | |
var o = {}; | |
var a = this.serializeArray(); | |
$.each(a, function () { | |
if (o[this.name]) { | |
if (!o[this.name].push) { o[this.name] = [o[this.name]]; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from reportlab.platypus import Paragraph,SimpleDocTemplate | |
from reportlab.lib.styles import getSampleStyleSheet | |
from reportlab.graphics.charts.piecharts import Pie | |
from reportlab.lib.colors import brown,blue | |
from reportlab.graphics.charts.legends import Legend | |
from reportlab.graphics.shapes import Drawing | |
from reportlab.lib.colors import black | |
# THIS FUNCTION CALCULATES THE PERCENTILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Graph: | |
def __init__(self): | |
self.nodes = set() | |
self.edges = defaultdict(list) | |
self.distances = {} | |
def add_node(self, value): | |
self.nodes.add(value) | |
def add_edge(self, from_node, to_node, distance): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
class database(object): | |
def __init__(self): | |
self.filename = "help.db" | |
self.table = "help_data" | |
self.sql_do('create table if not exists '+self.table+' ( key TEXT,data TEXT)') | |
def sql_do(self, sql, *params): | |
self._db.execute(sql, params) | |
self._db.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import psycopg2 | |
class database(object): | |
def __init__(self,database,table): | |
self.database = database | |
self.table = table | |
self.sql_do('create table if not exists '+self.table+' ( key TEXT,data TEXT)') | |
def sql_do(self, sql, *params): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from urllib.parse import urlparse,urljoin | |
from bs4 import BeautifulSoup | |
all_urls = set() | |
class url_tree(): | |
def __init__(self, base_url,page_no=1 ,children=None): | |
self.url = base_url | |
self.page_no =page_no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gym | |
import random | |
import numpy as np | |
import tflearn | |
from tflearn.layers.core import input_data, dropout, fully_connected | |
from tflearn.data_utils import to_categorical | |
from tflearn.layers.estimator import regression | |
from statistics import median, mean | |
from collections import Counter | |
import glob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import speech_recognition as sr, pyttsx | |
from googletrans import Translator | |
# pyttsx engine config | |
speech_engine = pyttsx.init('sapi5') # see http://pyttsx.readthedocs.org/en/latest/engine.html#pyttsx.init | |
speech_engine.setProperty('rate', 150) | |
# translator object | |
translator = Translator() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Algorithmia, speech_recognition as sr, pyttsx | |
# Algorthmia Api key and end point | |
client = Algorithmia.client('simCM+BqJzKSw/iMrQsR/OTRwVE1') | |
algo = client.algo('translation/GoogleTranslate/0.1.1') | |
# pyttsx engine config | |
speech_engine = pyttsx.init('sapi5') # see http://pyttsx.readthedocs.org/en/latest/engine.html#pyttsx.init | |
speech_engine.setProperty('rate', 150) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv, random | |
class NaiveBayes(object): | |
def __init__(self, filename, split_ratio): | |
''' | |
:param filename: a csv filename with absolute or full path | |
:param split_ratio: test to train ratio | |
''' |
OlderNewer