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
# 2023-11-27 MIT LICENSE | |
Here's the open source version of my ChatGPT game MonkeyIslandAmsterdam.com. | |
It's an unofficial image+text-based adventure game edition of Monkey Island in Amsterdam, my home town. | |
Please use it however you want. It'd be nice to see more ChatGPT-based games appear from this. If you get inspired by it, please link back to my X https://x.com/levelsio or this Gist so more people can do the same! | |
Send me your ChatGPT text adventure game on X, I'd love to try it! |
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
batches = Queue.new | |
Order.select(:id).find_in_batches do |batch| | |
batches << batch.map(&:id) | |
end | |
cpu_available.times do | |
Thread.new do | |
while(ids = batches.pop) | |
pid = Process.fork do | |
Sunspot.index! Order.includes(:product).find(ids) | |
end |
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
cpu_available = 5 | |
Order.includes(:products).find_in_batches do |batch| | |
batch.in_groups(cpu_available, false) do |group| | |
Process.fork do | |
Sunspot.index! group | |
end | |
end | |
Process.waitall | |
end |
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
require 'shopify_api' | |
API_KEY = 'enteryourkeyhere' | |
PASSWORD = 'enteryourpasswordhere' | |
SHOP_NAME = 'yourshopname' | |
shop_url = "https://#{API_KEY}:#{PASSWORD}@#{SHOP_NAME}.myshopify.com/admin" | |
ShopifyAPI::Base.site = shop_url | |
i = 11211316 # start with ab1234 | |
product_count = ShopifyAPI::Product.count |
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
require 'rubygems' | |
gem 'activerecord', '3.0.4' | |
gem 'activerecord-oracle_enhanced-adapter', '1.4.0' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection( :adapter => 'oracle_enhanced', :database => 'orcl', | |
:username => 'hr', :password => 'hr') | |
ActiveRecord::Base.connection.instance_eval do | |
drop_table :jobs rescue nil |
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
// Make all lines comments first | |
BufferedReader inputFile = new BufferedReader(new FileReader("input.txt")); | |
String line = null; | |
while((line=inputFile.readLine())!=null){ | |
System.out.println("comment found: " + line); | |
} | |
// Now find email addresses | |
BufferedReader inputFile = new BufferedReader(new FileReader("input.txt")); | |
String line = null; |
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
class Object | |
# call send on nested objects. | |
# example: nested_send(blog_post, 'author.name') #=> 'Bob' | |
# returns nil if any call returns nil | |
def nested_send(method_name) | |
val = self | |
method_names = method_name.split('.') | |
method_names.each do |m| | |
return nil unless val |
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
class Numeric | |
# Usage: 1234.commify # => '1,234' | |
def commify | |
self.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse | |
end | |
end |
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
<script type="text/javascript"> | |
function comma(num) { | |
var collector = new Array(); | |
var numberArray = ('' + num).split('').reverse(); | |
for(var i = 0; i < numberArray.length; i++) { | |
if(i % 3 == 0 && i != 0) collector.push(","); | |
collector.push(numberArray[i]); | |
} | |
return collector.reverse().join(''); | |
} |
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
App failed to start | |
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack.rb:17: warning: already initialized constant VERSION | |
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/plugin/loader.rb:184:in `ensure_all_registered_plugins_are_loaded!': Could not locate the following plugins: community_engine and white_list (LoadError) | |
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/plugin/loader.rb:44:in `load_plugins' | |
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:348:in `load_plugins' | |
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:163:in `process' | |
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in `send' | |
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in `run' | |
from /disk1/home/slugs/12838_f2b2289_c549/mnt/config/environment.rb:11 |
NewerOlder