Skip to content

Instantly share code, notes, and snippets.

View boykoc's full-sized avatar

Cody Boyko boykoc

View GitHub Profile
$ nosetests --ckan --with-pylons=test-core.ini ckan ckanext
.....EE.............................../usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py:2181: SAWarning: Usage of the 'related attribute set' operation is not currently supported within the execution stage of the flush process. Results may not be consistent. Consider using alternative event listeners or connection-level operations instead.
% method)
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................../usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/sql/compile
@boykoc
boykoc / sample-error.txt
Created January 25, 2019 17:11
Example error during CKAN 2.8.2 tests locally from source install.
======================================================================
ERROR: ckanext.webpageview.tests.test_view.TestWebPageView.test_view_shown_on_resource_page
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/cody/ckan/lib/default/src/ckan/ckan/tests/helpers.py", line 389, in wrapper
return func(*args, **kwargs)
File "/home/cody/ckan/lib/default/src/ckan/ckanext/webpageview/tests/test_view.py", line 46, in test_view_shown_on_resource_page
response = app.get(url)
@boykoc
boykoc / bill_splitter.rb
Created November 10, 2017 17:23
Method to *evenly* split a bill among people.
##
# Module to split bills evenly for a group of people (i.e. splitting cost for a pizza lunch).
#
# Basic use:
# `BillSplitter.split_bill(total: 82.42, people: 11)` => "Each person should fork over 7.49!"
module BillSplitter
require 'bigdecimal'
def self.split_bill(total: 0.00, people: 1)
bd_total = BigDecimal.new(total.to_s)
@boykoc
boykoc / huffman-coding-compression.rb
Last active September 22, 2017 16:02
Implementation of basic technique for compression based on Huffman coding.
#
# This is a basic implementation of compression based on Huffman coding.
# My main source of reference to try and implement this was the Wikipedia page [1].
# Specifically the image there that explains the basic steps [2].
#
# I was initially tasked to implmenet this and was unable to at the time.
# About a week later, after doing other practice coding problems and reading some more
# docs I decided to try it again.
#
# This took a number of hours broken over 2 days. I tried to limit google searches to only
@boykoc
boykoc / n_plus_1_minus_1_setup.rb
Last active July 21, 2017 13:35
Eager loading join causing n+1-1
# Create rails app to see issue.
rails new sample
rails g scaffold Author name:string
rails g scaffold Post title:string body:text author:references
rails g scaffold Comment body:text post:references
# Update post model to add association.
has_many :comments
@boykoc
boykoc / encrypt_decrypt_script.rb
Created July 12, 2017 17:13
Ruby OpenSSL Symmetric Encryption and Decryption.
# Get the encryption classes needed. Assuming they are in the same directory.
require './symmetric_encrypt.rb'
require './symmetric_decrypt.rb'
puts "What would you like to do?"
puts "Type 'encrypt', 'decrypt' or 'exit'."
input = gets.chomp
input.downcase
if input == 'encrypt'
@boykoc
boykoc / check_weather.rb
Created February 1, 2017 15:45
Ruby script to print the weather. This is setup to run from cmd line for Ontario, Canada as the default area using Environment Canada.
module WeatherChecker
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# Setup proxy just for this.
# Modify this to work for your needs/setup. Remove if you aren't behind a proxy.
system 'export http_proxy=$https_proxy'
city_directory_url = 'https://weather.gc.ca/forecast/canada/index_e.html?id=ON'