This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The Black and Scholes (1973) Stock option formula */ | |
use std::f64; | |
fn black_scholes(putCallFlag:&str, s:f64, x:f64, t:f64, r:f64, v:f64) -> f64 { | |
let d1 = ( (s / x).ln() + (r + v * v / 2.0) * t) / ( v * t.sqrt() ); | |
let d2 = d1 - v * t.sqrt(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import bindContext from './path/to/bindContext'; | |
export default class SomeComponent extends React.Component { | |
constructor() { | |
super(); | |
// ========== Too verbose ========== | |
// this.toggleEventForm = this.toggleEventForm.bind(this); | |
// this.handleSubmit = this.handleSubmit.bind(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import alt from '../libs/alt'; | |
class KaleActions { | |
create(data) { | |
return new Promise((resolve, reject) => { | |
var post = $.ajax({ | |
type: 'POST', | |
data: data, | |
url: '/kaleapi', | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Circle</title> | |
<style type="text/css"> | |
.circle-container { | |
width: 150px; | |
height: 150px; | |
line-height: 150px; | |
text-align: center; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write reduce without Array.reduce | |
// @param {Array} list | |
// @param {Function} fn takes (acc, result) | |
// @acc {*} acc is the starting point or working accumulator | |
const reduce (list, fn, acc) => { | |
let i = 0; | |
var len = list.length; | |
while(i < len) { | |
acc = fn(acc, list[i]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Part 1 | |
// write an array mapping function that can be passed into reduce | |
const mapping = (transform) => (acc, val) => acc.concat([transform(val)]); | |
// write an array filtering function that can be passed into reduce | |
const filtering = (predicate) => (acc, val) => predicate ? acc.concat([val]): acc; | |
// Part 2 | |
// abstract out the "reduce" logic | |
const concat = (acc, val) => acc.concat([val]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const test1 = [ | |
[1] | |
]; | |
const test2 = [ | |
[1, 2], | |
[3, 4] | |
]; | |
const test3 = [ | |
[1, 2, 3], | |
[4, 5, 6], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const phoneNumberMnemonics = (phoneNumber) => { | |
const letters = ["0", "1", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] | |
const numbers = phoneNumber.split(''); | |
const results = []; | |
const wipStack = [ | |
{ wip: '', remaining: numbers } | |
]; | |
while (wipStack.length > 0) { | |
let [wip, remainingNumbers] = wipStack.pop(); | |
if (remainingNumbers.length > 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO TEST | |
// given [3,4,5,6,7,8,9,1,2] | |
// return 7 | |
const test1 = [3,4,5,6,7,8,9,1,2] | |
const test2 = [8,9,1,2,3,4,5,6,7] | |
const findk = list => { | |
if (list[0] < list[list.length-1]) { | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /dev/null | |
+++ b/my_file.txt | |
@@ -0,0 +1,3 @@ | |
+Dear Abby | |
+I met a new person today | |
+It was a good day |
OlderNewer