Skip to content

Instantly share code, notes, and snippets.

@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):
@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 / 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

@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 / 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
[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 / 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:
@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 / recover_source_code.md
Created March 18, 2017 14:59 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@JMSwag
JMSwag / onedir.patch
Created May 16, 2017 22:23 — forked from ben-willmore/onedir.patch
pyupdater onedir patch
diff --git a/pyupdater/client/updates.py b/pyupdater/client/updates.py
index f610963..547e60e 100644
--- a/pyupdater/client/updates.py
+++ b/pyupdater/client/updates.py
@@ -624,16 +624,29 @@ class AppUpdate(LibUpdate):
temp_dir = get_mac_dot_app_dir(self._current_app_dir)
self._current_app_dir = temp_dir
- app_update = os.path.join(self.update_folder, self.name)
+ #app_update = os.path.join(self.update_folder, self.name)