This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import logging | |
import sys | |
import textwrap | |
from llama_index import ( | |
GPTKeywordTableIndex, | |
SimpleDirectoryReader, | |
LLMPredictor, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Groups (clusters) similar lines together from a text file | |
using k-means clustering algorithm. | |
Also does some simple cleaning (such as removing white space and replacing numbers with (N)). | |
Example: | |
python cluster_lines.py --clusters 20 invalid_dates.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rewritten code from /r2/r2/lib/db/_sorts.pyx | |
from math import sqrt | |
def _confidence(ups, downs): | |
n = ups + downs | |
if n == 0: | |
return 0 | |
z = 1.281551565545 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
amazon_sender.py | |
~~~~~~~~ | |
Python helper class that can send emails using Amazon SES and boto. | |
The biggest feature of this class is that encodings are handled properly. | |
It can send both text and html emails. | |
This implementation is using Python's standard library (which opens up for a lot more options). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from csv import DictWriter | |
from cStringIO import StringIO | |
from parts.util.encoding import ensure_str | |
from twist.init import init_twist | |
init_twist(EXPOSE_MODULES=False) | |
from twist.models.database import main_db, close_current_connections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Start video conversations from Twist by just typing `/appear room-name` | |
""" | |
from flask import Flask | |
from flask import jsonify | |
from flask import request | |
app = Flask(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "Growth numbers for April 2017", | |
"content": "Hi team,\nThese are our growth numbers for **April 2017**...", | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Rewritten code from /r2/r2/lib/db/_sorts.pyx | |
from math import sqrt | |
def _confidence(ups, downs): | |
n = ups + downs | |
if n == 0: | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript that solves http://regex.alf.nu/ | |
// Run in Chrome or Firefox console | |
// Enjoy ;-) | |
// Some people, when confronted with a problem, think | |
// “I know, I'll use regular expressions.” | |
// Now they have two problems. | |
for(var lvl in levels) { | |
var fn = function(lvl) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript that solves http://regex.alf.nu/ | |
// Run in Chrome or Firefox console | |
// Enjoy ;-) | |
// Some people, when confronted with a problem, think | |
// “I know, I'll use regular expressions.” | |
// Now they have two problems. | |
for(var lvl in levels) { | |
var fn = function(lvl) { |
NewerOlder