-
Notifications
You must be signed in to change notification settings - Fork 19
/
python.json
75 lines (75 loc) · 2.15 KB
/
python.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
// copy these snippets into %appdata%\code\user\snippets\python.json
"StackOverflow: download survey": {
"prefix": "sodownload",
"body": [
"import requests",
"data = requests.get('https://drive.google.com/uc?export=download&id=0B6ZlG_Eygdj-c1kzcmUxN05VUXM')",
"with open('survey2017.zip', 'wb') as file:",
"\tfile.write(data.content)",
""
],
"description": "StackOverflow Demo: download surveyss"
},
"StackOverflow: unzip survey": {
"prefix": "sounzip",
"body": [
"import zipfile",
"with zipfile.ZipFile('survey2017.zip') as zip:",
"\tzip.extractall('survey2017')",
""
],
"description": "StackOverflow Demo: unzip survey"
},
"StackOverflow: cleanup files": {
"prefix": "socleanup",
"body": [
"import shutil, os",
"shutil.move('survey2017/survey_results_public.csv', 'survey2017.csv')",
"shutil.rmtree('survey2017')",
"os.remove('survey2017.zip')",
""
],
"description": "StackOverflow Demo: cleanup files"
},
"StackOverflow: fix totals": {
"prefix": "sototal",
"body": [
"if year < 2016:",
"\tnotNull = languages.apply(lambda x: pd.notnull(x)).sum(axis=1)",
"\ttotal = notNull[notNull > 0].shape[0]"
],
"description": "StackOverflow Demo: fix totals for surveys pre 2016"
},
"StackOverflow: extract files": {
"prefix": "soextract",
"body": [
"import zipfile",
"with zipfile.ZipFile('survey2017.zip') as zip:",
"\tzip.extractall('survey2017')\n",
"import shutil, os",
"shutil.move('survey2017/survey_results_public.csv', '${0:survey2017}.csv')",
"shutil.rmtree('survey2017')",
"os.remove('survey2017.zip')",
""
],
"description": "StackOverflow Demo: cleanup files"
},
"todo": {
"prefix": "todo",
"body": ["# TODO $CURRENT_MONTH_NAME $CURRENT_DATE, $CURRENT_YEAR: "]
},
"Flask App": {
"prefix": "flaskapp",
"body": [
"from flask import Flask, render_template",
"app = Flask(__name__)\n",
"@app.route('/')",
"def index():",
"\treturn render_template('index.html')\n",
"if __name__ == '__main__':",
"\tapp.run(host='0.0.0.0', port=8000, debug=True)"
],
"description": "Basic flask app"
}
}