Skip to content

Instantly share code, notes, and snippets.

@rubyconvict
rubyconvict / scanval.go
Created May 20, 2020 12:24 — forked from husobee/scanval.go
scanner valuer example
package main
import (
"database/sql"
"database/sql/driver"
"errors"
"fmt"
_ "github.com/mattn/go-sqlite3"
)
@rubyconvict
rubyconvict / set-access-point.sh
Created April 15, 2019 10:31 — forked from archy-bold/set-access-point.sh
Script to find the access points for the given network SSID and set the BSSID for that network to the MAC of the access point with the highest strength
#!/bin/bash
# Usage: ./set-access-points.sh [network SSID] [network interface id = wlan0]
# Read in the arguements
ssid=$1;
interface=$2;
# SSID is required
if [ -z "$ssid" ]; then
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@rubyconvict
rubyconvict / activity_finder.rb
Last active August 23, 2017 07:24 — forked from sqrtsanta/activity_finder.rb
Preload associations of polymorphic objects
# http://api.rubyonrails.org/classes/ActiveRecord/EagerLoadPolymorphicError.html
# https://github.com/chaps-io/public_activity/issues/297
# https://ksylvest.com/posts/2017-08-23/eager-loading-polymorphic-associations-with-ruby-on-rails
class ActivityFinder
attr_reader :activities, :user
def initialize(user)
@user = user
@activities = Activity.all.where(:user_id => user_ids).
@rubyconvict
rubyconvict / bulk_reindexer.rb
Last active February 15, 2023 21:42 — forked from VvanGemert/bulk_reindexer.rb
Asynchronous bulk reindexing module for Searchkick with Sidekiq
# https://medium.com/rubyinside/asynchronous-elasticsearch-bulk-reindexing-with-rails-searchkick-and-sidekiq-26f2f9aa8513
# https://github.com/ankane/searchkick
# 2.3.2 [unreleased]
# - Added wait option to async reindex
# Searchkick.reindex(async: {wait: true})
# This code has been ported to searchkick.
require 'sidekiq/api'
# BulkReindexer
module BulkReindexer
/**
* BEM Mixin for Sass (v3.4.0)
*
* Block / Element / Modifier
*
* Example:
*
* @include b(test) {
* background: red;
* @include e(element){