Skip to content

Instantly share code, notes, and snippets.

@andrewdanks
andrewdanks / cool_story_bro.py
Last active May 7, 2022 18:08
"Cool story, bro" alternatives
from itertools import product
from random import choice
# Cool story, bro. alternatives
# by @andrewdanks
# Prints all combinations iff True; prints a random sentence otherwise.
print_all_combos = False
story_adjectives = ['intriguing', 'riveting', 'gripping', 'fascinating', 'compelling', 'charming', 'dazzling']
@jdevalk
jdevalk / .htaccess
Last active November 28, 2023 20:28
These three files together form an affiliate link redirect script.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
@tkirrane
tkirrane / companion-product
Last active July 22, 2020 14:03
Add a companion product to cart page
{% comment %}
To add a companion product to the cart automatically if a primary product is in cart:
1. Create a new link list under your Navigation tab.
2. In that link list, make the first link point to companion product.
3. Copy your link list handle where indicated at line 8:
{% endcomment %}
{% assign linklist = linklists['put-your-link-list-handle-here'] %}
{% comment %}
@heyalexej
heyalexej / permissions.sh
Last active September 12, 2018 16:27
Fix WordPress File Permission
#!/bin/bash -ex
#
# configures wordpress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# script is aware of .git directories by default. edit if you need to consider
# other folders as well.
#
# you will find a log file in /tmp/ in case you fucked up.
@nikhilpi-zz
nikhilpi-zz / buzzfeedNews_spider.py
Created April 2, 2015 01:46
Scrapy Scraper for Buzzfeed
import scrapy
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.lxmlhtml import LxmlLinkExtractor
from buzzLinks.items import BuzzlinksItem
from urlparse import urlparse
# Spider
class DmozSpider(CrawlSpider):
name = "buzzfeedNews"
allowed_domains = ["buzzfeed.com"]
{% comment %}
To add a companion product to the cart automatically if a primary product is in cart:
1. Create a new link list under your Navigation tab.
2. In that link list, make the first link point to companion product.
3. Copy your link list handle where indicated at line 9
4. Set the minimum cart total required for the bonus product on line 10
{% endcomment %}
{% assign linklist = linklists['put-your-link-list-handle-here'] %}
{% assign min_total = 100 %}
@mxlje
mxlje / Rakefile
Created July 19, 2015 11:16
secrets for rake tasks
require 'yaml'
task :deploy do
# add check if file exists etc
keys = YAML::load(File.open('keys.yml'))
token = keys['token']
secret = keys['secret']
# add check for empty values etc
@heyalexej
heyalexej / subinfo.py
Created August 11, 2015 09:15
Quick, Dirty & Wonky Sub Tracker for Chris
import requests
import time
import json
headers = {'User-Agent': 'android:subgrowth:v0.1 (by /u/twelvis)'}
def getit(subreddit):
r = requests.get(
'http://www.reddit.com/r/' +
def get_headers(s, sep=': ', strip_cookie=True,strip_cl=True, strip_headers:list=[]) -> dict():
l = s.split('\n')
d = dict()
for kv in l:
if kv:
k = kv.split(sep)[0]
v = kv.split(sep)[1]
if strip_cookie and k == 'cookie': continue
if strip_cl and k == 'content-length': continue
if k in strip_headers: continue