Skip to content

Instantly share code, notes, and snippets.

View stanlee321's full-sized avatar

Stanley Salvatierra stanlee321

View GitHub Profile
@stanlee321
stanlee321 / docker-golang-private-repos
Created September 10, 2020 05:12
docker-golang-private-repos
FROM golang
RUN apt-get update && apt-get install -y ca-certificates git-core ssh
ADD keys/my_key_rsa /root/.ssh/id_rsa
RUN chmod 700 /root/.ssh/id_rsa
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
RUN git config --global url.ssh://[email protected]/.insteadOf https://github.com/
ADD . /go/src/github.com/myaccount/myprivaterepo
@stanlee321
stanlee321 / delete-last-remote-commit
Created August 28, 2020 05:07
delete-last-remote-commit
git reset --hard HEAD^
git push origin -f
@stanlee321
stanlee321 / Dockerfile.md
Last active August 19, 2020 22:45
Minitmal docker image for python DataScience

docker image

FROM python:3-alpine
WORKDIR /usr/source/app
COPY requirements.txt ./

RUN apk update
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk --no-cache --update-cache add gcc gfortran build-base wget freetype-dev libpng-dev openblas-dev
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
@stanlee321
stanlee321 / README.md
Last active August 17, 2020 00:07
Install postgress
@stanlee321
stanlee321 / AUX_SQL_QUERIES.md
Last active August 11, 2020 16:41
AUX_SQL_QUERIES.md

Queries

Create Column

ALTER TABLE 
	"fbGroups_posts_clean" 
ADD COLUMN "POST_TAG" "TEXT"
ALTER TABLE 
	"fbGroups_posts_clean" 
@stanlee321
stanlee321 / send_image_post.py
Created July 30, 2020 04:00
HOW TO SEND IMAGE TO A REST API, FLASK
# DEMO CLASS
class PlotTimeSeries:
def __init__(self):
pass
def _find_weekend_indices(self, datetime_array, weekend=5):
"""
Returns all indices of Saturdays & Sundays in a datetime array
datetime_array(pandas) = pandas datetime array
weekend(int) = assume weekend starts at day=5=Saturday
@stanlee321
stanlee321 / add user ssh to ec2 instance
Last active August 12, 2020 15:51
USER SSH ADD TO EC2 and config crontab
$ ssh-keygen -t rsa
$ cat /you/.ssh/id_rsa.pub | ssh -i pem_file.pem [email protected] "cat >> .ssh/authorized_keys"
}
# CRONTAB
# ┌───────────── minute (0 - 59)
$ ls -al ~/.ssh+
# Generate
ssh-keygen -t rsa -b 4096 -C "[email protected]"
# Start the ssh-agent in the background.
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
@stanlee321
stanlee321 / curl_post_json.md
Created July 19, 2020 23:56 — forked from ungoldman/curl_post_json.md
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

@stanlee321
stanlee321 / graph_full_example.py
Created July 7, 2020 22:35
graph_complete_example
def draw_graph3(networkx_graph,notebook=False,output_filename='graph.html',show_buttons=True,only_physics_buttons=False,
height=None,width=None,bgcolor=None,font_color=None,pyvis_options=None):
"""
This function accepts a networkx graph object,
converts it to a pyvis network object preserving its node and edge attributes,
and both returns and saves a dynamic network visualization.
Valid node attributes include:
"size", "value", "title", "x", "y", "label", "color".
(For more info: https://pyvis.readthedocs.io/en/latest/documentation.html#pyvis.network.Network.add_node)
Valid edge attributes include: