Skip to content

Instantly share code, notes, and snippets.

@zhangpengGenedock
zhangpengGenedock / mongodb collection group by example
Last active June 19, 2017 06:47
mongodb pymongo collection group by example.py
start_date = str(get_format_date(begin_timestamp))
end_date = str(get_format_date(end_timestamp))
match = {
'date': {
'$gte': start_date,
'$lte': end_date,
}
}
@zhangpengGenedock
zhangpengGenedock / github workflow crash solution.txt
Last active June 19, 2017 11:08
github workflow 崩溃解决办法
github workflow crash solution
I can't tell you why it worked, but deleting the workflow's working directory
(/Users/$USER/Library/Application Support/Alfred 3/Workflow Data/de.gh01.alfred.github)
cleared the cache and things seem to work again.
on alfred_script(q)
if application "iTerm2" is running or application "iTerm" is running then
run script "
on run {q}
tell application \":Applications:iTerm.app\"
activate
try
select first window
set onlywindow to false
on error
@zhangpengGenedock
zhangpengGenedock / git co tag
Created June 29, 2017 03:20
git checkout to specific tag
git checkout tags/1.1.4
.explain("executionStats")
@zhangpengGenedock
zhangpengGenedock / compound index hint and explain
Created July 3, 2017 09:01
compound index hint and explain
.hint({ quantity: 1, type: 1 }).explain("executionStats")
@zhangpengGenedock
zhangpengGenedock / mongodb create unique index
Created July 5, 2017 03:33
mongodb create unique index
db.collection.createIndex( { a: 1 }, { unique: true } )
@zhangpengGenedock
zhangpengGenedock / iterm2_execute_pyenv_activate
Created July 5, 2017 08:26
当打开iterm的terminal时,pyenv激活virtualenv
In iTerm2, preferences>profiles>tab general, there is an option in Command called send text at start that executes any command you put there after login.
pyenv activate zhangpeng
@zhangpengGenedock
zhangpengGenedock / gddata_daily_stats_delete_duplicate.js
Created July 7, 2017 04:04
gddata daily stats delete duplicate
var bulk = db.gddata_daily_stats.initializeOrderedBulkOp(),
count = 0;
// List "all" fields that make a document "unique" in the `_id`
// I am only listing some for example purposes to follow
db.gddata_daily_stats.aggregate([
{ "$group": {
"_id": {
"account_name" : "$account_name",
"date": "$date",
@zhangpengGenedock
zhangpengGenedock / group_gddata_daily_stats_account_name_and_date.js
Created July 7, 2017 07:51
group gddata daily stats account name and date
var match = {
'date': {
'$gte': '2017-06-24',
'$lte': '2017-06-30',
}
}
var group = {
'_id': {'account_name':'$account_name','region':'$region'},