Skip to content

Instantly share code, notes, and snippets.

View compwron's full-sized avatar
💭
https://github.com/drop-ice/dear-github-2.0

compwron compwron

💭
https://github.com/drop-ice/dear-github-2.0
View GitHub Profile
# group by x
# def time(a_proc)
# start = Time.now
# a_proc.call
# puts Time.now - start
# end
#
# time(Proc.new { code_here })
# time(Proc.new { more_code_here })
thing1 = { data: 'data1', size: 10 }
thing2 = { data: 'data2', size: 20 }
thing3 = { data: 'data3', size: 5 }
require 'time'
require 'ap'
class Cache
def initialize(size:)
@size = size
@things = []
@locations = {} # key: @things pointer
@compwron
compwron / tictactoe.rb
Created April 28, 2019 22:00
incomplete tictactoe
# frozen_string_literal: true
class TicTacToe
class SpotTaken < StandardError
end
SIZE = 3
DEFAULT = '-'
def initialize
@compwron
compwron / ymlfind.rb
Last active December 20, 2018 01:40
Find the line number of a key in a long yaml file
#!/usr/bin/ruby
# frozen_string_literal: true
require 'yaml'
to_find = ARGV[0]
puts "Finding #{to_find}"
parts = to_find.split('.')
filename = 'config/locales/en.yml'
@compwron
compwron / queue-example.rb
Created December 14, 2017 05:38
simple queue demo code
# Design & implement an API that allows us to offload work into a queue, as well
# as consume and complete jobs on the queue. The API should provide the following
# functionality:
#
# 1) enqueue a job, which would consist of a job type and parameters
#
# 2) register something to handle jobs of a specific type
# (e.g. this could be a callback or class)
#
# 3) execute all jobs in the queue
@compwron
compwron / SafeCommitGradlePlugin.java
Created December 14, 2017 05:25
gradle plugin to install https://github.com/jandre/safe-commit-hook when a build is run
package com.example.gradleplugin
import com.google.common.io.Resources
import org.ajoberstar.grgit.Grgit
import java.nio.charset.Charset
class PreCommitHooks {
public static final String HOOK_PATH = '.git/hooks/'
public static final String COMMIT_MSG_HOOK_PATH = HOOK_PATH + 'commit-msg'
@compwron
compwron / flowify.sh
Last active December 29, 2017 05:53
gradle task for ratcheting flow percentage in js codebase
#!/usr/bin/env bash
files_with_flow=`grep -r @flow web-src/src | wc -l | sed 's#^ *##g'` # sed removes leading whitespace
total_js_files=`find web-src/src -name *.js -type f | wc -l | sed 's#^ *##g'`
echo "Files with flow: "$files_with_flow
echo "Total js files: "$total_js_files
source previous_flowify_counts.sh
echo "Previous percentage flowified: "$PREVIOUS_FLOWIFY_PERCENTAGE
@compwron
compwron / hard_questions_for_recruiters.txt
Created September 5, 2017 22:57
hard questions for recruiters
Even though some of these questions don't affect me directly, I consider them excellent indicators of whether a company is somewhere that I want to work at, because I would not like to work at a place where I wouldn't be able to be proud of.
(In approximate order of liklihood that a company will make me sad)
Does the company offer trans healthcare? How do you stack up against the https://www.hrc.org/hei/hei-scoring-criteria checklist?
What is your parental leave policy?
Would I be the only woman developer on the team?
What is your policy/approach/guidelines on contributing back to open source software projects?
What is the team like? Number, composition, specialties? Do they do pull requests or push to master, what are their favorite conferences, is there an on call rotation? :)
@compwron
compwron / clearable-material-ui-date-picker.js
Created August 31, 2017 21:46
clearable-material-ui-date-picker.js
// credit to Michael Lennon
import React, {Component, button} from "react";
import PropTypes from "prop-types";
import DatePicker from "material-ui/DatePicker";
import moment from "moment-timezone";
function DatePickerClearable({style, datePickerStyle={}, ...datePickerProps}) {
function clearBtnClickWrapper() {
datePickerProps.onChange(null, null); // (event, newValue)
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.MigrationInfo;
import org.flywaydb.core.api.callback.BaseFlywayCallback;
import org.flywaydb.core.api.callback.FlywayCallback;
import org.flywaydb.core.api.configuration.FlywayConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer;