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
Today I try to install Redmine server with Puppet on a vagrant managed virtual machine. I use a published module on puppet forge: | |
http://forge.puppetlabs.com/johanek/redmine | |
And the following is my operations: | |
1. Initialize VM: | |
chad@typcserver ~/docs/vagrant-prj $ vagrant --version | |
Vagrant 1.4.3 | |
chad@typcserver ~/docs/vagrant-prj $ vagrant init | |
chad@typcserver ~/docs/vagrant-prj $ cat Vagrantfile |
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
When I run above codes in spark-shell, I got the following errors: | |
scala> val job = new Job(sc.hadoopConfiguration) | |
warning: there were 1 deprecation warning(s); re-run with -deprecation for details | |
java.lang.IllegalStateException: Job in state DEFINE instead of RUNNING | |
at org.apache.hadoop.mapreduce.Job.ensureState(Job.java:283) | |
at org.apache.hadoop.mapreduce.Job.toString(Job.java:452) | |
at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:324) | |
at scala.runtime.ScalaRunTime$.stringOf(ScalaRunTime.scala:329) | |
at scala.runtime.ScalaRunTime$.replStringOf(ScalaRunTime.scala:337) |
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
#!/bin/bash | |
sed 's/{\"\$date\":\(\".\{10\}T.\{12\}Z\"\)}/\1/g' f1000.json > temp.json | |
sed -i 25d temp.json | |
mongoimport -d test -c strDate --type json --file temp.json | |
# sample data: | |
"timeStart":{"$date":"1015-09-01T00:00:00.000Z"},"timeEnd":{"$date":"2018-03-02T00:00:00.000Z"}, | |
"timeStart":{"$date":"2016-09-01T00:00:00.000Z"},"timeEnd":{"$date":"2021-04-0kT00:00:00.000Z"}, | |
"timeStart":{"$date":"2017-09-01T00:00:00.000Z"},"timeEnd":{"$date":"2021-05-09T00:00:00.000Z"}, |
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
aa = [{'a': 3}, {'a': 2}, {'a': 5}, {'b':8}] | |
sorted(aa, key=lambda rec: rec['a'] if 'a' in rec else 1, reverse=True) | |
#: [{'a': 5}, {'a': 3}, {'a': 2}, {'b': 8}] | |
sorted(aa, key=lambda rec: rec['a'] if 'a' in rec else 6, reverse=True) | |
#: [{'b': 8}, {'a': 5}, {'a': 3}, {'a': 2}] |
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
#!/usr/bin/python | |
import sys, re | |
from os import system | |
usage = """ | |
Usage: | |
Full style: ./cpColl sUser:sPwd@sHost:sPort/sDb-sColl dUser:dPwd@dHost:dPort/dDb-dColl | |
Abbr for source on localhost: ./cpColl sDb-sColl dUser:dPwd@dHost:dPort/dDb-dColl | |
Abbr for destination on localhost: ./cpColl sUser:sPwd@sHost:sPort/sDb-sColl dDb-dColl |
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 math | |
import random | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def normal_cdf(x, mu=0, sigma=1): | |
return (1 + math.erf((x - mu) / math.sqrt(2) / sigma)) / 2 | |
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 argparse | |
parser = argparse.ArgumentParser( | |
description='Sync docs in MongoDB to Elasticsearch server') | |
parser.add_argument('inputfile_name', | |
help='the json file contains data to synced from MongoDB') | |
parser.add_argument('-s', '--server-name', | |
help='the IP address of Elasticsearch server') | |
parser.add_argument('-i', '--index', help='the index name of ES') | |
parser.add_argument('-t', '--type-name', help='the type name of the index') |
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 os | |
import subprocess | |
basedir = '/home/leo/.donno/repo' | |
notebook = 'dsnote' | |
err_coll = [] | |
for fn in os.listdir(basedir): | |
print('upload %s' % fn) | |
fullname = os.path.join(basedir, fn) |
OlderNewer