Skip to content

Instantly share code, notes, and snippets.

View rcdilorenzo's full-sized avatar
🙌
Working in His Kingdom (Col 3:17)

Christian Di Lorenzo rcdilorenzo

🙌
Working in His Kingdom (Col 3:17)
View GitHub Profile
@rcdilorenzo
rcdilorenzo / resize-images.sh
Created November 3, 2018 17:32
Sample code from rcd.ai blog post
#!/bin/bash
# resize-images.sh
# Preprocess Stanford Cars Dataset
# Stats for width
# ❯ ls cars_**/*.jpg |
# xargs -L1 identify -format "%w\n" |
# datamash min 1 max 1 mean 1 median 1
#
# 78 7800 700.49255483472 640
@rcdilorenzo
rcdilorenzo / eda.r
Last active July 14, 2018 19:33
Collection of helpful EDA functions in R (originally created for M.S. in Data Science assignment work at Regis University)
hist.density <- function (data, xlab = "<x>", font.main = 1,
main = "Histogram of data") {
# Calculate histogram based on these values
data.hist = hist(data, plot = FALSE)
# Determine scaling factor
multiplier = data.hist$counts / data.hist$density
# Create density function of the area
@rcdilorenzo
rcdilorenzo / install-elixir.yml
Created November 30, 2015 02:33
An ansible playbook script to install elixir on a raspberry pi running Raspbian Wheezy
---
- hosts: all
remote_user: pi
tasks:
- name: check if erlang installed
shell: which erl
register: erl_check
ignore_errors: true
- apt_repository: repo='deb http://packages.erlang-solutions.com/debian wheezy contrib' state=present
# Assumes an existing data frame called `raw`
# that is directly imported from the URL and
# has not converted the "?" values to NA's
colnames(raw) <- c("Type", "CapShape", "CapSurface", "CapColor", "Bruises",
"Odor", "GillAttachment", "GillSpacing", "GillSize",
"GillColor", "StalkShape", "StalkRoot",
"StalkSurfaceAboveRing", "StalkSurfaceBelowRing",
"StalkColorAboveRing", "StalkColorBelowRing", "VeilType",
"VeilColor", "RingNumber", "RingType", "SporePrintColor",
@rcdilorenzo
rcdilorenzo / bisynoptic_text_analysis.py
Last active December 3, 2017 01:32
Text analysis comparison between the Synoptic Gospels Matthew and Luke. Created as a part of a graduate assignment for an M.S. in Data Science from Regis University. (Simply run `python bisynoptic_text_analysis.py` from the current directory with all the files downloaded)
from word_frequency import WordFrequency
luke = WordFrequency('Luke', './Luke.txt')
matthew = WordFrequency('Matt', './Matthew.txt')
print('================================')
print('= Frequently Occurring Phrases =')
print('= Between Matthew & Luke (Max =')
print('= 4 words/phrase, Min freq 15) =')
print('================================')
@rcdilorenzo
rcdilorenzo / main.go
Last active August 17, 2017 02:19
Golang port (for fun/school) of simple recommendation system from http://guidetodatamining.com/chapter2/
package main
import (
"fmt"
"math"
"sort"
)
type Recommendation struct {
Name string
@rcdilorenzo
rcdilorenzo / Button.swift
Created July 19, 2017 12:40
Various iOS extensions for creating reusable views in code
import UIKit
extension UIButton {
static func createBordered(light: Bool) -> UIButton {
let button = UIButton(type: .roundedRect)
button.contentEdgeInsets = UIEdgeInsets(top: 5, left: 7, bottom: 5, right: 7)
button.layer.cornerRadius = 5
button.translatesAutoresizingMaskIntoConstraints = false
if (light) {
button.backgroundColor = UIColor.white

Keybase proof

I hereby claim:

  • I am rcdilorenzo on github.
  • I am rcdilorenzo (https://keybase.io/rcdilorenzo) on keybase.
  • I have a public key ASABBZcTLyE8g_vbKklI8aSC1LTqFlK-KHgIaZuKIcm39Qo

To claim this, I am signing this object:

@rcdilorenzo
rcdilorenzo / MyControllerOrView.m
Created May 2, 2017 21:45
How to display dynamic length strings in a scrollable popover on iOS with perfect padding 👌🏻🥇
// Requires a property like the following
// @property (nonatomic, strong) UIPopoverController *textPopover;
- (void)displayPopoverForText:(NSString *)text inView:(UIView *)view presentingRect:(CGRect)rect maxSize:(CGSize)maxSize {
UIViewController *controller = [UIViewController new];
UITextView *textView = [UITextView new];
textView.text = text;
textView.editable = NO;
textView.backgroundColor = [UIColor clearColor];
@rcdilorenzo
rcdilorenzo / main.md
Created November 28, 2016 12:04
TIL: Generic Protocol Limitations in Swift

TIL: Apparently, Swift does not support creating concrete protocols from generic ones since it uses associated types for more customizable generic protocol adaptation. This is in contrast to classes and structs. Here is an example of a generic struct from my situation:

fileprivate struct WindowScopeUpdate<State> {
    let update: (State) -> (State)
}

An example usage would be like this (where TaskListWindowState is a concrete type such as a class, struct, or non-generic protocol):