Skip to content

Instantly share code, notes, and snippets.

View lshapz's full-sized avatar

Laura Shapiro lshapz

View GitHub Profile
@lshapz
lshapz / commands.md
Last active May 16, 2018 16:31
git commands I want to remember

remove file or folder from entire git history

  • useful for sensitive data (passwords) or large files (save space)
git filter-branch --tree-filter "rm -rf ./PATH_TO_FOLDER/OR_FILE.EXT" HEAD 
git push origin --force --all
@lshapz
lshapz / header_row_how_to.md
Last active March 12, 2018 17:29
workflow for revising the header row of an enormous CSV file in preparation for JSON conversion
Problem:
  • 100000 line CSV file.
  • header row includes unnecessary type definitions in it (i.e. "header1:String,header2:Decimal,header3:INT32")
  • CSV is too large to open in Numbers/Google Sheets for simple find/replace
Solution:
  • get only the header row
@lshapz
lshapz / cats.html
Created August 28, 2017 16:02
vue data binding and components
<style>
ul {
list-style-type: none;
}
</style>
<div id="app">
<component :is="currentView"></component>
const flat = (array) => {
let newArray = []
return function flatten(array){
array.forEach(item=>{
if (typeof item === "object") {
flatten(item)
}
else {newArray.push(item)}
})
return newArray
@lshapz
lshapz / data.js
Last active April 17, 2017 22:48
recursive_tree_creation
module.exports.alphaEmployees = alphaEmployees =
[ { name: 'Jake',
role: 'senior developer',
reports_to: 'project manager' },
{ name: 'Jane', role: 'senior accountant', reports_to: 'CFO' },
{ name: 'Jaya',
role: 'junior developer',
reports_to: 'senior developer' },
{ name: 'Jeff',
role: 'salesperson',
@lshapz
lshapz / fun_with_linked_lists.rb
Created April 11, 2017 19:38
Linked List related functions
class LinkedListNode
attr_accessor :value, :next_node, :list
def initialize(value, next_node=nil)
@value = value
@list = []
@next_node = next_node
end
def print
select employees.name, b.name from employees join employees as b on employees.salary < b.salary;
require 'byebug'
def stringSimilarity(a)
array = Array.new(a.length, 0)
# each index in array will be similiarty score between a[i..-1] and a
array[0] = a.length
# we know a[0..-1] == a so let's start there
left = 0;
right = 0;
# left and right are bounds of "z box", or substring we are checking
index = 1
module MovieHelper
def new_movie
@director = Director.find_or_create_by!(name: "Alan Smithee")
@movie = Movie.find_or_create_by!(title: "Movie", director_id: @director.id, year: 1956, link: "http://imdb.com/title/tt0033467", imdbID: "tt0033467")
end
def movie_two
@director = Director.find_or_create_by!(name: "Alan Smithee")
@movie2 = Movie.find_or_create_by!(title: "Movie 2", director_id: @director.id, year: 1957, link: "http://imdb.com/title/tt0333467", imdbID: "tt0333467")
def current_user
@user = User.find(session[:user_id]
end