Skip to content

Instantly share code, notes, and snippets.

@shreyasms17
shreyasms17 / execute_autoflatten_complex.py
Last active September 2, 2022 10:22
AutoFlatten Complex JSON
from pyspark.sql.functions import col, explode_outer
from pyspark.sql.types import *
from copy import deepcopy
from autoflatten import AutoFlatten
from collections import Counter
s3_path = 's3://mybucket/orders/'
df = spark.read.orc(s3_path)
json_df = spark.read.json(df.rdd.map(lambda row: row.json))
json_schema = json_df.schema
@shreyasms17
shreyasms17 / autoflatten.py
Last active December 12, 2022 20:40
AutoFlatten
import json
class AutoFlatten:
def __init__(self, json_schema):
self.fields_in_json = self.get_fields_in_json(json_schema)
self.all_fields = {}
self.cols_to_explode = set()
self.structure = {}
self.order = []
self.bottom_to_top = {}
@mrchristine
mrchristine / spark_schema_save_n_load.py
Created May 28, 2019 21:12
Read / Write Spark Schema to JSON
##### READ SPARK DATAFRAME
df = spark.read.option("header", "true").option("inferSchema", "true").csv(fname)
# store the schema from the CSV w/ the header in the first file, and infer the types for the columns
df_schema = df.schema
##### SAVE JSON SCHEMA INTO S3 / BLOB STORAGE
# save the schema to load from the streaming job, which we will load during the next job
dbutils.fs.rm("/home/mwc/airline_schema.json", True)
with open("/dbfs/home/mwc/airline_schema.json", "w") as f:
@kevin-smets
kevin-smets / 1_kubernetes_on_macOS.md
Last active May 5, 2024 10:12
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@Pusnow
Pusnow / 한글과유니코드.md
Last active July 22, 2024 04:03
한글과 유니코드

한글과 유니코드

유니코드에서 한글을 어떻게 다루는지를 정리하였다.

유니코드

  • 유니코드(Unicode)는 전 세계의 모든 문자를 컴퓨터에서 일관되게 표현하고 다룰 수 있도록 설계된 산업 표준 (위키 백과)
  • 단순히 문자마다 번호를 붙임
  • 계속 업데이트되며 현재는 Unicode Version 9.0.0 이 최신이다.

UTF

  • 유니코드를 실제 파일 등에 어떻게 기록할 것인지를 표준화한 것이다.
@qgp9
qgp9 / tmon.sh
Last active August 8, 2016 15:13
monitoring with tmux
#!/bin/bash
com=${1:-"htop"}
tname=mon
twin=mon
tnw=$tname:$twin
tmux has-session -t $tname
if [ $? != 0 ]
then
tmux new-session -s $tname -n $twin -d ssh -t a1 "$com"
@dlstadther
dlstadther / example_redshift_copy.py
Last active June 9, 2021 07:35
Using Luigi's Redshift and S3
# import luigi modules
import luigi
from luigi.contrib import redshift
from luigi import configuration, s3
# import python core modules
import os
import shutil
import datetime
@haje01
haje01 / 도커와 AWS를 활용한 클라우드 딥러닝 환경 구축.md
Last active December 20, 2020 08:56
도커와 AWS를 활용한 클라우드 딥러닝 환경 구축

도커와 AWS를 활용한 클라우드 딥러닝 환경 구축

글쓴이: 김정주(haje01@gmail.com)

최근 딥러닝 관련 패키지들은 대부분 CPU와 GPU를 함께 지원하고 있습니다. GPU를 사용하면 보다 빠르게 학습 결과를 낼 수 있지만, GPU를 활용하기 위해서는 NVIDIA계열의 그래픽 카드, 드라이버 S/W 그리고 CUDA의 설치를 필요로 합니다.

이 글에서는 AWS의 GPU 인스턴스와 도커를 활용해 딥러닝 패키지(Caffe)를 편리하게 사용하는 방법을 소개합니다.


@ihoneymon
ihoneymon / springboot-introduction.md
Last active October 14, 2022 08:44
스프링부트 소개

스프링부트 소개

0. 스프링부트SpringBoot란?

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.

  • 스프링부트는 단독실행되는, 실행하기만 하면 되는 상용화 가능한 수준의, 스프링 기반 애플리케이션을 쉽게 만들어낼 수 있다.
  • 최소한의 설정으로 스프링 플랫폼과 서드파티 라이브러리들을 사용할 수 있도록 하고 있다.