Skip to content

Instantly share code, notes, and snippets.

View JohnnyFang's full-sized avatar
👨‍💻
working on improvin' my skills!

Johnny Fang JohnnyFang

👨‍💻
working on improvin' my skills!
View GitHub Profile
@JohnnyFang
JohnnyFang / GnuPG-2.2.md
Last active August 19, 2022 10:42 — forked from vt0r/GnuPG-2.2.md
Build/install instructions for GnuPG 2.2.x on Ubuntu and similar distros (formerly for 2.1.x)

GnuPG 2.2.x Build Instructions

Below are my build instructions for GnuPG 2.2.10, released on August 30th, 2018. These instructions are built for a headless Ubuntu 18.04 LTS server (and have also been tested on Ubuntu 14.04/16.04).

If you prefer, you may use the below install script to install GnuPG 2.2.x by running the following commands:

curl -OL "https://gist.githubusercontent.com/JohnnyFang/ca2f243a9adb179186e5932c9c1445d0/raw/a2d4ca7056f9908d0f856acff7d2b466a99306ff/install-gnupg22.sh" && sudo -H bash ./install-gnupg22.sh

Install the needed dependencies

@JohnnyFang
JohnnyFang / load_explore_data.py
Created April 28, 2019 00:36
loading zomato json restaurant data
path ="datasets/"
files = ["file1.json", "file2.json", "file3.json", "file4.json", "file5.json"]
column_names = ["restaurant.id", "restaurant.name", "restaurant.cuisines", "restaurant.location.city",
"restaurant.location.address", "restaurant.location.latitude",
"restaurant.location.longitude", "restaurant.user_rating.rating_text"]
new_col_names = ["id", "name", "cuisines", "city", "address", "latitude", "longitude", "rating_text"]
dataset = pd.DataFrame()
for file in files:
file_path = path + file
@JohnnyFang
JohnnyFang / normalize_json.py
Last active April 27, 2019 23:40
flatten nested json data using pandas' json_normalize
column_names = ["restaurant.id", "restaurant.name", "restaurant.cuisines", "restaurant.location.city",
"restaurant.location.address", "restaurant.location.latitude",
"restaurant.location.longitude", "restaurant.user_rating.rating_text"]
new_col_names = ["id", "name", "cuisines", "city", "address", "latitude", "longitude", "rating_text"]
if 'restaurants' in el and len(el['restaurants']):
df = pd.concat([pd.DataFrame(json_normalize(restaurant)) for restaurant in el['restaurants']])
restaurants_df = df[[col for col in column_names]]
restaurants_df.rename(columns=dict(zip(column_names, new_col_names)), inplace=True)
@JohnnyFang
JohnnyFang / load_explore_json_data.py
Last active April 27, 2019 22:28
loading json files (python 3)
path = "datasets/"
files = ["file1.json", "file2.json", "file3.json", "file4.json", "file5.json"]
for file in files:
file_path = path + file
with open(file_path) as f:
json_data = json.load(f)
for el in json_data:
# we check that 'restaurants' exists and it contains data
if 'restaurants' in el and len(el['restaurants']):
# Do something with our restaurant data
@JohnnyFang
JohnnyFang / sensor.py
Created March 14, 2019 23:40
iterator for streamed data coming from fictional sensor - Extended iter() format lesson
import datetime
import itertools
import random
class Sensor:
def __iter__(self):
return self
def __next__(self):
return random.random()
@JohnnyFang
JohnnyFang / BubbleSort.java
Created February 21, 2019 17:41
BubbleSort
//*******************************************************************
// Welcome to CompileJava!
// If you experience any issues, please contact us ('More Info') -->
// Also, sorry that the "Paste" feature no longer works! GitHub broke
// this (so we'll switch to a new provider): https://blog.github.com\
// /2018-02-18-deprecation-notice-removing-anonymous-gist-creation/
//*******************************************************************
import java.lang.Math; // headers MUST be above the first class
@JohnnyFang
JohnnyFang / views.py
Created December 29, 2018 01:18
Flask todo list app - todo_api views.py
# app/todo_api/views.py
from flask import request, jsonify, Response
from app import db
from app.models import Todo, TodoSchema
from . import todo_api
todo_schema = TodoSchema()
todos_schema = TodoSchema(many=True)
@JohnnyFang
JohnnyFang / views.py
Created December 29, 2018 00:54
Flask todo app - webapp views.py
# app/webapp/views.py
from flask import render_template
from app.models import Todo
from . import webapp
@webapp.route('/')
def index():
all_todos = Todo.query.all()
@JohnnyFang
JohnnyFang / __init__.py
Created December 29, 2018 00:49
Flask todo app todo_api blueprint initialization
# app/todo_api/__init__.py
from flask import Blueprint
todo_api = Blueprint('todo_api', __name__)
from . import views
@JohnnyFang
JohnnyFang / __init__.py
Created December 29, 2018 00:42
Flask todo app webapp blueprint initialization
# app/webapp/__init__.py
from flask import Blueprint
webapp = Blueprint('webapp', __name__)
from . import views