Skip to content

Instantly share code, notes, and snippets.

View ziplokk1's full-sized avatar
💭
ayy lmao

Mark Sanders ziplokk1

💭
ayy lmao
View GitHub Profile
"""
Determine whether a circle is a "Perfect Circle" or not.
To use this module you need:
python3.6
PIL (https://pillow.readthedocs.io/en/4.2.x/installation.html#basic-installation)
>>> from perfect_circle import is_perfect_circle
>>> from PIL import Image
>>> image = Image.open('/some/path/to/circle.jpg')
import time
from scrapy.downloadermiddlewares.retry import RetryMiddleware
from scrapy.utils.response import response_status_message
class PauseOnStatusMiddleware(RetryMiddleware):
"""
When encountering a 503 error from amazon, pause the request for TIMEOUT seconds and retry
# -*- coding: utf-8 -*-
# Scrapy settings for ScrapyChip project
#
# For simplicity, this file contains only the most important settings by
# default. All the other settings are documented here:
#
# http://doc.scrapy.org/en/latest/topics/settings.html
#
@ziplokk1
ziplokk1 / deobfuscated.js
Created July 3, 2017 02:46
Newest revision of incapsula's obfuscated js code from whoscored.com
(function() {
function getSessionCookies() {
var cookieArray = new Array();
var cName = /^\s?incap_ses_/;
var c = document.cookie.split(";");
for (var i = 0; i < c.length; i++) {
var key = c[i].substr(0, c[i].indexOf("="));
var value = c[i].substr(c[i].indexOf("=") + 1, c[i].length);
if (cName.test(key)) {
cookieArray[cookieArray.length] = value;
@ziplokk1
ziplokk1 / incap.py
Last active August 31, 2018 11:21
"""
For use with python3.
Usage: Download and save this script in your project folder.
In the script:
from incap import IncapSession as Session
session = Session()
response = session.get('https://www.url.com')
@ziplokk1
ziplokk1 / install-schedulix-2.7.sh
Created November 29, 2016 22:38
Modified install script for schedulix2.7 for use with AWS EC2.
#!/bin/bash
#
# schedulix_install.sh
#
# ###################### NOTE #####################
# There will be an error when attempting to access mysql 'root'@'localhost'.
# To fix this issue,
# - stop mysql
# sudo /etc/init.d/mysql stop
# - start mysqld configuration
#!/bin/bash
# install instructions taken from https://renoirboulanger.com/blog/2015/04/upgrade-python-2-7-9-ubuntu-14-04-lts-making-deb-package/
# update apt
sudo apt-get update
# install build dependencies
sudo apt-get install -y gcc-multilib g++-multilib libffi-dev libffi6 libffi6-dbg python-crypto python-mox3 python-pil python-ply libssl-dev zlib1g-dev libbz2-dev libexpat1-dev libbluetooth-dev libgdbm-dev dpkg-dev quilt autotools-dev libreadline-dev libtinfo-dev libncursesw5-dev tk-dev blt-dev libssl-dev zlib1g-dev libbz2-dev libexpat1-dev libbluetooth-dev libsqlite3-dev libgpm2 mime-support netbase net-tools bzip2 python-dev
"""
This middleware will allow you to specify status codes to retry after a specified wait timeout period.
"""
import time
from scrapy.contrib.downloadermiddleware.retry import RetryMiddleware
from scrapy.utils.response import response_status_message
class PauseOnStatusMiddleware(RetryMiddleware):
@ziplokk1
ziplokk1 / install-mysql-odbc5.6.sh
Created April 6, 2016 16:07
Script to setup odbc packages and install mysql client on linux 14.04LTS.
#!/bin/bash
# RUN AS SUDO
# install instructions taken from here http://www.kaffeetalk.de/how-to-setup-and-configure-mysql-with-unixodbc-under-ubuntu-14-04/
# install and configure mysql client
sudo apt-get install mysql-client
# install odbc drivers
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.Random;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;