Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Molnar soobrosa

View GitHub Profile
@soobrosa
soobrosa / recipe.sh
Created May 4, 2021
Two commands that got me closer to the nested things.
View recipe.sh
cat recipes_vegan.json | jq '.recipes[].extendedIngredients[]' | jq '[.id,.aisle,.image,.consistency,.name,.nameClean,.original,.originalString,.originalName,.amount,.unit,.meta[],.metaInformation[],.measures.metric.amount,.measures.metric.unitShort,.measures.metric.unitLong]' -c
cat recipes_vegan.json | jq '.recipes[].analyzedInstructions[].steps[]' | jq '[.number, .step, .ingredients[].id, .ingredients[].name, .ingredients[].localizedName, .ingredients[].image]' -c
View redshift_json_udf.sql
CREATE OR REPLACE FUNCTION CLEAN_DEEP_JSON (j VARCHAR(65535), f VARCHAR(65535))
RETURNS VARCHAR(MAX)
STABLE AS $$
import json
if not j:
return None
try:
arr = json.loads(j)
except valueerror:
return None
@soobrosa
soobrosa / install_opencv_rpi.sh
Last active Sep 26, 2017
Install OpenCV on a Raspbian Jessie
View install_opencv_rpi.sh
# thanks to
# https://medium.com/r/?url=https%3A%2F%2Fncsforum.movidius.com%2Fdiscussion%2Fcomment%2F299%2F%23Comment%5C_299
# https://ahmedibrahimvt.wordpress.com/2017/02/19/fatal-error-hdf5-h-no-such-file-or-directory/
# http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
@soobrosa
soobrosa / install_caffe_rpi.sh
Created Sep 4, 2017
Caffe install + benchmark script for Raspbian Jessie
View install_caffe_rpi.sh
# tested on a Raspbery Pi 3 running a Raspbian Jessie July 2017
# dependencies
apt-get update
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install libopenblas-dev
sudo apt-get install libatlas-base-dev
@soobrosa
soobrosa / install_caffe_osx.sh
Last active Jun 16, 2018
Caffe install + benchmark script for OSX
View install_caffe_osx.sh
# tested on Macbook Air 13", early 2015, 1,6 Ghz Intel Core i5, 8Gb RAM running macOS Sierra
# if you don't have brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
# dependencies
brew install -vd snappy leveldb gflags glog szip lmdb
brew tap homebrew/science
brew install hdf5 opencv
@soobrosa
soobrosa / export_spotify_tracks_you_liked.sh
Last active Feb 15, 2016
Own your list of favourite tracks on Spotify
View export_spotify_tracks_you_liked.sh
#!/bin/bash
#
# you need
# https://github.com/jehiah/json2csv and
# https://stedolan.github.io/jq/
# to roll like this
#
# get your token at https://developer.spotify.com/web-api/console/get-current-user-saved-tracks/
#
@soobrosa
soobrosa / Makefile
Created Nov 20, 2015
Is Yelp international?
View Makefile
source.downloaded:
mkdir source
cd source && { curl -O "https://d396qusza40orc.cloudfront.net/dsscapstone/dataset/yelp_dataset_challenge_academic_dataset.zip" ; cd -; }
source.decompressed: source.downloaded
unzip source/yelp_dataset_challenge_academic_dataset.zip
#
# one record pretty printed from each file composed of lines of JSONs
#
@soobrosa
soobrosa / extract_db_from_twb.py
Last active Aug 29, 2015
Extract database connections from Tableau workbooks
View extract_db_from_twb.py
# parses directories for .twb files
# and extracts database connections
# rough and dirty
import os
for root, dirs, files in os.walk('.'):
for file in files:
if file.endswith('.twb'):
f = open(root + '/' + file)
View csv_to_google_sheets.py
# Usage:
# python push_to_google_sheets.py filename.csv sheet_name
#
# In case your Google Account protected
# with Two Factor Authorization,
# you have to create an application-specific password
# and use your email to login as usual.
# https://accounts.google.com/b/0/IssuedAuthSubTokens?hl=en_GB
#
# Dependency: