Skip to content

Instantly share code, notes, and snippets.

def get_product_from_llm(frames):
PROMPT_MESSAGES = [
{
"role": "user",
"content": [
"In 4 words or fewer, identify the main product in this advertisement. Be specific (e.g., car make and model).",
*map(lambda x: {"image": x, "resize": 350}, frames),
],
},
@JayK31
JayK31 / GEMS!
Created October 2, 2014 12:35
GEMS!
gem 'newrelic_rpm'
gem 'devise', '~> 2.2.4'
gem 'stripe'
gem "paperclip", "~> 3.5.0"
gem "httparty"
gem 'unicorn'
gem 'mail'
gem 'redis'
gem 'resque', '~> 1.25.2', :require => 'resque/server'
gem 'resque-scheduler'
def self.fetch
# fetch data from NYC openscrape
responses = HTTParty.get('http://nypd.openscrape.com/data/collisions.json.gz')
# limit the reponses to approx 700
limit_resp = responses[37000..-1]
# responses.map do |response|
limit_resp.map do |response|
traffic_incident = self.new(latitude: response[0], longitude: response[1], description: description(response))
def search
result = HTTParty.get("https://api.twitter.com/1.1/search/tweets.json",
:query => { 'q' => self.name },
:headers => {
'Authorization' => "Bearer #{ENV['TWIT']}"
})
result_body = result.body
json_result_body = JSON.parse(result_body)
statuses = json_result_body["statuses"]
texts = statuses.map { |status| status["text"]}
$(document).ready(function() {
$(".view-trips").click(function(event) {
event.preventDefault();
$.ajax({
url: "/trips/users/" + userId,
method: "GET",
dataType: "json"
}).done(function(data) {
$(".trips").empty()
$("<h3>").appendTo(".trips")
# README
# pass in this file when creating a rails project
#
# for example:
# rails _3.2.14_ new awesome_app -d postgresql -m ~/kickhash_template.rb
remove_file "README.rdoc"
create_file "README.md", "TODO"
gem_group :development, :test do
Backbone.Collection = {
fetch: function() {
var requestUrl;
if (isAFunction(this.url)) {
requestUrl = this.url();
} else {
requestUrl = this.url;
}
<script src="//http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src="//http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
@JayK31
JayK31 / backbone.js
Created May 5, 2014 15:57
backbone.js
// Backbone.js 1.1.2
// (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
(function(root, factory) {
// Set up Backbone appropriately for the environment. Start with AMD.
@JayK31
JayK31 / underscore.js
Created May 5, 2014 15:56
underscore.js
// Underscore.js 1.6.0
// http://underscorejs.org
// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
(function() {
// Baseline setup
// --------------