Skip to content

Instantly share code, notes, and snippets.

@yeedle
yeedle / The Technical Interview Cheat Sheet.md
Created November 13, 2016 04:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

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.
@yeedle
yeedle / StringToIntConversion.java
Last active November 27, 2016 02:53
Converts a number encoded as a String in any radix to an int in decimal representation using Java 8 based on http://stackoverflow.com/a/18552071/4240010
import java.util.*;
import java.util.stream.*;
import java.util.concurrent.atomic.*;
class StringToIntConversion {
public static void main(String[] args) {
String binary = "01110";
System.out.println(Integer.valueOf(binary, 2));
System.out.println(toRadix(binary, 2));
@yeedle
yeedle / CountingOccuerences.java
Last active November 27, 2016 15:12
Counting occurrences of words or chars in a string using Java 8 streams
import java.util.*;
import java.util.stream.*;
class CountingOccureences {
public static void main(String[] args) {
String example = "The quick brown fox jumps over the lazy dog and the dog catches the fox";
System.out.println(countOccurences(example.replaceAll("\\s", ""), ""));
// output: {a=3, b=1, c=3, d=3, e=6, f=2, g=2, h=5, i=1, j=1, k=1, l=1, m=1, n=2, o=6, p=1, q=1, r=2, s=2, t=5, u=2, v=1, w=1, x=2, y=1, z=1}
@yeedle
yeedle / ExtensionMethods.cs
Created December 14, 2016 20:09
asgn06 created by Yeedle - https://repl.it/Eo5Y/37
using System;
using System.Linq;
using System.Collections.Generic;
public static class ExtnesionMethods {
public static IEnumerable<T> MaxOverPrevious<T, S>(this IEnumerable<T> enumerable, Func<T, S> comparable) where S : IComparable<S>
{
if (!enumerable.Any()) yield break;
@yeedle
yeedle / download_windows_binaries.R
Created December 25, 2016 20:33
How to download an R package and all its dependecies for windows
getPackages <- function(packs){
packages <- unlist(
tools::package_dependencies(packs, available.packages(),
which=c("Depends", "Imports"), recursive=TRUE)
)
packages <- union(packs, packages)
packages
}
packages <- getPackages(c("ggplot2", "MASS"))
@yeedle
yeedle / add_images_as_xlabels.R
Created March 6, 2017 02:00 — forked from jonocarroll/add_images_as_xlabels.R
Replace categorical x-axis labels with images
#' Replace categorical x-axis labels with images
#'
#' Pipe a ggplot2 graph (with categorical x-axis) into this function with the argument of a list of
#' pictures (e.g. loaded via readImage) and it builds a new grob with the x-axis categories
#' now labelled by the images. Solves a problem that you perhaps shouldn't have.
#'
#' @author J. Carroll, \email{jono@@jcarroll.com.au}
#' @references \url{http://stackoverflow.com/questions/29939447/icons-as-x-axis-labels-in-r-ggplot2}
#'
#' @param g ggplot graph with categorical x axis
library(tidyverse)
#> + ggplot2 2.2.1.9000        Date: 2017-05-20
#> + tibble  1.3.1                R: 3.4.0
#> + tidyr   0.6.3               OS: elementary OS 0.4.1 Loki
#> + readr   1.1.1              GUI: X11
#> + purrr   0.2.2.2         Locale: en_US.UTF-8
#> + dplyr   0.5.0.9005          TZ: posixrules
#> + stringr 1.2.0           
#> + forcats 0.2.0
@yeedle
yeedle / rasmussen-approval-index.r
Last active August 2, 2017 14:30
comparing the rasmussen approval index of obama and trump
library(tidyverse)
library(rvest)
library(lubridate)
library(ggalt)
obama_url <- "http://www.rasmussenreports.com/public_content/politics/obama_administration/obama_approval_index_history"
trump_url <- "http://www.rasmussenreports.com/public_content/politics/trump_administration/trump_approval_index_history"
index <- list(obama = obama_url, trump = trump_url) %>%
map_df(~ read_html(.x) %>%
@yeedle
yeedle / hourly-weather.R
Last active February 5, 2022 04:14
Temperature of every hour in NY since 1973
library(tidyverse)
library(R.utils)
library(glue)
library(magrittr)
library(weathermetrics)
library(padr)
library(ggExtra)
library(lubridate)
library(scales)
library(hrbrthemes)
@yeedle
yeedle / hourly-weather-london.R
Created October 24, 2017 13:50
Temperature of every hour in London since 1973
library(tidyverse)
library(R.utils)
library(glue)
library(padr)
library(ggExtra)
library(lubridate)
library(scales)
library(hrbrthemes)
#london