Skip to content

Instantly share code, notes, and snippets.

View seemaullal's full-sized avatar

Seema Ullal seemaullal

  • United States
  • 00:50 (UTC -07:00)
View GitHub Profile
@seemaullal
seemaullal / CoDuels
Created March 17, 2015 22:33
CoDuels
### Core Features ###
- Log in
- Screen cast of what you can do (demo) for about page
- Live feed of open "battles" (___ & ___ are battling on ___ challenge).
- Panel? Github sign in, Google plus, twitter, other ??
- Profile page
- Random challenge plus challenge specific user
- Can pick any challenge (grouped by easy, medium, hard)
- Leader board on challenge page of "top scores" (?) from users who have done the challenge
- Let users comment/rate other peoples code (maybe)
@seemaullal
seemaullal / gist:dc9b81f8ee45cfa7eb83
Last active August 29, 2015 14:24
Algorithms 7/16

Level 1
Create a function called removeVowels() to remove all the vowels in a given string. Both uppercase and lowercase vowels should be removed. Your input will be a string and you should return the string without any vowels.

Level 2
Write a function that takes in a 2-D array that represents a square matrix and returns the product of the diagonal of the matrix. For example [ [ 2, 3], [ 4, 5] ] will return 10 (2x5).

Level 3

@seemaullal
seemaullal / gist:2d2c3493b5fe3a737264
Created July 14, 2015 18:45
Longest Common Subsring

A dynamic programming approach to this problem is described below. This approach takes O(n*n) time since we are comparing the letters of a string using an n*n matrix (where n is the length of the longer string since empty characters are added to the shorter string).

A dynamic programming approach to this problem is described below. This approach takes O(n*n) time since we are comparing the letters of a string using an n*n matrix (where n is the length of the longer string since empty characters are added to the shorter string).


(click on the image to be taken to the video)

Now that we know how to think about this programming from a dynamic programming perspective, we can write some code to solve the problem. There are a few different approaches to this but generally they all have some things in common:

  • you will have a 2-d array that represents the matrix which compares
@seemaullal
seemaullal / gist:c504de50ab42a57b59c1
Last active August 29, 2015 14:24
Valid Parentheses Combinations

One way of solving this problem is to do so recursively: -you can always pick a left parentheses as long as you haven't used up all of your left parentheses (i.e. if the # of left parentheses is less than n)

  • you can pick a right parentheses if it does not make the combination invalid
    • it will be invalid if there are more right parentheses than left
    • if you keep track of how many left parentheses you currently have added, then you can determine whether or not you can add a right parentheses to the current combination
    • when you have added n left parentheses and n right parentheses, you have a valid result and can add it to your results set

You can use the following recursive calls to mimic this.

First you call a function getCombinations(left,right,curr) with left = n, right =0, and curr='' because you have n left parentheses to add but can't add any right yet (it would make the combination invalid since right parentheses must come after a left) and your initial result is an empty stri

@seemaullal
seemaullal / gist:f8d2b47d036ff9b6308a
Last active August 29, 2015 14:25
Angular Sample #1
/*
This is a custom attribute directive I wrote. It was used for form validation to ensure that the name
entered in a form was not already in the database. It is an async custom validator.
*/
'use strict';
app.directive('sandwichnamevalidator', function(SandwichesFactory, $q){
return {
require: 'ngModel',
restrict: '',
// This is a state and the controller that corresponds to the state
'use strict';
angular.module('learndotApp')
.config(function ($stateProvider) {
$stateProvider
.state('calendar', {
url: '/calendar',
controller: 'CalendarCtrl',
@seemaullal
seemaullal / gist:f347e925c8d2e0026da7
Last active August 29, 2015 14:25
Angular Sample #3
/* This is a factory used to manage a firebase reference that held data for each
room of a coding challenge instance. It was part of a web applications where
users could compete in coding challenges against each other in real time
The application can be viewed at http://www.coduels.com */
'use strict';
app.factory('RoomFactory', function($q) {
var factory = {};
alias log="git log --graph --pretty=format:'%Cred%h%Creset %C(cyan)%an%Creset -%C(blue)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
alias inst='bundle && rake db:migrate && npm install'
alias rs='git reset --hard HEAD'
alias prodc='cap production rails:console'
alias test='zeus rspec'
alias gco='git checkout'
alias ga='git add'
alias gap='git add -p'
alias gcp='git commit -p'
alias gd='git diff'

Template Method

Template method is pretty straight forward: you have a parent class that is pretty bare and more of a skeleton- it will mostly contain "abstract methods" that exist to be overridden by the subclasses that inherit from the parent. This allows you to put shared behavior in the parent class while letting the subclasses customize behavior by overriding methods. Let's take a look at an example:

class HotDrink
	attr_reader :temperature
	def initialize(temperature)
		@temperature = temperature
	end
@seemaullal
seemaullal / README.md
Last active May 1, 2017 14:43
Airport Distance Calculator Instructions

Airport Distance Calculator

Calculate the distance between two airports.

About

  • Search for an airport by typing its name, city, or airport code. Airport names will autocomplete as you search
  • The distance between the two airports will be calculated in nautical miles and the airports will also be shown on a Google map.

Live Version

A live version of the application is online at https://airport-distances.herokuapp.com/. Alternatively, follow the installation instructions below to run the application locally.