Skip to content

Instantly share code, notes, and snippets.

@dsisnero
dsisnero / request_helpers.rb
Created October 12, 2023 11:37 — forked from dogweather/request_helpers.rb
Use CSS Selectors in RSpec Request Specs
def css(selector)
html.css(selector).text
end
def html
Nokogiri::HTML(response.body)
end
@dsisnero
dsisnero / Makefile
Created May 24, 2023 20:27 — forked from straight-shoota/Makefile
Makefile for Crystal + Shards
-include Makefile.local # for optional local options
DOC_SOURCE ::= src/**
BUILD_TARGET ::= bin/app
# The shards command to use
SHARDS ?= shards
# The crystal command to use
CRYSTAL ?= crystal
@dsisnero
dsisnero / neovim_eval_ruby.rb
Created November 18, 2022 00:01 — forked from mctaylorpants/neovim_eval_ruby.rb
EvalRuby plugin for Neovim
# EvalRuby: Run Ruby without leaving Neovim
#
# Usage:
# - While on a line of Ruby, or in Visual mode
# with multiple lines selected, type :EvalRuby.
#
# Installation:
# 1. Install neovim-ruby: https://github.com/neovim/neovim-ruby
#
# 2. Put this file in your plugins directory
@dsisnero
dsisnero / hawthjit.rb
Created September 15, 2022 04:23 — forked from jhawthorn/hawthjit.rb
A "MJIT Custom Compiler" JIT in ~100 lines of Ruby
# $ ruby -v
# ruby 3.2.0dev (2022-09-11T14:08:14Z master 684353fc03) [x86_64-linux]
# $ ruby --mjit=pause --mjit-wait --mjit-min-calls=5 hawthjit.rb
# 246
# 246
# 246
# 246
# attempting to compile block in <main>
# can't compile putself
# attempting to compile double
@dsisnero
dsisnero / .travis.yml
Created September 7, 2022 20:27 — forked from LukeMathWalker/.travis.yml
Travis CI - Rust setup
language: rust
cache: cargo
rust:
- stable
before_cache: |
cargo install cargo-tarpaulin
before_script:
- rustup component add rustfmt
- rustup component add clippy
- cargo install cargo-audit
@dsisnero
dsisnero / audit-on-push.yml
Created September 7, 2022 20:27 — forked from LukeMathWalker/audit.yml
GitHub Actions - Rust setup
name: Security audit
on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
#!/usr/bin/env ruby
# encoding: utf-8
# frozen_string_literal: true
require 'pry'
require 'json'
require 'rest-client'
WIKIDATA_SPARQL_URL = 'https://query.wikidata.org/sparql'
@dsisnero
dsisnero / RDF_basic.rb
Created March 10, 2022 23:34 — forked from amejiarosario/RDF_basic.rb
RDF.rb basics
#=== Real life examples ===
graph = RDF::Graph.new
# read from file
graph = RDF::Graph.load("http://datagraph.org/jhacker/foaf.nt")
# -or- from the web
graph = RDF::Graph.load("http://dbpedia.org/resource/Elvis_Presley")
graph << RDF::RDFa::Reader.open("http://www.bestbuy.com/shop/ipad+xoom+-windows")
graph.each_predicate { |s| puts s.inspect }
@dsisnero
dsisnero / ractor_worker_pool.rb
Created February 2, 2021 00:06 — forked from brandur/ractor_worker_pool.rb
Ractor worker pool
require 'kramdown'
require 'redcarpet'
require 'toml'
require 'yaml'
#
# pool
#
class WorkerPool
class Broadcaster
attr_reader :ractor
def initialize
@ractor = new_ractor
end
def new_ractor
Ractor.new { Ractor.recv rescue nil }
end
def broadcast(message)
next_ractor = new_ractor