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
package patmat | |
import org.scalatest.FunSuite | |
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
import patmat.Huffman._ | |
@RunWith(classOf[JUnitRunner]) |
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
object InsertionSort{ | |
def sort(xs : List[Int]): List[Int] = { | |
def insert(sorted : List[Int], e : Int)= { | |
sorted.takeWhile( x => (x < e)) ++ List(e) ++ sorted.dropWhile( x => (x < e)) | |
} | |
xs.foldLeft(List[Int]()) { (sorted, e) => insert(sorted, e) } | |
} | |
} |
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
# Easier navigation: .., ..., ~ and - | |
alias ..="cd .." | |
alias ...="cd ../.." | |
alias ....="cd ../../.." | |
alias .....="cd ../../../.." | |
# Detect which `ls` flavor is in use | |
if ls --color > /dev/null 2>&1; then # GNU `ls` | |
colorflag="--color" | |
else # OS X `ls` |
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
INSERT INTO app (appID, appType, partnerID) SELECT distinct(appID), appType, partnerID FROM performance WHERE appID IN( SELECT distinct(appID) FROM performance AS ip WHERE date='2014-08-13' AND NOT EXISTS (SELECT appID FROM app AS ia WHERE ip.appID = ia.appID) AND ip.appID IS NOT NULL AND ip.appID != '') LIMIT 1000; |
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
function queryStringMapping(){ | |
var paramStr = window.location.href.split("?")[1].split("&"); | |
var paramsMap = new Object() , key , value; | |
for(var i in paramStr){ | |
key = paramStr[i].split("=")[0]; | |
value = decodeURI(paramStr[i].split("=")[1]); | |
paramsMap[key] = value; | |
} | |
return paramsMap; | |
} |
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 path from 'path'; | |
import webpack from 'webpack'; | |
import HtmlWebpackPlugin from 'html-webpack-plugin'; | |
const PORT = process.env.PORT || 8888; | |
const HOST = process.env.HOST || 'localhost'; | |
const config = { | |
entry: { | |
app: [ |
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
String.prototype.reverse = function(){ | |
var m = this.length >> 1, | |
f = this.substring(0,m), | |
t = this.substring(m,this.length); | |
return m == 0 ? t : this.reverse.apply(t) + this.reverse.apply(f); | |
} |
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
//We have an array, and we want to modify it to get new value. | |
const arr = [1, 2, 3]; | |
//f1, f2, f3 are some variable functions will apply to our arr. | |
const f1 = (x) => x+1; | |
const f2 = (x) => x*2; | |
const f3 = (x) => x*x; | |
// We usually evaluate functions one by one by mapping to get our final answer. | |
const res1 = arr.map(f1).map(f2).map(f3); |
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/addons'; | |
import Immutable from 'immutable'; | |
import classnames from 'classnames'; |
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
{ | |
mixins: [React.addons.OtherMixin, React.OtherMixin, CampaignMixin, React.addons.PureRenderMixin] | |
} |
OlderNewer