Skip to content

Instantly share code, notes, and snippets.

View v1shwa's full-sized avatar
:octocat:
⚡️

Vishwa v1shwa

:octocat:
⚡️
View GitHub Profile
@jzempel
jzempel / application:__init__.py
Created July 29, 2012 20:37
Flask with Celery 3.0
from blueprint import example
from extensions import mail
from flask import Flask
import settings
def create_app(settings=settings):
ret_val = Flask(__name__)
ret_val.config.from_object(settings)
# initialize extensions...
@evandrix
evandrix / README.md
Created September 11, 2012 00:06
Headless web browsers

Here are a list of headless browsers that I know about:

  • [HtmlUnit][1] - Java. Custom browser engine. JavaScript support/DOM emulated. Open source.
  • [Ghost][2] - Python only. WebKit-based. Full JavaScript support. Open source.
  • [Twill][3] - Python/command line. Custom browser engine. No JavaScript. Open source.
  • [PhantomJS][4] - Command line/all platforms. WebKit-based. Full JavaScript support. Open source.
  • [Awesomium][5] - C++/.Net/all platforms. Chromium-based. Full JavaScript support. Commercial/free.
  • [SimpleBrowser][6] - .Net 4/C#. Custom browser engine. No JavaScript support. Open source.
  • [ZombieJS][7] - Node.js. Custom browser engine. JavaScript support/emulated DOM. Open source.
  • [EnvJS][8] - JavaScript via Java/Rhino. Custom browser engine. JavaScript support/emulated DOM. Open source.
@tristanwietsma
tristanwietsma / adaboost.py
Created April 30, 2013 01:13
AdaBoost Python implementation of the AdaBoost (Adaptive Boosting) classification algorithm.
from __future__ import division
from numpy import *
class AdaBoost:
def __init__(self, training_set):
self.training_set = training_set
self.N = len(self.training_set)
self.weights = ones(self.N)/self.N
self.RULES = []
@willurd
willurd / web-servers.md
Last active June 29, 2024 17:26
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@SEJeff
SEJeff / gist:5797270
Created June 17, 2013 14:24
Forcing splinter to download a file
cls.browser_prefs = {
# Silence the "Unresponsive script" dialogs
"dom.max_chrome_script_run_time": 600,
"dom.max_script_run_time": 600,
"browser.download.folderList": 2,
# We actually download CSV files from search results
# to verify the search functionality works as expected
"browser.download.dir": tempfile.mkdtemp(),
"browser.download.manager.showWhenStarting": False,
"browser.helperApps.neverAsk.saveToDisk": "text/csv,application/csv,text/plain",
@igrigorik
igrigorik / github.bash
Last active December 22, 2023 23:55
Open GitHub URL for current directory/repo...
alias gh="open \`git remote -v | grep git@github.com | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`"
@clemsos
clemsos / gensim_workflow.py
Last active February 22, 2022 11:09
How to calculate TF-IDF similarity matrix of a complete corpus with Gensim
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
This script just show the basic workflow to compute TF-IDF similarity matrix with Gensim
OUTPUT :
@samuell
samuell / luigi_time_tasks_example.py
Last active June 14, 2022 19:32
How to output the execution time of tasks in the luigi workflow system, as discussed [here](https://groups.google.com/d/msg/luigi-user/uivbf-luX9w/z0GCKKsIefoJ)
import luigi
import time
class TimeTaskMixin(object):
'''
A mixin that when added to a luigi task, will print out
the tasks execution time to standard out, when the task is
finished
'''
@luigi.Task.event_handler(luigi.Event.PROCESSING_TIME)
@merqurio
merqurio / example.py
Created October 14, 2014 08:43
Flask image file upload with Google App Engine (GAE) Blobstore Example, with Google Cloud Storage (GCS)
# Render the template for the upload form:
@app.route("/upload")
def upload():
uploadUri = blobstore.create_upload_url('/submit', gs_bucket_name=BUCKET_NAME)
return render_template('upload.html', uploadUri=uploadUri)
# Place your uploadUri in the form path (html):
'''<form action="{{ uploadUri }}" method="POST" enctype="multipart/form-data">'''
@zachradtka
zachradtka / emr.py
Last active May 17, 2020 01:06
Startup an EMR cluster
import abc
import time
import boto
from boto.emr.connection import EmrConnection
from boto.regioninfo import RegionInfo
from boto.emr.step import InstallPigStep
import luigi
from luigi.s3 import S3Target, S3PathTask