Skip to content

Instantly share code, notes, and snippets.

@JMSwag
JMSwag / btsync.supervisor.conf
Created September 22, 2016 01:45 — forked from MartinBrugnara/btsync.supervisor.conf
Supervisor .conf for Bit Torrent Sync (btsync)
[program:btsync]
command=/usr/local/btsync/btsync --nodaemon --config /usr/local/btsync/sync.conf
user=<%= btuser %>
redirect_stderr=true
stdout_logfile=/tmp/btsync.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=3
@JMSwag
JMSwag / MongoEngineGridFS Server
Created May 16, 2016 06:36 — forked from kimenye/MongoEngineGridFS Server
Serve GridFs files from mongo engine with flask
from flask import Flask, request, redirect, url_for, make_response, abort
from mongoengine.fields import get_db
from bson import ObjectId
from gridfs import GridFS
from gridfs.errors import NoFile
from <your_app> import app
@app.route('/files/<oid>')
def serve_gridfs_file(oid):
try:
[master 4546f78] ...
1 file changed, 1 insertion(+)
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 310 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
-----> Cleaning up...
-----> Building tt from herokuish...
-----> Adding BUILD_ENV to build environment...
@JMSwag
JMSwag / Flask-Restful_S3_File_Upload.py
Created April 30, 2016 22:43 — forked from RishabhVerma/Flask-Restful_S3_File_Upload.py
Uploading a file to S3 while using Flask with Flask-Restful to create a REST API.
# -*- coding: utf-8 -*-
"""
An example flask application showing how to upload a file to S3
while creating a REST API using Flask-Restful.
Note: This method of uploading files is fine for smaller file sizes,
but uploads should be queued using something like celery for
larger ones.
"""
from cStringIO import StringIO
@JMSwag
JMSwag / btsync
Last active April 30, 2016 05:58 — forked from mendelgusmao/btsync
init.d script for btsync (based on another script built to run dropbox)
#!/bin/sh
### BEGIN INIT INFO
# Provides: btsync
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of btsync.
@JMSwag
JMSwag / selenium-screenshotting.md
Created March 29, 2016 03:15 — forked from dannguyen/selenium-screenshotting.md
Using Selenium and Python to screenshot a javascript-heavy page

Using Selenium and Python to screenshot a javascript-heavy page

As websites become more JavaScript heavy, it's harder to automate things like screenshotting for archival purposes. I've seen examples and suggestions to use PhantomJS for visual testing/archiving of websites, but have run into issues such as the non-rendering of webfonts. I've never tried out Selenium until today...and while I'm not thinking about performance implications yet, Selenium seems far more accurate than PhantomJS...which makes sense since it actually opens a real browser. And it's not too hard to script to do complex interactions: here's an [example of how to log in to Twitter, write a tweet, upload an image, and send a tweet via Selenium and DOM element selection](https://gist.github.com/dannguyen/8a6fa49253c1d6a0eb92

@app.route('/login/<provider_name>', methods=['GET', 'POST'])
@authomatic.login('g')
@requires_ssl
def login(provider_name):
if g.user is not None and g.user.is_authenticated():
return redirect(url_for('index'))
if authomatic.result:
if authomatic.result.error:
return 'Something went wrong: {0}'.format(authomatic.result.error.message)
if authomatic.result.user:
@JMSwag
JMSwag / app.py
Last active November 22, 2015 05:44
from __future__ import unicode_literals
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import (QApplication, QMainWindow,
QFileDialog, QMessageBox)
class Ui_MainWindow(object):
@JMSwag
JMSwag / bs3-login-form.html
Created October 25, 2015 16:51 — forked from bMinaise/bs3-login-form.html
Bootstrap 3 - Login Form Example From: http://bootsnipp.com
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-4">
<h1 class="text-center login-title">Sign in to continue to Bootsnipp</h1>
<div class="account-wall">
<img class="profile-img" src="https://lh5.googleusercontent.com/-b0-k99FZlyE/AAAAAAAAAAI/AAAAAAAAAAA/eu7opA4byxI/photo.jpg?sz=120"
alt="">
<form class="form-signin">
<input type="text" class="form-control" placeholder="Email" required autofocus>
<input type="password" class="form-control" placeholder="Password" required>
@JMSwag
JMSwag / singleton_scheduler.py
Created October 23, 2015 22:52 — forked from reclosedev/singleton_scheduler.py
Singleton Scheduler for celery-beat with Redis Sentinel
from os import urandom
from celery.beat import PersistentScheduler
from some_place import create_readis_connection # !
class SingletonScheduler(PersistentScheduler):
def __init__(self, *args, **kwargs):
super(SingletonScheduler, self).__init__(*args, **kwargs)