Skip to content

Instantly share code, notes, and snippets.

@fcharmy
fcharmy / Dockerfile
Last active August 31, 2018 07:56
mongodb-4.0.2
FROM python:3.7
RUN wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.2.tgz
RUN tar -zxvf mongodb-*.tgz
RUN rm mongodb-*.tgz
RUN mkdir -p /data/db
ENV PATH="/mongodb-linux-x86_64-4.0.2/bin:${PATH}"
EXPOSE 27017
ENTRYPOINT ["mongod"]
@fcharmy
fcharmy / connection.py
Created September 13, 2018 08:55
sqlalchemy models
import logging
from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.engine import reflection
from sqlalchemy.orm import mapper, sessionmaker
logger = logging.getLogger(__name__)
def get_session(host=None, port=3306, db=None,
@fcharmy
fcharmy / sync_git.sh
Created September 13, 2018 09:02
auto sync github repository for whole repo or given certain directories
#!/usr/bin/env bash
# To keep updating codes from git repository
#
# feng.charmy@gmail.com
# Nothe: please make sure git config has read permission of repository
#
# Usage ./sync_dags.sh git@github.com:user/repo.git branch_name\
# -t interval_in_seconds\
# -d sparse_checkout_directory(optional) -d more_sparse_checkout_directory ..\
# -e execute_command_after_sync
@fcharmy
fcharmy / ig_scrapy_spider.py
Last active September 26, 2018 10:04
Crawl IG hashtag posts including post link, main images url, thumbnail, is_video, username, likes, caption, posted time, user profile image url. Only show the spider implementation, pipeline need to be implement separately.
import json
import urllib.parse as urlparse
from scrapy import Item, Field, Spider, Request
from scrapy.exceptions import CloseSpider
# ------ Instagram settings ------
IG_SERVER = "https://www.instagram.com"
IG_PATH = '/explore/tags/'
IG_POST_PATH = "p/"
{
"metric": [
"prec_rec_f1"
],
"image": [
{
"image": {
"im_id": "xxx",
"width": 512,
"height": 512
{
"overview": {
"concept_group_names": [
"category",
"sleeve_length",
"pattern"
],
"metrics": {
"prec_rec_f1": {
"type": "table",
{
"metric": [
"acc_1"
],
"image": [
{
"image": {
"im_id": "xxx",
"width": 512,
"height": 512
{
"overview": {
"concept_group_names": [
"category",
"sleeve_length",
"pattern"
]
},
"results": [
{
{
"metric": [
"confusion_matrix"
],
"image": [
{
"image": {
"im_id": "xxx",
"width": 512,
"height": 512
{
"metric": [
"pr_curve"
],
"image": [
{
"image": {
"im_id": "xxx",
"width": 512,
"height": 512