#Mac OS X - Notes
This file contains 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
framework 'Foundation' | |
class String | |
def language | |
CFStringTokenizerCopyBestStringLanguage(self, CFRangeMake(0, self.size)) | |
end | |
def tokens | |
str_array = [] | |
stok = CFStringTokenizerCreate(nil,self,[0,self.length],0,nil) | |
CFStringTokenizerGetCurrentTokenRange(stok) |
This file contains 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
IO.popen("grep -i what", "w").write ( IO.popen('find . ').read ) |
This file contains 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 mllib | |
import scala.util.Random | |
import org.jblas.DoubleMatrix | |
import org.apache.spark.SparkContext | |
import org.apache.spark.rdd._ | |
import org.apache.spark.SparkConf | |
import org.apache.spark.SparkContext._ |
This file contains 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
# Load a Remote file to hadoop through ssh | |
cat /some/path/tofile.csv | ssh user@host "hadoop fs -put - /some_hdfs/path/for/the/file.csv" |
This file contains 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
on write_to_file(this_data, target_file, append_data) | |
try | |
set the target_file to the target_file as string | |
set the open_target_file to open for access file target_file with write permission | |
if append_data is false then set eof of the open_target_file to 0 | |
write this_data to the open_target_file starting at eof | |
close access the open_target_file | |
return true | |
on error | |
try |
This file contains 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 scala.sys.process._ | |
//"ls -la".!! | |
val result = "ls -la".!! |
This file contains 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
# pyspark --packages com.databricks:spark-avro_2.10:1.0.0 | |
# read avro files from 1.3.0 spark | |
df = sqlCtx.load("/path/to/my_avro", "com.databricks.spark.avro") |
This file contains 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
// Set logging level for spark scala | |
Logger.getLogger("org").setLevel(Level.WARN) | |
Logger.getLogger("akka").setLevel(Level.WARN) |
This file contains 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
#from pyspark.sql import HiveContext | |
#sqlContext = HiveContext(sc) | |
query = """ | |
select * from db.sometable where col>50 | |
""" | |
results = sqlContext.sql(query) | |
result_writer = pyspark.sql.DataFrameWriter(results) | |
result_writer.saveAsTable('db.new_table_name',format='parquet', mode='overwrite',path='/path/to/new/data/files') |
OlderNewer