Skip to content

Instantly share code, notes, and snippets.

View dmolesUC's full-sized avatar

David Moles dmolesUC

View GitHub Profile
@dmolesUC
dmolesUC / IndexColumnDemo.java
Created December 19, 2017 19:12
Displaying JavaFX TableView row number in a column
View IndexColumnDemo.java
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableCell;
@dmolesUC
dmolesUC / entrypoint.sh
Created October 21, 2020 18:12
Start and terminate multiple sevices
View entrypoint.sh
# ########################################
# Start server and manager in background
/start-server.sh &
SERVER_PID=$!
/start-manager.sh &
MANAGER_PID=$!
# ########################################
@dmolesUC
dmolesUC / LICENSE.md
Last active February 2, 2022 16:56
Quick and dirty Sprockets wrapper fror https://github.com/ntkme/sass-embedded-host-ruby
View LICENSE.md

The MIT License (MIT)

Copyright © 2021 The Regents of the University of California

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@dmolesUC
dmolesUC / encoding-problems.sh
Created August 5, 2021 19:36
Grep command to locate possible Windows 1252 <-> UTF-8 encoding problems
View encoding-problems.sh
# After https://www.i18nqa.com/debug/utf8-debug.html
#
# A more sophisticated version of this would grep for suspicious sequences-of-sequences;
# if the file legit contains accented characters, this will show it as a false positive
find . -name marc.xml -exec env LANG=LC_ALL grep -Pl '(\xc2|\xc3|\xc5|\xc6|\xcb|\xe2)' {} \;
@dmolesUC
dmolesUC / escape-uris.rb
Last active November 12, 2020 22:05
Escaping URIs in Ruby
View escape-uris.rb
#!/usr/bin/env ruby
# coding: utf-8
require 'addressable'
require 'cgi'
require 'erb'
require 'uri'
# base_url = 'https://user:password !$&' + "'" + '()*+,;=@host.domain/path:?#@-.+_~/ path!$&' + "'" + '()*+,;=.cgi'
# query = 'query1.-_~ *+,;=value1.-_~ *+'
View list-all-crontabs-one-liner.sh
getent passwd | cut -f1 -d: | while read user; do crontab=$(sudo crontab -u $user -l 2>/dev/null) && echo -e "\n$user:\n$crontab"; done
@dmolesUC
dmolesUC / rake-task-monkey-patch.rb
Last active October 16, 2020 23:45
Monkey-patch Rake::Task to show all task invocations
View rake-task-monkey-patch.rb
# In your Rakefile (after Rails.application.load_tasks, in a Rails project):
module TaskExtensions
def invoke
(@logger ||= Logger.new($stderr)).tap do |logger|
logger.info("invoke #{self.name}") # note: you can also dump environment variables etc. here
end
super
end
end
@dmolesUC
dmolesUC / ruby-1.8.7-catalina.md
Created August 27, 2020 16:45
Installing Ruby 1.8.7 on macOS Catalina with Homebrew and 0penSSL 1.0
View ruby-1.8.7-catalina.md

Cf. this StackOverflow answer:

brew install rbenv/tap/openssl@1.0

rvm reinstall 1.8.7-head --with-openssl-dir='/usr/local/Cellar/openssl@1.0/1.0.2t' \
  --with-openssl-lib='/usr/local/Cellar/openssl@1.0/1.0.2t/lib' \
  --with-openssl-include=/usr/local/Cellar/openssl@1.0/1.0.2t/include

rvm use 1.8.7
@dmolesUC
dmolesUC / sqlite3-pcre.md
Last active July 9, 2020 23:41
Installing sqlite3-pcre on macOS
View sqlite3-pcre.md
  1. Decide where you're going to put the compiled library, e.g. ~/lib. We'll call this <target-dir> below.

  2. Clone ralight/sqlite3-pcre

  3. Ensure pcre is installed (brew install pcre).

  4. In the sqlite3-pcre directory, compile with:

    cc \
      -shared \

-o /sqlite3-pcre.so \

@dmolesUC
dmolesUC / seed_dump-standalone.md
Created February 12, 2020 17:42
Using the seed_dump gem with StandaloneMigrations
View seed_dump-standalone.md

The seed-dump gem generates db/seeds.rb for a Rails project from an existing database. It also works outside of Rails with standalone-migrations, but you need to jump through a couple of hoops to set up the Rake task and give it access to your model classes.

In your Gemfile:

gem 'seed_dump'