Skip to content

Instantly share code, notes, and snippets.

View srowhani's full-sized avatar

Seena Rowhani srowhani

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
int str_len (char* myStr)
{
int length = 0;
while (1)
{
if (myStr[length] == '\0')
break;
@srowhani
srowhani / components.my-component.js
Created August 3, 2016 18:54
Asana Style Editor
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement () {
if (this.get('isFocused'))
this.$('input').focus()
}
});
@srowhani
srowhani / example.json
Last active October 6, 2016 00:53
JSONAPI Example ember
{
"data": [
{
"_id": "ember-frost-navigation@5.0.3",
"type": "repository",
"attributes": {
"name": "ember-frost-navigation",
"source": "GitHub",
"user": "",
"version": "5.0.3",
@srowhani
srowhani / _def.js
Last active October 17, 2016 23:27
MWT algorithm implemented in ES6
let Point = function (x, y) {
this.x = x
this.y = y
}
let Triangle = function (p1, p2, p3) {
this.p1 = p1
this.p2 = p2
this.p3 = p3
}
@srowhani
srowhani / .deploy.sh
Last active October 21, 2016 17:56
Helps deploy stuff
#!/bin/bash
set -ev
# Blow up current dist
rm -rf dist;
# Build it
ember build --prod;
# Initialize dist as it's own repo
URL=$(git remote get-url origin);
cd dist;
git init;
Array.prototype.equals = function (array) {
// if the other array is a falsy value, return
if (!array)
return false;
// compare lengths - can save a lot of time
if (this.length != array.length)
return false;
for (var i = 0, l=this.length; i < l; i++) {
#!/usr/bin/env node
/**
* Suppose you want to place gasoline stations at various locations along a highway.
* For simplicity, let us model the highway as the X-axis.
* You have a list of potential locations for the gas stations x1 , x2 , . . . , xn .
* For each location, you have an estimated revenue r1 , r2 , . . . , rn .
* However, for environmental reasons, the distance between two gas stations must be at least 20 kilometers,
* that is for two consecutive gas stations xi and xj, we must have xj − xi ≥ 20.
* Design a placement algorithm that will optimize your estimated revenue.
* For example, if your possible station locations are (2, 17, 24, 32, 48),
@srowhani
srowhani / Dijkstra's Algorithm Base Impl
Created December 3, 2016 21:15
Dijkstra's Algorithm Runtime Analysis
Given
G = (V,E)
s = some arbitrary starting vertex v in V
wt = function that returns the weight of e given edge
d = {}
S = {} -> Result set
Q = V
for each v in V
d[v] = Infinity
@srowhani
srowhani / 2 Connected Graphs
Last active February 27, 2024 06:16
COMP3804 - Final Exam Review
A graph is said to be 2 connected if from every pair of vertices (u,v), there exists a vertex disjoint path from u to v.
That is to say that for every vertex x in V(G), G - x is still connected.
Theorem 1 (Whitney, 1927)
A connected graph G with at least
three vertices is 2-connected iff for every two vertices x, y ∈
V (G), there is a cycle containing both.
If every two vertices belong to
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});