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 csv | |
csv_connection = open("predict.csv", "wb") | |
f = csv.writer(csv_connection) | |
f.writerow(["pk", "dt", "name", "temp", "humidity", "smv", "trigger"]) | |
f.writerow(["pk111", "dt1111", "name1111", "temp1111", "humidity1111", "smv1111", "trigger1111"]) | |
f.writerow(["pk111", "dt1111", "name3331", "temp3331", "humidity3331", "smv3331", "trigger3331"]) | |
csv_connection.close() |
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
# in settings.py | |
DEFAULT_FILE_STORAGE = 'appengine_toolkit.storage.GoogleCloudStorage' | |
APPENGINE_TOOLKIT = { | |
'BUCKET_NAME': 'XXXXXX', | |
} | |
################### | |
# save 1 | |
uploaded_file = request.FILES.get('file_' + str(i)) |
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
# settings.py | |
def get_app_credentials(): | |
import io | |
import json | |
from google.oauth2 import service_account | |
json_credentials_path = 'xxxxxx.json' | |
with io.open(json_credentials_path, 'r', encoding='utf-8') as json_fi: | |
credentials_info = json.load(json_fi) | |
credentials = service_account.Credentials.from_service_account_info(credentials_info) |
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
private String connectToServer(String urlConnection) throws Exception{ | |
Request request = new Request.Builder().url(urlConnection).build(); | |
OkHttpClient client = new OkHttpClient(); | |
Response response = client.newCall(request).execute(); | |
String jsonData = response.body().string(); | |
Log.d("JSON STRING_DATA", jsonData); | |
return jsonData; | |
} |
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 django.core.files.storage import default_storage | |
print default_storage.__class__ | |
from django.core.files.base import ContentFile | |
import io | |
import random | |
def generate_photo_file(): | |
from PIL import Image |
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 requests | |
import DotMap | |
from httplib import OK | |
import logging | |
def get_accounts_no_meta_data(): | |
""" | |
https://app.beyonic.com/api/collectionrequests -H "Authorization: Token XXXX" | |
beyonic collection requests that dont have meta field | |
""" |
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 requests | |
r = requests.post(url='http://35.227.57.118/graphql/', json={"query": "{links {url}}"}) | |
print(r.status_code) | |
print(r.content) | |
if r.status_code == 200 or r.status_code == 201: | |
r_json = r.json() | |
data = r_json['data'] | |
links = data['links'] |
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
curl \ | |
-X POST \ | |
-H "Content-Type: application/json" \ | |
--data '{"query": "{links {url}}"}' \ | |
http:///35.227.57.118/graphql/ |
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 mysql.connector | |
mydb = mysql.connector.connect( | |
host="127.0.0.1", | |
user="root", | |
passwd="XXXXXX" | |
) | |
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 | |
## Modification of https://almcc.me/blog/2017/05/04/removing-older-versions-on-google-app-engine/ | |
## to allow deletion of of old app versions, leaving only version per service | |
## define all your services | |
declare -a arr=("default" "sellio-clients" "ad-manager" "sellio-test" "unified-bot" "momo" "healthcheck") | |
echo 'started' | |
## now loop through the above array | |
for i in "${arr[@]}" |