Skip to content

Instantly share code, notes, and snippets.

View rynbyjn's full-sized avatar
🤘
metal

Ryan Boyajian rynbyjn

🤘
metal
  • Denver, CO
View GitHub Profile
@rynbyjn
rynbyjn / word_from_selection.coffee
Created June 19, 2014 20:20
Gets the closest word backwards from the cursor position within a text node.
getWordFromSelection: (e) ->
selection = document.getSelection()
word = []
text = selection.anchorNode?.wholeText || ' '
wordArr = text.split('')
anchorPos = selection.anchorOffset - 1
anchorPos = 0 if anchorPos < 0
for index in [anchorPos..0]
letter = wordArr[index]
if letter.match(/\s/)
@rynbyjn
rynbyjn / seeds.rb
Created October 1, 2014 20:14
Seed test users.
(0..10).each do |num|
unless User.exists? username: "testie#{num}"
User.create! username: "testie#{num}", email: "testie#{num}@example.com", password: 'password', password_confirmation: 'password'
end
end
@rynbyjn
rynbyjn / Generate release notes from PRs.md
Last active August 29, 2015 14:23
Generate release notes from closed pull requests.

Generate release notes from PRs

By default this will look at the previous 100 commits from your local .git folder in your project. To Add release notes to an older project you might want to bump that WAY up.

Also you will need a valid GitHub token in your .env file.

GenerateReleaseNotes.new('your_org/your_project', 'path_to_location_of_prev_sha_file/previous-sha.yml', ENV['GITHUB_API_TOKEN'], true)

@rynbyjn
rynbyjn / Generate Apple App Icon sizes from a larger image.md
Last active January 5, 2016 00:04
Generate Apple app icon sizes from a larger image

Generate Apple App Icon sizes from a larger image

ruby generate_app_icon_sizes.rb path_to_large_image

@rynbyjn
rynbyjn / line_numbers.sh
Last active February 24, 2017 21:51
Print out the count of lines within each file in the src
find src -type f -print | xargs wc -l
@rynbyjn
rynbyjn / 666.js
Created March 1, 2016 15:53
alert 666
alert([2, 3, 5, 7, 11, 13, 17].map((x) => x * x).reduce((x, y) => x + y, 0))
@rynbyjn
rynbyjn / bit_tech_symposium_notes.md
Last active May 11, 2018 19:14
BIT Technology Symposium

BIT Technology Symposium

Giving Accessibility a Face

Paul Seigneur (student, Golden High School)

  • Braile and speak (piece of technology that would speak braile)
  • Brailist (translator)
  • Screen Readers:
    • JAWS ($1100)
  • NVDA (free, but seems to require a donation, but windows only)
@rynbyjn
rynbyjn / hooks.md
Last active November 28, 2018 20:10
L&L on React 16.7.0 hooks

React 16.7.0 hooks

  • Currently in alpha.2, but scheduled for release ~Q1 2019 React roadmap
  • Opt in (100% backwards compatible)

3 things that suck in React

  1. Reusing logic (wrapper hell) think HOCs & render prop functions
  2. Reduce “giant” components (too much boiler plate logic split across lifecycle methods)
@rynbyjn
rynbyjn / color.ts
Created March 29, 2019 15:59
Some helper functions for color manipulation and compliance in javascript
export const fullHex = (hex: string): string => {
let h: string = hex.replace(/[^a-f\d]/gi, '')
if (h.length < 6) {
h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2]
}
return h
}
export const updateHexLuminance = (hex: string, lum: number = 0): string => {
const h: string = fullHex(hex)
@rynbyjn
rynbyjn / px2rem.ts
Created June 14, 2019 16:03
A stylis.js plugin to convert pixel values to rem values
// Based on the [postcss-pxtorem plugin](https://github.com/cuth/postcss-pxtorem)
const minPixelValue = 4
export const ROOT_VALUE = 16
const unitPrecision = 5
// See https://github.com/cuth/postcss-pxtorem/blob/master/lib/pixel-unit-regex.js
const pxRegExp = /"[^"]+"|'[^']+'|url\([^)]+\)|(\d*\.?\d+)px/gi
// Not an exhaustive list but should cover most use cases: