Skip to content

Instantly share code, notes, and snippets.

@jayanthdeejay
jayanthdeejay / The Technical Interview Cheat Sheet.md
Created February 2, 2018 17:36 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
work_ids = ActiveFedora::SolrService.query('depositor_ssim:dungavjk@mail.uc.edu AND has_model_ssim:Article', fl: "id", rows: 1000)
work_ids.each do |work|
pid = work['id']
article = Article.find(pid)
article.depositor = 'konecnmc@ucmail.uc.edu'
article.edit_users = ['konecnmc@ucmail.uc.edu']
article.save
article.file_sets.each do |file|
file.depositor = 'konecnmc@ucmail.uc.edu'
file.edit_users = ['konecnmc@ucmail.uc.edu']
@jayanthdeejay
jayanthdeejay / add_work_to_col.rb
Created June 6, 2019 19:30
Add works to collection
worktype = Etd
all_specified_works = worktype.where({:resource_type => 'thesis'}) #the select is something like '{:resource_type => "thesis"}'
col = Collection.find('gps')
col.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
all_specified_works.each do |work|
if work.member_of_collections.empty?
work.member_of_collections += [col]
end
year = work.date_created[0].split("-")[0]
if not work.year.present?
irb(main):006:0> local_file = File.open('spec/fixtures/images/world.png') => #<File:spec/fixtures/images/world.png>
irb(main):007:0> local_file = Hydra::Derivatives::IoDecorator.new(local_file)
=> #<File:spec/fixtures/images/world.png>
irb(main):008:0> local_file.mime_type = 'application/foo'
=> "application/foo"
irb(main):009:0> local_file.original_name = 'world.png'
=> "world.png"
irb(main):010:0> Hydra::Works::AddFileToFileSet.call(fs, local_file, :original_file, versioning: false)
Unable to check /var/folders/9t/rygbnddx0b1ckw6tjs3m18qm0000gq/T/20160531-85153-cfleh6 for viruses because no virus scanner is defined
=> #<FileSet id: "ww72bb63r", label: nil, relative_path: nil, import_url: nil, part_of: [], resource_type: [], creator: [], contributor: [], description: [], keyword: [], rights: [], publisher: [], date_created: [], subject: [], language: [], identifier: [], based_near: [], related_url: [], bibliographic_citation: [], source: [], head: [], tail: [], depositor: "jcoyne", title: [], date_uploaded:
@jayanthdeejay
jayanthdeejay / characterization.rb
Created January 19, 2020 03:52 — forked from jcoyne/characterization.rb
Test characterization hydra pcdm goldenseal curationexperts
fs = FileSet.find('mp48sc83h')
file_name = 'tmp/uploads/mp/48/sc/83/letz_01_0020_019.tif'
service = Hydra::Works::CharacterizationService.new(fs, file_name, {})
fits_output = service.send(:extract_metadata, file_name)
terms = service.send(:parse_metadata, fits_output)
class Book < ActiveFedora::Base
include Hydra::Works::Work
end
class Page < ActiveFedora::Base
include Hydra::Works::Work
end
book = Book.new
page = Page.new
2.2.1 :003 > ActiveFedora::Noid::Service.new.mint
seed is 271030524290525531404955989783767342781
counters size is 293
@rand.rand(counters.size) is 261
counters[261] is {:value=>6300353125, :max=>6324492408}
counters[261][:value] is 6300353125
counters[261][:value] is now 6300353126
=> "vt150j25g"
2.2.1 :004 > ActiveFedora::Noid::Service.new.mint
seed is 271030524290525531404955989783767342781
@jayanthdeejay
jayanthdeejay / analytics_test.rb
Created January 19, 2020 04:01 — forked from mjgiarlo/analytics_test.rb
legato filtering out 0-result dates?
# Inspired by https://gist.github.com/3166610
require 'google/api_client'
require 'date'
API_VERSION = 'v3'
CACHED_API_FILE = "analytics-#{API_VERSION}.cache"
# Update these to match your own apps credentials
service_account_email = 'foobar@developer.gserviceaccount.com' # Email of service account
key_file = '/tmp/foobar-privatekey.p12' # File containing your private key
@jayanthdeejay
jayanthdeejay / gist:9b15dcf6803d2894dd77d8d4d5e5e05d
Created January 19, 2020 04:09 — forked from hortongn/gist:b842074c8a3cfb0a0c09c6bce4e5e80a
Find all works in a collection and update the editors for each work
c = Collection.find('d504rk335')
work_ids = []
c.member_objects.each do |member|
work_ids << member.id
end
new_edit_users = ["user1@example.com", "user2@example.com"]
def change_edit_users(work_ids, new_edit_users)
work_ids.each do |pid|
@jayanthdeejay
jayanthdeejay / digest_check.rb
Created January 19, 2020 04:17 — forked from awead/digest_check.rb
Version checksum report
# Checks the shasum of each version and current content in old production
# and compares it to those in new production.
#
# To run the report, go to the Rails console and copy-in the two classes in the file.
# Then run:
#
# > report = ChecksumReport.new
#
# The report is an array of hashes, each of which looks like:
#