Skip to content

Instantly share code, notes, and snippets.

View cfitz's full-sized avatar

Chris Fitzpatrick cfitz

  • Machine Games
  • Sweden
View GitHub Profile
import synonyms from './synonyms'
// Keywords that should not be stemmed
const swedishKeywords = ['senior', 'island']
const indexConfig = {
settings: {
index: {
'mapping.total_fields.limit': 2200,
number_of_shards: 1,
number_of_replicas: 2,
@cfitz
cfitz / tests
Last active March 27, 2020 07:13
-----------------------------------
Kuben Stage
( 1 worker, 1 thread, react-rails prerender on, no OJ, JEMALLOC OFF, 5 apps)
-----------------------------------
Total allocated: 24312661 bytes (249894 objects)
Total retained: 1223539 bytes (4574 objects)
allocated memory by gem
@cfitz
cfitz / e2e_test.rb
Last active January 28, 2020 20:53
# config/initializers/e2e_test.rb
# For some situations, we need to have the e2e
# test to behave different in order to speed up the tests.
# rubocop:disable Style/ClassVars
if ENV.fetch('E2E_TEST', 'false') == 'true'
require_relative '../../lib/util/az_list_controller_util'
module Util
class AzListControllerUtil
class << self
import Fq from './fq'
import { SolrQueryOptions } from '../../types/types'
import SolrParams from './solrParams'
class SolrQuery {
// Filters
fqs: Fq[]
// Query
q: string
@cfitz
cfitz / default
Created March 21, 2019 10:15
INCF ElasticSearch NGINX configuration
server {
listen 443;
server_name localhost;
ssl_certificate /etc/ssl/certs/STAR_incf_org-chained.crt;
ssl_certificate_key /etc/ssl/private/STAR_incf_org.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
@cfitz
cfitz / decrypt.py
Last active December 27, 2018 17:23
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5 as Cipher_PKCS1_v1_5
from base64 import b64decode
# uses pycryptodome (3.7.2)
file_in = open('private.pem','rb').read()
key = RSA.import_key(file_in) # import the public key
# we make our cipher
cipher = Cipher_PKCS1_v1_5.new(key)
# plugins/local/backend/model/fix_sort_names.rb
[ NameCorporateEntity, NameFamily, NamePerson, NameSoftware].each do |klass|
$stderr.puts "Updating ... #{klass}"
klass.all.each do |obj|
# get the jsonmodel
@cfitz
cfitz / gitflow-breakdown.md
Created October 31, 2017 10:14 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@cfitz
cfitz / login_test.rb
Last active September 22, 2017 22:12
example integration test using rack-cas, capybara, and minitest
# to do integration tests with rack-cas, you have to use the FakeCas middleware, which intercepts CAS redirects and
# displays a "fake CAS" login form. This form will give a token to anything, but it has to be a user that's in the
# DB for the application to log the user in.
# To set this up, add
# config/environments/test.rb :
# config.rack_cas.fake_attributes = { 'admin': { "admin": true, "cas_directory_id": "admin", "name": "admin" } }
# test/test_helper.rb:
# require 'capybara/rails'
@cfitz
cfitz / http.rb
Created May 17, 2017 10:07
Use HTTPS if post is set to 443/8443
require 'net/http'
class Net::HTTP
singleton_class.send(:alias_method, :start_orig, :start)
class << self
def start(address, *arg, &block)
opt = Hash.try_convert(arg[-1]) ? arg.pop : {}
opt[:use_ssl] = ( [ 443, 8443 ].include?(arg.first) )
arg << opt