Skip to content

Instantly share code, notes, and snippets.

View krisleech's full-sized avatar

Kris Leech krisleech

View GitHub Profile
@krisleech
krisleech / EXAMPLE.md
Last active February 14, 2020 15:05
Inline Gemfile for learning and reporting bugs
require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'
  gem 'activerecord'
  gem 'sqlite3'
  gem 'rspec'
  gem 'pry'
end
@krisleech
krisleech / HOWTO_PUSH_TO_SPEAK_MUTE.md
Created January 11, 2020 15:03
Push to Speak, via command line

This works for all mics including webcam mics.

bin/mic-on

#!/usr/bin/env bash

# toggle webcam mic
amixer -c 1 sset Mic cap
# toggle default mic
@krisleech
krisleech / HOWTO
Created January 11, 2020 14:21
UTAXO bluetooth headphone Ubuntu
Hold power button for 5 seconds to enter pairing mode
Open Bluetooth Devices and press Search
Right click UTAXO UT-BH001 and click Pair
Right click UTAXO UT-BH001 and press Add audio sink
Set volume in PulseAudio Volume Control (pavucontrol)
@krisleech
krisleech / nothing.rb
Created November 12, 2019 10:36
differentiating nil from nothing
Nothing = Object.new
result = [1,nil,2,4,nil].find(Nothing) { |i| i == nil }
if result == Nothing
else
end
@krisleech
krisleech / CONSt.md
Created November 11, 2019 16:17
const lookup oddity
class FieldDefinition    
  def meta
    Meta.new
  end
end

class TextFieldDefinition < FieldDefinition
  class Meta
 end
@krisleech
krisleech / yahify.rb
Created October 22, 2019 13:46
Using class in shorthand map (etc.) synatx
class Yahify
def call(str)
str + 'YAH'
end
def self.to_proc
proc { |str| new.call(str) }
end
end
@krisleech
krisleech / AR_VALUE.rb
Created October 15, 2019 20:02
ActiveRecord with value object
require "bundler/inline"
gemfile(false) do
source "https://rubygems.org"
gem "rspec"
gem "pry"
gem "activerecord"
gem "sqlite3"
end
@krisleech
krisleech / pipe.rb
Created October 12, 2019 22:12
Piping in Ruby
require 'pry'
class Pipe
def self.pipe(*args)
new(args)
end
def self.[](*args)
new(args)
end
@krisleech
krisleech / izzy.md
Created October 12, 2019 21:48
Izzy case idea
class Izzy
  def initialize(sign, n)    
    @s = sign
    @n = n
  end

  def ===(other)
    other.send(@s, @n)
 end
@krisleech
krisleech / RUBY_DOCKERFILE.md
Created September 26, 2019 08:50
Dockerfile for Ruby application

Ruby 2.6 on Ubuntu with Bundler 2.x

# Dockerfile

FROM ubuntu

RUN apt-get update
RUN apt-get install -y build-essential wget gcc automake autoconf autogen libtool make cmake bison unzip flex libqt4-dev zlib1g zlib1g-dev libqtwebkit-dev libreadline6 libreadline-dev  libreadline6-dev libssl-dev libfontconfig1-dev chrpath mysql-client libxml2-dev libxslt1-dev libxslt-dev libmysqlclient-dev libsqlite3-dev git git-core xvfb socat libyaml-dev libgdbm-dev libncurses5-dev libffi-dev