Skip to content

Instantly share code, notes, and snippets.

@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.
##
@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
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 / BoyerMooreStringSearch.py
Created October 14, 2010 17:46
Boyer Moore string search implementation in Python
# Boyer Moore String Search implementation in Python
# Ameer Ayoub <ameer.ayoub@gmail.com>
# Generate the Bad Character Skip List
def generateBadCharShift(term):
skipList = {}
for i in range(0, len(term)-1):
skipList[term[i]] = len(term)-i-1
return skipList
@ameerkat
ameerkat / worldnews_fastai_classifier.ipynb
Last active April 10, 2021 17:16
fast.ai example notebook for training a classifier on reddit
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# 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 / 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
@ameerkat
ameerkat / sorts.py
Created December 7, 2010 15:04
Various sorts implemented in Python (Insertion, Bubble, Merge, Quick, Counting)
# BunchO Sorting Algorithms
# Ameer Ayoub <ameer.ayoub@gmail.com>
# Last Modified 12/2/2010
import random
#
# Insertion Sort
#
def insertion_sort(l):
"""Given an input list, returns a sorted permutation of the list
@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>
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: