Skip to content

Instantly share code, notes, and snippets.

View drusepth's full-sized avatar
💭
hacking away on notebook.ai

Andrew Brown drusepth

💭
hacking away on notebook.ai
View GitHub Profile
import functools
def markov_chain(initial_word=None, heuristic_function=lambda x, y: 0):
chain_words = [initial_word]
while chain_words[-1] != None:
current_word = chain_words[-1]
# Generate a pool of potential antecedents to choose from
potential_followup_words = followup_words_for(current_word)
def content(
content_types: Rails.application.config.content_types[:all].map(&:name),
page_scoping: { user_id: self.id }
)
# @user_content ||= content_list(page_scoping: page_scoping, content_types: content_types).group_by(&:page_type)
polymorphic_content_fields = [:id, :name, :page_type, :user_id, :created_at, :updated_at, :deleted_at, :privacy]
where_conditions = page_scoping.map { |key, value| "#{key} = #{value}" }.join(' AND ') + ' AND deleted_at IS NULL'
sql = content_types.map do |page_type|
chained_query = nil
Rails.application.config.content_types[:all].each do |content_type_class|
if chained_query.nil?
chained_query = content_type_class.select(:id, :name)
else
chained_query = content_type_class.select(:id, :name).union(chained_query)
end
end
chained_query.count
require 'pry'
class MethodProfile
attr_accessor :method_reference
# Method delegates
def arity; @method_reference.arity; end
def initialize(method_reference)
@method_reference = method_reference
package scripts.tasks.train.magic;
import org.powerbot.script.Condition;
import org.powerbot.script.Random;
import org.powerbot.script.rt4.ClientContext;
import org.powerbot.script.rt4.Magic;
import scripts.Task;
import scripts.reference.items.RuneId;
import scripts.reference.towns.TownWaypoint;
import scripts.services.InventoryService;
package scripts.caches;
import org.powerbot.script.rt4.ClientContext;
import org.powerbot.script.rt4.Item;
import java.sql.Timestamp;
import java.util.Date;
public class BankCache {
java.util.Hashtable<Integer, Integer> item_quantity;
class ActiveMock
class Character
def self.new(params={})
{
first_name: ['Andrew', 'Bob', 'Carol', 'David', 'Evan', 'Fred', 'George', 'Henry', 'Isaac', 'Jacob', 'Luke'].sample,
last_name: ['Green', 'Brown', 'Blue', 'White', 'Red', 'Orange', 'Purple', 'Grey', 'Silver'].sample,
age: (1..100).to_a.sample,
role: ['Protagonist', 'Antagonist', 'Foil', 'Support'].sample,
gender: ['Male', 'Female', 'Other'].sample,
eye_color: ['Green', 'Brown', 'Blue', 'White', 'Red', 'Orange', 'Purple', 'Grey', 'Silver'].sample,
# <`lm`> if a supernatural chicken was haunting you, would that be a poultrygeist?
# <dru> `lm`: I feel like I could set up a pun generator to find words that are a maximum levenshtein distance away
# from a compound word stem (e.g. poultry --> [polter]geist)
# <dru> I have no idea how to set up the rest of the joke other than manually though
# <dru> "what do you call a [adjective related to poltergeist] [synonym for chicken | chicken] that [verb related
# to poltergeist]?"
# <dru> thanks for the inspiration bbl
# Intended joke outcome:
# Q. What do you call a supernatural chicken haunting you?
before_action do
begin
trace = ApplicationController.class_variable_get(:@@trace_reference)
rescue NameError
trace = TracePoint.new(:call) do |tp|
source_path = tp.path
if source_path.include?('/app/controllers/') || source_path.include?('/app/models/')
begin
puts [
require 'active_support/concern'
module HasChangelog
extend ActiveSupport::Concern
included do
def change_events
ContentChangeEvent.where(content_id: id, content_type: self.class.name).order(:id)
end