Skip to content

Instantly share code, notes, and snippets.

View Genkilabs's full-sized avatar
😸
Writing software...

Alex Genkilabs

😸
Writing software...
  • Adept Mobile
  • Colorado
View GitHub Profile
@romellem
romellem / INSTRUCTIONS.md
Last active February 27, 2024 00:51
Fix homebrew node installations - dyld: Library not loaded: /usr/local/opt/icu4c/lib/$VERSION

On my unsupported macOS (currently 10.14), whenever I brew upgrade, node breaks with the following error

$ node -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.69.dylib
  Referenced from: /usr/local/opt/node@16/bin/node
  Reason: image not found

If you ls in the /usr/local/opt/icu4c/lib/ directory, you'll see a different version, e.g. libicui18n.71.dylib or whatever.

@gene1wood
gene1wood / How-to-pass-all-headers-in-CloudFront-using-CloudFormation.md
Last active February 8, 2023 20:24
How to configure CloudFront using CloudFormation to pass all headers

How to configure CloudFront using CloudFormation to pass all headers

How can you configure a CloudFront distribution to pass all headers to the origin if the CloudFront distribution is deployed using CloudFormation? If you deploy the distribution in the AWS Web Console, you can select between None, Whitelist and All. In CloudFront it appears that you can only assert a whitelist of allowed headers. This is done in this area of a CloudFormation resource describing a CloudFront distribution

Resources:
  CloudFrontDistribution:
    Type: AWS::CloudFront::Distribution
    Properties:
      DistributionConfig:
@Genkilabs
Genkilabs / user.rb
Created November 23, 2016 20:53
Rolify: Remove all roles for a resource and enforce only one role per resource (singleton pattern)
class User < ApplicationRecord
rolify :strict => true, :before_add => :before_add_role
#Helper method to remove any existing role this user has for a resource
def remove_all_roles resource
# README: This syntax relies on changes on the following PR
# https://github.com/RolifyCommunity/rolify/pull/427
# Or include the source of this directly:
# gem 'rolify', :git => "git://github.com/Genkilabs/rolify.git"
remove_role nil, resource
@weedySeaDragon
weedySeaDragon / rake_examples.rake
Last active October 13, 2022 19:48
Rake examples - passing arguments to a rake task, calling one rake task from another, and more
# Also @see https://www.viget.com/articles/protip-passing-parameters-to-your-rake-tasks for
# examples using dependents and default values for arguments (see the updates at the end)
# Avdi Grimm's rake tutorial is really helpful. His section on FileLists:
# @see http://www.virtuouscode.com/2014/04/22/rake-part-2-file-lists/
# Rails:
# * to get access to Rails models, etc, your task must depend on the :environment task
# ex: task :my_task => :environment do ....
@tokenvolt
tokenvolt / simple_form_bootstrap3.rb
Last active November 2, 2023 11:55
Bootstrap 3 simple form initializer
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
@twalling
twalling / heroku_syslog_proxy.rb
Created February 26, 2012 04:06
Syslog proxy for Heroku log messages to make them work with Graylog2
# example message:
# 197 <158>1 2011-11-28T19:00:34+00:00 d.b948a827-37d6-431e-9323-03e8ec503a35 heroku router - - GET graylog2.org/images/screenshots/04_t.png dyno=web.1 queue=0 wait=0ms service=4ms status=200 bytes=29494
require 'socket'
require 'gelf'
DEBUG = true
LISTEN_PORT = 5514
LISTEN_ADDRESS = "127.0.0.1"
@Genkilabs
Genkilabs / autocomplete.js.coffee
Created February 20, 2012 19:39
Pass additional parameters into jQueryUI autocomplete widget in rails 3.1 coffeescript
#turn on our autocompletes if there are any
jQuery ->
if $('#user_autocomplete').length
index = 1
$('#user_autocomplete').autocomplete
source: (request, response) ->
#add our custom index parameter to the call
request["index"] = index++
#make our request and handle the response as normal
$.ajax(
require 'matrix'
def regression x, y, degree
x_data = x.map {|xi| (0..degree).map{|pow| (xi**pow) }}
mx = Matrix[*x_data]
my = Matrix.column_vector y
((mx.t * mx).inv * mx.t * my).transpose.to_a[0].reverse
end