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
#!/bin/sh | |
# one way (older scala version will be installed) | |
# sudo apt-get install scala | |
#2nd way | |
sudo apt-get remove scala-library scala | |
wget http://www.scala-lang.org/files/archive/scala-2.11.2.deb | |
sudo dpkg -i scala-2.11.2.deb | |
sudo apt-get update |
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
#!coding:utf-8 | |
#!coding:/usr/bin/python | |
""" | |
dependency: | |
you have to install beautifulsoup4 modulex | |
sudo pip install beautifulsoup4 | |
description: | |
ximalaya downloading program made by Meyou(Wuhan) --2015.4.27 |
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 requests | |
from bs4 import BeautifulSoup | |
from multiprocessing.dummy import Pool | |
import os | |
os.chdir(r'E:\python\2017_4_20') | |
mp3_url = 'http://www.ximalaya.com/2452186/album/4015467' | |
headers = { |
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
#!/bin/bash | |
# Copyright (c) Jupyter Development Team. | |
# Distributed under the terms of the Modified BSD License. | |
set -e | |
if [[ ! -z "${JUPYTERHUB_API_TOKEN}" ]]; then | |
# launched by JupyterHub, use single-user entrypoint | |
exec /usr/local/bin/start-singleuser.sh $* | |
else |
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
// see https://gist.github.com/2382341 | |
// scalaz for only solution3 | |
import scalaz._ | |
import Scalaz._ | |
object SolutionForMultiNestedMatchforMyStudy { | |
def f(num: Int): Option[Int] = { | |
num match { |
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
// this flavour is pure magic... | |
def toDouble: (Any) => Double = { case i: Int => i case f: Float => f case d: Double => d } | |
// whilst this flavour is longer but you are in full control... | |
object any2Double extends Function[Any,Double] { | |
def apply(any: Any): Double = | |
any match { case i: Int => i case f: Float => f case d: Double => d } | |
} | |
// like when you can invoke any2Double from another similar conversion... |
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
def averageTime[R](block: => R, numIter: Int = 10): Unit = { | |
val t0 = System.nanoTime() | |
(1 to numIter).foreach( _ => block) | |
val t1 = System.nanoTime() | |
val averageTimeTaken = (t1 - t0) / numIter | |
val timeTakenMs = averageTimeTaken / 1000000 | |
println("Elapsed time: " + timeTakenMs + "ms") | |
} | |
val testDf = spark.range(10000000).toDF.cache |
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 org.apache.spark.ml._ | |
import org.apache.spark.ml.util.Identifiable | |
import org.apache.spark.sql.types._ | |
val df = Seq( | |
(0, "a"), (1, "b"), | |
(2, "c"), (3, "a"), | |
(4, "a"), (5, "c")) | |
.toDF("label", "category") |
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
df.collect().foreach(row => row.toSeq.foreach(col => { | |
col match { | |
case n: Number => println(col) | |
case _ => None | |
} | |
})) |
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
df.collect().foreach(row => row.toSeq.foreach(col => { | |
col match { | |
case n: Number => println(col) | |
case _ => None | |
} | |
})) |
OlderNewer