Skip to content

Instantly share code, notes, and snippets.

View emilebosch's full-sized avatar
🏠
Working from home

Emile Bosch emilebosch

🏠
Working from home
View GitHub Profile
import os
import pickle
import warnings
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
@thegedge
thegedge / find_cohesive_changes.rb
Last active May 14, 2020 13:42
Attempt to find cohesive sets of methods in a Ruby file, based on how it's changed with other files in a repo
#!/usr/bin/ruby --disable-gems
#
# # Prerequisites
#
# # Example usage
#
# find_cohesive_changes <file>
#
require "open3"
@thegedge
thegedge / find_unused_methods.rb
Last active May 19, 2020 08:17
Find unused Ruby methods (expect false positives) via static analysis
#!/usr/bin/env ruby
# frozen_string_literal: true
require "csv"
require "set"
begin
require "erubi"
rescue LoadError
end
@ethanfrogers
ethanfrogers / job.yaml
Created May 7, 2019 12:36
Kaniko Job spec
apiVersion: batch/v1
kind: Job
metadata:
name: kaniko-builder
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
@bbonamin
bbonamin / Brewfile
Last active March 19, 2024 14:54
Capybara Selenium Webdriver: Headless Chrome (with file downloads!) & Headless Firefox
tap "caskroom/cask"
cask "google-chrome"
cask "firefox"
brew "chromedriver"
brew "geckodriver"
@theorygeek
theorygeek / association_loader.rb
Last active October 31, 2023 07:15
Preloading Associations with graphql-batch
# frozen_string_literal: true
class AssociationLoader < GraphQL::Batch::Loader
attr_reader :klass, :association
def initialize(klass, association)
raise ArgumentError, "association to load must be a symbol (got #{association.inspect})" unless association.is_a?(Symbol)
raise ArgumentError, "cannot load associations for class #{klass.name}" unless klass < ActiveRecord::Base
raise TypeError, "association #{association} does not exist on #{klass.name}" unless klass.reflect_on_association(association)
@klass = klass
@rmosolgo
rmosolgo / Gemfile
Last active March 27, 2023 08:38
GraphQL Ruby Subscriptions
source 'https://rubygems.org'
gem "graphql", github: "rmosolgo/graphql-ruby", branch: "subscriptions"
gem "sinatra"
gem "thin"
@mankind
mankind / rails-jsonb-queries
Last active May 23, 2024 06:47
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@burke
burke / genkey.rb
Created October 12, 2016 14:34
Create an Elliptic Curve keypair in ruby
require 'openssl'
k = OpenSSL::PKey::EC.new('secp384r1').generate_key
p = OpenSSL::PKey::EC.new(k.public_key.group)
p.public_key = k.public_key
puts k.to_pem, p.to_pem
@SoylentGraham
SoylentGraham / PaintCloudData.shader
Created May 3, 2016 22:31
Shader based texture painting. Add the script to a plane with a collider and attach a render texture
Shader "NewChromantics/PaintCloudData"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
PaintUv("PaintUv", VECTOR) = (0,0,0,0)
PaintBrushSize("PaintBrushSize", Range(0,0.1) ) = 0.1
}
SubShader
{