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
def get_credential_service_account(): | |
from oauth2client.service_account import ServiceAccountCredentials | |
SERVICE_ACC_CREDENTIAL = 'your-service-account-secrets-file.json' | |
scopes = ['https://www.googleapis.com/auth/drive'] | |
pprint("Request for credential received"); | |
try: | |
credentials = ServiceAccountCredentials.from_json_keyfile_name(SERVICE_ACC_CREDENTIAL, scopes=scopes) | |
pprint(credentials) | |
return credentials |
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
"use strict"; | |
(() => { | |
var console = (window.console = window.console || {}); | |
[ | |
"assert", "clear", "count", "debug", "dir", "dirxml", | |
"error", "exception", "group", "groupCollapsed", "groupEnd", | |
"info", "log", "markTimeline", "profile", "profileEnd", "table", | |
"time", "timeEnd", "timeStamp", "trace", "warn" | |
].forEach(method => { | |
console[method] = () => {}; |
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
// $ node | |
// > process.version; | |
// 'v8.9.4' | |
// > http.STATUS_CODES | |
{ '100': 'Continue', | |
'101': 'Switching Protocols', | |
'102': 'Processing', | |
'200': 'OK', | |
'201': 'Created', |
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
-- Get current date in PST time-zone | |
SELECT DATE_ADD(DATE(CONVERT_TZ(current_time(), 'GMT', 'US/Pacific')); |
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 glob | |
import exifread | |
NAME_LENGTH = 10 | |
jpg_files = glob.glob('*.jpg') | |
for a_file in jpg_files: | |
try: |
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
function getBrowser() { | |
var nVer = navigator.appVersion; | |
var nAgt = navigator.userAgent; | |
var browserName = navigator.appName; | |
var fullVersion = '' + parseFloat(navigator.appVersion); | |
var majorVersion = parseInt(navigator.appVersion, 10); | |
var nameOffset, verOffset, ix; | |
// In Opera, the true version is after "Opera" or after "Version" | |
if ((verOffset = nAgt.indexOf("Opera")) != -1) { |
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
#### after the above custom my.cnf, add this at the Dockerfile | |
FROM mysql:latest | |
COPY ./custom-mysql.cnf /etc/mysql/conf.d/ | |
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
# src: https://stackoverflow.com/a/12424439/617185 | |
def send_email(user, password, recipient, subject, body): | |
import smtplib | |
FROM = user | |
TO = recipient if type(recipient) is list else [recipient] | |
SUBJECT = subject | |
TEXT = body |
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
def copy_file_to_folder(file_id, new_folder_id, move=False): | |
# acquiring credentials | |
# for credential function, please refer to: https://gist.github.com/kmonsoor/d89c930a8df3060106c04648dc6058b0 | |
try: | |
drive_service = discovery.build('drive', 'v3', credentials = get_credential_service_account()) | |
except Exception as e: | |
print("File copy/move failed due to failed acquire credentials") | |
raise | |
if move: |
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
# MariaDB 10.2 CentOS repository list - created 2017-09-17 13:42 UTC | |
# http://downloads.mariadb.org/mariadb/repositories/ | |
[mariadb] | |
name = MariaDB | |
baseurl = http://yum.mariadb.org/10.2/centos7-amd64 | |
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB | |
gpgcheck=1 |