Skip to content

Instantly share code, notes, and snippets.

View ianhenrysmith's full-sized avatar
🆒

Ian Smith ianhenrysmith

🆒
View GitHub Profile
@ianhenrysmith
ianhenrysmith / csv_splitter.rb
Created January 28, 2025 18:18
ruby utility class for splitting a large CSV into several smaller ones (default size: 100k rows)
require 'csv'
require 'fileutils'
require 'optparse'
# example usage: ruby csv_splitter.rb ~/Downloads/accountant_sales_readiness_and_gusto_pro_jan28.csv
# with options
# ruby csv_splitter.rb -c 50000 -o output_folder <filename.csv>
def split_csv(input_file:, output_dir:, chunk_size: 100_000, keep_headers: true)
Works with other engineers and Product to formulate project goals and feature specifications.
Strong user knowledge of infrastructure tooling (CI, deployment, monitoring).
Asks for help at appropriate points when stuck.
Active participation in PR reviews.
Create well-written, comprehensive tests.
Domain expert with respect to applications / systems owned.
Play key role in developing product roadmaps.
Has deep understanding of customer & business needs.
Make considered decisions when and how to integrate third party libraries and systems.
Proactively communicates with stakeholders about issues affecting personal delivery of project.
require "faraday"
require "byebug"
require "json"
require "nokogiri"
require "open-uri"
class ImagePopulator
# class to wrap the API for Match Reverse Image Search
# https://github.com/cleargraphinc/match
{
"mainFilters" => [
{
"label" => "dropdown",
"value" => "custom_field_54d0020d67e6e25bab00000d",
"showAdvanced" => true,
"availableOptions" => ["54d0020d67e6e25bab00000a", "54d0020d67e6e25bab00000b"]
}, {
"label" => "Industry",
"value" => "custom_field_558ad76667e6e23ca4000001",
{
"mainFilters" => [
{
"label" => "dropdown",
"value" => "custom_field_54d0020d67e6e25bab00000d",
"showAdvanced" => true,
"availableOptions" => [
{"value" => "1", "label" => "Aaa"},
{"value" => "2", "label" => "2"}
]
# mongoid query to get post counts by body type
def body_types
@body_types = PostType.all.distinct(:body_type).sort
end
def body_type_count(body_type)
post_type_ids = PostType.where(body_type: body_type).distinct(:id)
Post.where(:post_type_id.in => post_type_ids, :synced_to_gallery_date.ne => nil).count
end
@ianhenrysmith
ianhenrysmith / salesforce_data_generator.rb
Last active July 6, 2017 18:46
generate leads or contact data for salesforce testing purposes. defaults to 100 contacts. to run, just do a `ruby ./salesforce_data_generator.rb lead 10`, or with whatever args you want. make sure to do a `gem install faker` first. works in ruby 2.4
require "faker"
require "csv"
def contact_row
[
first_name,
last_name,
email,
title,
birthday
require "restforce" # Salesforce::SignedRequest needs restforce
signed_request_string = "" # get a signed request string for this
signed_request = Salesforce::SignedRequest.new(raw_request: signed_request_string)
parsed_client = signed_request.parsed_request["client"]
client = Restforce.new(
oauth_token: parsed_client["oauthToken"],
# bundle exec rake wikiseed:star_wars SUBDOMAIN=jammies COUNT=1
require 'open-uri'
require 'nokogiri'
namespace :wikiseed do
TYPE_MAPPINGS = {
wikipedia: {
category: 'Wikipedia',
url: 'https://en.wikipedia.org/wiki/Special:Random',
class Crypto
attr_reader :key, :length, :output
AZ_INT_MAPPINGS = {"a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5, "f"=>6, "g"=>7, "h"=>8, "i"=>9, "j"=>10, "k"=>11, "l"=>12, "m"=>13, "n"=>14, "o"=>15, "p"=>16, "q"=>17, "r"=>18, "s"=>19, "t"=>20, "u"=>21, "v"=>22, "w"=>23, "x"=>24, "y"=>25, "z"=>26}
def initialize(count)
@length = count
@key = generate_key
end