Skip to content

Instantly share code, notes, and snippets.

@ameerkat
ameerkat / SendScreencap
Created March 16, 2015 05:31
Send yourself a text and screenshot url. Useful for monitoring a long pending build/deploy operation.
import tempfile, uuid, pyscreenshot
from twilio.rest import TwilioRestClient
from azure.storage import BlobService
# Your Account Sid and Auth Token from twilio.com/user/account
twilio_account_sid = ""
twilio_auth_token = ""
client = TwilioRestClient(twilio_account_sid, twilio_auth_token)
# Screencap
def missing_number(s_final):
for starting_length in range(1, (len(s_final)/2) + 1):
s = s_final[:] # copy
skipped = -1
starting_number = int(s[:starting_length])
plus_one = starting_number + 1 # the two valid options
plus_two = starting_number + 2
s = s[starting_length:]
round_passed = True
while s and round_passed:
@ameerkat
ameerkat / MD5.cs
Created October 29, 2016 08:35
MD5 Implementation in C# based on Wikipedia psuedocode
using System;
using System.Linq;
namespace MD5
{
/// <summary>
/// RFC for MD5 https://tools.ietf.org/html/rfc1321
/// Based on the pseudo code from Wikipedia: https://en.wikipedia.org/wiki/MD5
/// </summary>
public class MD5
@ameerkat
ameerkat / app.config
Created April 7, 2017 07:28
Simple log4net format for console logging
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
@ameerkat
ameerkat / score.py
Created March 10, 2018 02:44
Calculate the object by object mIOU for the 2018 Data Science Bowl
# score.py
import os
import settings
from tqdm import tqdm
from skimage.io import imread
import numpy as np
import metrics
from keras.models import Model, load_model
from skimage.morphology import label
from skimage.transform import resize
# Adapted from https://www.osrsbox.com/blog/2019/03/18/watercooler-scraping-an-entire-subreddit-2007scape/
import requests
import json
import re
import time
import os
SUBREDDIT = "movies"
PUSHSHIFT_REDDIT_URL = "http://api.pushshift.io/reddit"
@ameerkat
ameerkat / worldnews_fastai_classifier.ipynb
Last active April 10, 2021 17:16
fast.ai example notebook for training a classifier on reddit
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from scrapingbee import ScrapingBeeClient
import time
import logging
import json
SCRAPING_BEE_API_KEY = "RBUHWF4Y0ORC8RGXVRG07VNCBNFN3AH3083P3CHJKEF00HIFGQD2Z0BIMXD4C7AHF14S361H85NZ5TYF" # replace with your API key
class ScrappingBeeClientWrapper:
def __init__(self, client, client_config):
self.client = client
@ameerkat
ameerkat / render-theme-block.py
Last active November 30, 2023 17:08
This is a simple python script that renders a Shopify theme app block to an HTML file. This can be useful for testing locally or just automated testing in general if you inject your test scripts to the page.
##
# Shopify App Block Loader
# This script renders block liquid files to HTML, allowing you to load them
# up and view them locally in isolation. This allows you to load them up for
# testing and to see how they operate. For example we have a complex javascript
# that runs and we need to see how it interacts with a complete page. This is
# a rough approximation of what is necessary for shopify. Does not include out
# of block scope elements but does include the wrapping block div. Note this
# does not render an entire product page. It only renders the block itself.
##