Skip to content

Instantly share code, notes, and snippets.

@thomwolf
thomwolf / fast_speech_text_speech.py
Last active July 21, 2024 18:37
speech to text to speech
""" To use: install LLM studio (or Ollama), clone OpenVoice, run this script in the OpenVoice directory
git clone https://github.com/myshell-ai/OpenVoice
cd OpenVoice
git clone https://huggingface.co/myshell-ai/OpenVoice
cp -r OpenVoice/* .
pip install whisper pynput pyaudio
"""
from openai import OpenAI
import time

Algorithmic Trading

In Less Than 100 Lines of Python Code

Dr. Yves J. Hilpisch | The Python Quants GmbH

Online, February 2021

(short link to this Gist: http://bit.ly/algo_100_code)

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
@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/' +
@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
{% 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 %}
@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"]
@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.
@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 %}