Skip to content

Instantly share code, notes, and snippets.

View coreyjs's full-sized avatar

Corey Schaf coreyjs

View GitHub Profile
@coreyjs
coreyjs / dcp1.rb
Created February 25, 2019 18:53
Daily Coding Email Challenge 2
puts 'Daily Coding Challenge 1'
puts 'Given a list of numbers and a number k, return whether any two numbers from the list add up to k.'
input = [10, 15, 3, 7]
k = 17
puts "input = #{input.to_s}"
puts "k = #{k}"
input.each_with_index do |num, i|
@coreyjs
coreyjs / dcp3.rb
Created February 25, 2019 18:53
Daily Coding Email Challenge 3
puts 1
@coreyjs
coreyjs / landscape_M.txt
Last active March 13, 2019 18:02
Unreal Basic Landscape Material
Begin Object Class=/Script/UnrealEd.MaterialGraphNode_Root Name="MaterialGraphNode_Root_0"
Material=PreviewMaterial'"/Engine/Transient.My_Landscape_M"'
NodePosX=560
NodePosY=-240
NodeGuid=3AE30DA94F8C789AFCCA76A064E7DFA7
CustomProperties Pin (PinId=8465D6104324CDFC1236A7AA3BF0C172,PinName="Base Color",PinType.PinCategory="materialinput",PinType.PinSubCategory="5",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_8 BD5EE9314271722DEBE601979B4CDC2F,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=72F1750A40A5CF95548D899BDCDA51EF,PinName="Metallic",PinType.PinCategory="materialinput",PinType.PinSubCategory="6",PinType.PinSubCatego
@coreyjs
coreyjs / two_strings_problem.rb
Last active July 25, 2020 16:09
Compare two strings to see if there is a subset
#!/bin/ruby
require 'json'
require 'stringio'
require 'set'
# Complete the twoStrings function below.
#s1, s2: two strings to analyze .
def twoStrings(s1, s2)
@coreyjs
coreyjs / string_permuatations.rb
Created July 25, 2020 15:37
Hash all string permutations
hash = {}
0.upto(s1.length.to_i - 1).flat_map do |start|
1.upto(s1.length - start).map do |length|
hash[s1[start, length]] = length
end
end.uniq
@coreyjs
coreyjs / left.rb
Created August 6, 2020 01:44
Left Rotate an Array
#!/bin/ruby
require 'json'
require 'stringio'
# Complete the rotLeft function below.
def rotLeft(a, d)
out = Array.new(a.length)
(0..a.length-1).each do |i|
new_location = (i + (a.length - d)) % a.length
@coreyjs
coreyjs / sum_pairs.py
Created August 6, 2020 16:52
K-diff pairs in an array
from collections import Counter
def find_pairs(nums, k) -> int:
# if k < 0, the result is 0
if k < 0:
return 0
count = Counter(nums)
pairs = set([])
@coreyjs
coreyjs / file_server.rb
Created August 6, 2020 21:27
File Server
class Storage
attr_accessor :value
def initialize
@value = nil
@map = {} # string, Storage
end
def map
@coreyjs
coreyjs / build_roc_auc.py
Created September 26, 2020 15:35
Function for calculating auc and roc
# Function for calculating auc and roc
def build_roc_auc(model, X_train, X_test, y_train, y_test):
'''
INPUT:
model - an sklearn instantiated model
X_train - the training data
y_train - the training response values (must be categorical)
X_test - the test data
y_test - the test response values (must be categorical)
@coreyjs
coreyjs / sigmoid.py
Created October 11, 2020 16:08
Sigmoid, yhat, error forumula and weight updating
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def output_formula(features, weights, bias):
return sigmoid(np.dot(features, weights) + bias)
def error_formula(y, output):
return - y*np.log(output) - (1 - y) * np.log(1-output)
def update_weights(x, y, weights, bias, learnrate):