Skip to content

Instantly share code, notes, and snippets.

Avatar

Jordan Hudgens jordanhudgens

View GitHub Profile
View optional-chaining.ts
type EmployeeType = {
email: string;
roles?: string[];
}
let data: {employees?: EmployeeType[]};
data = {
employees: [
{email: "test@example.com", roles: ["admin", "superAdmin"]},
View map-deep-dive.ts
const familyNames = ["Jordan", "Tiffany", "Kristine"];
// let capitalizedNames: string[] = [];
// for (var i = 0; i < familyNames.length; i++) {
// capitalizedNames.push(familyNames[i].toUpperCase())
// }
// console.log(capitalizedNames)
View ProgressiveImage.tsx
import React from "react";
import { StyleSheet, Animated } from "react-native";
const styles = StyleSheet.create({
imageOverlay: {
position: "absolute",
left: 0,
right: 0,
bottom: 0,
top: 0,
View pre-push.sh
#!/bin/sh
echo "Running RSpec"
bundle exec rspec spec
spec=$?
if [ "$spec" = 0 ]
then
echo >&2 "Tests are green, pushing..."
exit 0
View example-deps.json
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.29",
"@fortawesome/free-solid-svg-icons": "^5.13.1",
"@fortawesome/react-fontawesome": "^0.1.11",
"ajv": "6.12.0",
"autoprefixer": "^9.1.0",
"axios": "0.19.2",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^7.2.3",
View tokenable.rb
module Tokenable
extend ActiveSupport::Concern
# To add to a model with pre-existing records
# ModelName.all.each do |i|
# i.token = loop do
# random_token = SecureRandom.urlsafe_base64(nil, false)
# break random_token unless i.class.exists?(token: random_token)
# end
# i.save!
View sftp.rb
begin
Net::SFTP.start(HOSTNAME, USERNAME, :password => PASSWORD) do |sftp|
sftp.file.open("products.csv", "r") do |f|
puts "Opening file..."
# Old solution:
# data = SmarterCSV.process(f, value_converters: { sku: StringConverter })
# puts "Count: #{data.size}"
# product_iterator data
# New attempt(s)
View media-queries.scss
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
}
/*
##Device = Laptops, Desktops
View image_encoder.rb
# Create a helper lib
# e.g. lib/image_encoder.rb
module ImageEncoder
def self.call(image_data, resource_name, model)
image_data.match(/(image\/[a-z]{3,4});base64,(.*)/) do |match|
content_type = match[1]
decoded_data = Base64.decode64(match[2])
temp = Tempfile.open("image", encoding: "ascii-8bit")
temp.write(decoded_data)
View zshrc
alias -g subl=subl
PATH=$PATH:/usr/local/bin/; export PATH
export PATH=/usr/local/heroku/bin
# Alias' {{{
alias vi="vim"
alias zsh="vim ~/.zshrc"
alias szsh="source ~/.zshrc"
alias killtmux="tmux kill-server"
alias desk="cd ~/Desktop"