Skip to content

Instantly share code, notes, and snippets.

@negamorgan
negamorgan / adv-command-line.md
Last active August 29, 2015 14:07
Advanced Command Line Techniques

Advanced Command Line Techniques

pushd to save an array of working directories

❤  sites  mkdir sandbox
❤  sites  cd sandbox
❤  sandbox  pushd ~/Downloads/php-master
~/Downloads/php-master ~/sites/sandbox ~/sites ~

dirs to return the array

@negamorgan
negamorgan / env-instantclient-osx.md
Last active August 29, 2015 14:06
Oracle InstantClient setup
  1. Download Oracle InstantClient basic, sqlplus, and SDK packages

     instantclient-basic-macos.x32-11.2.0.4.0.zip
     instantclient-sqlplus-macos.x32-11.2.0.4.0.zip
     instantclient-sdk-macos.x32-11.2.0.4.0.zip
    
  2. Extract files and rename directory, if desired

     /instantclient
    

|

@negamorgan
negamorgan / jazz.sh
Created September 23, 2014 12:13
Jazz shell script example. From NetTuts tutorial.
#! /bin/sh
function help () {
echo "jazz - A simple script that makes using the Jasmine testing framework in a standalone project a little simpler."
echo ""
echo " jazz init - include jasmine in the project";
echo " jazz create FunctionName - creates ./src/FunctionName.js ./spec/FunctionNameSpec.js";
echo " jazz run - runs tests in browser";
}
@negamorgan
negamorgan / env-java-osx.md
Created September 22, 2014 20:28
Java 7 Dev Environment set up (OS X)
  1. Download JDK 7 for OS X x64 and follow the installation wizard.

  2. Add JAVA_HOME to env variables in .bash_profile, .bashrc or .zshrc

     export JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home'
    
  3. Add java_home alias to .bash_profile, .bashrc or .zshrc

     alias java_home='/usr/libexec/java_home'
    

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@negamorgan
negamorgan / euler-problem-2.rb
Created April 30, 2014 21:32
euler-problem-2.rb
def even_fibonacci_numbers
fibonacci_numbers.select {|n| n.even? }.reduce(:+)
end
def fibonacci_numbers
numbers = [1, 2]
while numbers[-1] < 4_000_000 do
numbers << numbers[-2] + numbers[-1]
end
numbers[0..-2]
@negamorgan
negamorgan / euler-problem-1.rb
Created April 30, 2014 20:39
euler-problem-1.rb
1.upto(999).select do |n|
n % 3 == 0 || n % 5 == 0
end.reduce(:+)
@negamorgan
negamorgan / fizzbuzz.rb
Created April 30, 2014 20:17
fizzbuzz.rb
def fizzbuzz(n)
1.upto(n).map do |num|
response = ""
response << "Fizz" if num % 3 == 0
response << "Buzz" if num % 5 == 0
response.empty? ? num : response
end
end
@negamorgan
negamorgan / euler-8.rb
Created March 18, 2014 13:29
Largest Product of Five (Euler 8)
def largest_product(digits)
product_of_five(digits).max
end
def product_of_five(digits)
digit_array = digits.to_s.split("")
digit_array[0..-5].map.with_index do |digit, i|
digit.to_i * digit_array[i+1].to_i * digit_array[i+2].to_i * digit_array[i+3].to_i * digit_array[i+4].to_i
end
end
@negamorgan
negamorgan / five-digit-max.rb
Created March 17, 2014 21:02
Largest 5 digit number in a series
def solution(digits)
group_by_five(digits).max
end
def group_by_five(digits)
digits.split("")[0..-5].map.with_index do |digit, i|
"#{digit}#{digits[i+1]}#{digits[i+2]}#{digits[i+3]}#{digits[i+4]}"
end
end