Skip to content

Instantly share code, notes, and snippets.

View mlr's full-sized avatar

Ronnie Miller mlr

View GitHub Profile
@mlr
mlr / word2vec.py
Last active June 19, 2023 05:23
Example of creating text embeddings using Gensim
# Prerequisite:
# Download the word2vec-google-news-300 model from Hugging Face
# https://huggingface.co/fse/word2vec-google-news-300/tree/main
# Download word2vec-google-news-300.model and word2vec-google-news-300.model.vectors.npy
# Place them in the same folder as this file.
from gensim.models import KeyedVectors
# Load the KeyedVectors model
model_path = "word2vec-google-news-300.model"
@mlr
mlr / form-fill.js
Created August 11, 2022 17:02
Starter form fill bookmarklet
javascript:
var formFill = function($) {
// Fill the form fields here
// $('#myField').val('Hello world');
};
(function(e, s) {
if(typeof jQuery != 'undefined') {
console.log('jQuery already loaded');
@mlr
mlr / PostgreSQL-README.md
Last active December 2, 2022 19:53
Start PostgreSQL mac

Sometimes restart can leave PostgreSQL not running.

tail -n 100 /usr/local/var/log/postgresql@9.6.log

FATAL: lock file "postmaster.pid" already exists HINT: Is another postmaster (PID 470) running in data directory "/usr/local/var/postgresql@9.6"?

rm /usr/local/var/postgresql@9.6/postmaster.pid
@mlr
mlr / send-game-command.sh
Created July 14, 2022 03:59
Send telnet command non-interactively
#!/usr/bin/expect
set timeout 10
set command [lindex $argv 0]
set message [lindex $argv 1]
spawn telnet 127.0.0.1 8081
expect "Connected"
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/Ronnie/.rubies/ruby-2.3.0/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
[--skip-yarn], [--no-skip-yarn] # Don't use Yarn for managing JavaScript dependencies
@mlr
mlr / Rakefile
Last active April 6, 2016 16:12
Simple S3 deploy task for middleman site
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
@mlr
mlr / .tigrc
Last active August 29, 2015 14:15
tigrc
set blame-view = date:relative author:full file-name:auto id:yes,color line-number:no,interval=5 text
set grep-view = file-name:no line-number:yes,interval=1 text
set main-view = line-number:no,interval=5 id:yes date:relative author:full commit-title:yes,graph,overflow=no
set refs-view = line-number:no id:yes date:relative author:full ref commit-title
set stash-view = line-number:no,interval=5 id:no date:relative author:full commit-title
set status-view = line-number:no,interval=5 status:short file-name
set tree-view = line-number:no,interval=5 mode author:full file-size date:relative id:yes file-name
bind generic g move-first-line
bind generic G move-last-line
@mlr
mlr / rspec_rails_cheetsheet.rb
Last active October 26, 2023 14:32 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet with expect syntax (including capybara matchers)
# Model
expect(@user).to have(1).error_on(:username) # checks whether there is an error in username
expect(@user.errors[:username]).to include("can't be blank") # check for the error message
# Rendering
expect(response).to render_template(:index)
# Redirecting
@mlr
mlr / form_builder.rb
Last active October 13, 2015 09:18
Add a "required" CSS class for inputs that are required using validates_presence_of
# Adds a required css class to the label if the field
# is required in the model using a presence validator
# You need to place this in a file that will be autoloaded
# or required manually into your project. The initializers
# folder is autoloaded, but you might already have a better
# place where you load in similar things for your project.
# Add this to your css:
#