Skip to content

Instantly share code, notes, and snippets.

View kokospapa8's full-sized avatar
🐕
koko

Jinwook Baek kokospapa8

🐕
koko
View GitHub Profile
from django.core.cache import cache, caches
from django.conf import settings
from django.db.models.query import QuerySet
DEFAULT_CACHE_ALIAS = 'default'
def _get_cache(cache_alias):
# did this because debug toolbar does not track caches when not using just cache.
# So, caches["default"] is not tracked
@kokospapa8
kokospapa8 / LogsToBQLambda
Last active January 28, 2021 18:15
CloudWatchToBigQuery Lambda Code
import os
import json
import zlib
from base64 import b64decode
from google.cloud import bigquery
from google.oauth2 import service_account
TABLE_NAME = "<project_id>.<dataset>.<table-name>"
@kokospapa8
kokospapa8 / .vimrc
Created December 21, 2020 01:19
vimrc conf
set hls ic is nu noswf
set hlsearch " 모든 검색결과 하이라이트
set ignorecase " 대소문자 무시하고 검색
set incsearch " 타이핑할 때마다 검색 결과 표시
set number " 줄번호 표시
set noswapfile " 스왑파일 사용안함
set smartcase
@kokospapa8
kokospapa8 / file_load_to_bq.py
Last active December 14, 2020 05:25
BigQuery for Data Warehousing - Chapter5 - Load Files to BQ using Python SDK
# Load BigQuery from the Python GCP Library
from google.cloud import bigquery
# Load a performance timer (optional or comment out)
from timeit import default_timer as timer
# Specify your fully-qualified table name as you would in the UI
import_table = 'YOUR-DATASET.bortdata.bookdata'
# Choose the GCS bucket and file, or override it with a full gs:// URI
gcs_bucket = 'YOUR-BUCKET'
gcs_file = 'book-data.csv'
# gs://mybucket/book-data.csv OR local file ./book-data.csv
@kokospapa8
kokospapa8 / gist:2c308a76b7565e55ec17f194fceba153
Created September 3, 2020 15:55
QWIKLAB GSP653 SOLUTION
<!DOCTYPE html>
<html>
<!--
Copyright 2016 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@kokospapa8
kokospapa8 / GSP330.txt
Last active August 30, 2020 15:45
GSP 330
Task1
# SSH into jumphost
cd /work/sample-app
gcloud config set compute/zone us-east1-d
gcloud container clusters get-credentials jenkins-cd --zone us-east1-b
kubectl create ns production
kubectl apply -f k8s/production -n production
kubectl apply -f k8s/canary -n production
kubectl apply -f k8s/services -n production
1)
```
CREATE OR REPLACE TABLE taxirides.taxi_training_data (
`pickup_datetime` TIMESTAMP,
`pickuplon` FLOAT64,
`pickuplat` FLOAT64,
`dropofflon` FLOAT64,
`dropofflat` FLOAT64,
`passengers` FLOAT64,
`fare_amount` FLOAT64
@kokospapa8
kokospapa8 / analyze_text.py
Created August 30, 2020 04:24
Qwiklab - GSP329 solution
# https://google.qwiklabs.com/focuses/12704?parent=catalog
# Dataset: image_classification_dataset
# Table name: image_text_detail
import os
import sys
# Import Google Cloud Library modules
from google.cloud import storage, bigquery, language, vision, translate_v2
if ('GOOGLE_APPLICATION_CREDENTIALS' in os.environ):
@kokospapa8
kokospapa8 / notion2blog.js
Created July 2, 2020 09:14 — forked from mayneyao/notion2blog.js
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
# Get a local Shell of container
docker run -i -t --entrypoint /bin/bash imageID
# Create image using this directory's Dockerfile
docker build -t friendlyname .
# Run "friendlyname" mapping port 4000 to 80
docker run -p 4000:80 friendlyname
# Same thing, but in detached mode
docker run -d -p 4000:80 friendlyname
# See a list of all running containers
docker ps