Skip to content

Instantly share code, notes, and snippets.

View feifangit's full-sized avatar

Fan Fei feifangit

  • PANW
  • Santa Clara , CA
View GitHub Profile
@feifangit
feifangit / hw54.js
Last active December 24, 2015 23:29
MongoDB university M101P HW5.4
db.zips.aggregate([
{$project:
{
fc: {$substr : ["$city",0,1]},
city:1,pop:1
}
},
{$match:{fc:{$lte:"9",$gte:"0"}}} ,
{
$group: {
@feifangit
feifangit / hw53.js
Created October 8, 2013 07:40
MongoDB university M101P HW5.3
db.stud.aggregate([
{$match:{"scores.type":{$in:["exam","homework"]}}},
{$unwind:"$scores"},
{$group:{_id:"$class_id",csall:{$avg:"$scores.score"}}},
{$sort:{csall:-1}},
{$limit:5}
]
)
@feifangit
feifangit / restart_heroku.py
Last active December 31, 2015 16:39
restart heroku apps
import heroku
HEROKU_TOKEN = "xx-xx-xx" #used for instance restart
APP_NAME = "xxx"
def restart_heroku(auto=False):
'''restart heroku instance to re-allocate IP'''
cloud = heroku.from_key(HEROKU_TOKEN)
app = cloud.apps[APP_NAME]
for p in app.processes:
p.restart()