Skip to content

Instantly share code, notes, and snippets.

View mjrusso's full-sized avatar

Michael Russo mjrusso

View GitHub Profile
@mjrusso
mjrusso / instructor-with-langchain-demo.livemd
Created March 8, 2024 19:53
Livebook demonstrating the use of Instructor with LangChain

Instructor+LangChain Demo

Mix.install(
  [
    {:instructor, "~> 0.0.5"},
    {:langchain, "~> 0.1.0"},
    {:kino, "~> 0.12.0"}
@mjrusso
mjrusso / liveviewgame.exs
Created December 22, 2022 14:45
A toy LiveView "game" example, using LiveView (as a single-file Phoenix app)
# A toy LiveView "game" example.
#
# Player locations are synchronized across all LiveView processes (browser
# tabs) using PubSub.
#
# Each player is represented by a symbol (e.g. '#'), and '.' characters
# represent open space on the grid.
#
# Use the arrow keys to move. There are no victory conditions -- you can simply
# move around.
@mjrusso
mjrusso / ViewController.swift
Created April 15, 2020 00:01
iPadOS 13.4: ImageCaptureCore's ICCameraFile `requestReadData(atOffset:length:completion:)` always passes empty Data object to completion block
import UIKit
import ImageCaptureCore
import MobileCoreServices
class ViewController: UIViewController {
var deviceFinder = DeviceFinder()
override func viewDidLoad() {
super.viewDidLoad()
### Keybase proof
I hereby claim:
* I am mjrusso on github.
* I am mjrusso (https://keybase.io/mjrusso) on keybase.
* I have a public key whose fingerprint is C64C 76BF 297F 6C1F DEC8 76D5 B3EF 65A8 D05F 2580
To claim this, I am signing this object:
@mjrusso
mjrusso / daily-events-aggregate.hql
Created January 18, 2012 22:43
Measuring User Retention with Hadoop and Hive
select
eventsAggregate.publicationId,
eventsAggregate.userId,
eventsAggregate.deviceModel,
eventsAggregate.eventType,
eventsAggregate.eventDate,
to_date(subs.activationTime) as activationDate,
datediff(eventsAggregate.eventDate, to_date(subs.activationTime)) as eventDay,
eventsAggregate.count
from (
@mjrusso
mjrusso / redis-transactions-demo.py
Created October 29, 2010 01:03
Redis transactions demonstration
# Redis transactions demonstration.
# See the following thread on the Redis mailing list for background:
# http://groups.google.com/group/redis-db/browse_thread/thread/8a981b3fd76f8f41
# Output is included in comments below the code.
import redis
def do(r):
r.watch('mykey1')
txn = r.pipeline()
[66/66] cxx_link: build/default/src/node_4.o build/default/src/node_buffer_4.o build/default/src/node_http_parser_4.o build/default/src/node_net2_4.o build/default/src/node_io_watcher_4.o build/default/src/node_child_process_4.o build/default/src/node_constants_4.o build/default/src/node_cares_4.o build/default/src/node_events_4.o build/default/src/node_file_4.o build/default/src/node_signal_watcher_4.o build/default/src/node_stat_watcher_4.o build/default/src/node_stdio_4.o build/default/src/node_timer_4.o build/default/src/node_script_4.o build/default/deps/c-ares/ares_expand_string_1.o build/default/deps/c-ares/ares_library_init_1.o build/default/deps/c-ares/ares_destroy_1.o build/default/deps/c-ares/ares_mkquery_1.o build/default/deps/c-ares/ares_options_1.o build/default/deps/c-ares/ares_cancel_1.o build/default/deps/c-ares/ares_parse_aaaa_reply_1.o build/default/deps/c-ares/ares_process_1.o build/default/deps/c-ares/ares_free_string_1.o build/default/deps/c-ares/ares_parse_srv_reply_1.o build/default/de
[67/67] cxx_link: build/default/src/node_4.o build/default/src/node_buffer_4.o build/default/src/node_http_parser_4.o build/default/src/node_net2_4.o build/default/src/node_io_watcher_4.o build/default/src/node_child_process_4.o build/default/src/node_constants_4.o build/default/src/node_cares_4.o build/default/src/node_events_4.o build/default/src/node_file_4.o build/default/src/node_signal_watcher_4.o build/default/src/node_stat_watcher_4.o build/default/src/node_stdio_4.o build/default/src/node_timer_4.o build/default/src/node_script_4.o build/default/src/node_crypto_4.o build/default/deps/c-ares/ares_expand_string_1.o build/default/deps/c-ares/ares_library_init_1.o build/default/deps/c-ares/ares_destroy_1.o build/default/deps/c-ares/ares_mkquery_1.o build/default/deps/c-ares/ares_options_1.o build/default/deps/c-ares/ares_cancel_1.o build/default/deps/c-ares/ares_parse_aaaa_reply_1.o build/default/deps/c-ares/ares_process_1.o build/default/deps/c-ares/ares_free_string_1.o build/default/deps/c-ares/ares_pa
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;
@mjrusso
mjrusso / sha1.js
Created March 27, 2010 20:35 — forked from jed/sha1.js
/* adapted by Jed Schmidt for use as a node.js module.
* the following node.js adapter code is MIT-licensed.
*
* Example usage:
*
* var sha1 = require("sha1.js"), hash;
*
* my_sha1 = sha1.hex( data );
* my_hmac_sha1 = sha1.hex( key, data );
*