Skip to content

Instantly share code, notes, and snippets.

@antonga23
antonga23 / laravellocal.md
Created May 15, 2020 10:38 — forked from hootlex/laravellocal.md
Run laravel project locally

##Windows users:

cmder will be refered as console

##Mac Os, Ubuntu and windows users continue here:

  • Create a database locally named homestead utf8_general_ci
@antonga23
antonga23 / requirements.txt
Last active May 29, 2020 12:17
Python package requiremnts for blink on Ubuntu 18 LTS running python 2.7
amqp==2.5.2
asn1crypto==0.24.0
attrs==19.3.0
Automat==20.2.0
beautifulsoup4==4.6.0
billiard==3.6.3.0
blink==3.2.1
cachetools==3.1.1
celery==4.4.2
certifi==2020.4.5.1
@antonga23
antonga23 / extract_json_values.py
Created October 29, 2020 09:37
A useful python function for extracting the values in a key-value-pair, from a JSON object
def json_extract(obj, key):
"""Recursively fetch values from nested JSON."""
arr = []
def extract(obj, arr, key):
"""Recursively search for values of key in JSON tree."""
if isinstance(obj, dict):
for k, v in obj.items():
if isinstance(v, (dict, list)):
extract(v, arr, key)
@antonga23
antonga23 / gist:5657c3bc78ac319be1a1f8acdd070602
Created October 29, 2020 13:57 — forked from c0ldlimit/gist:5164171
#python #flask #pandas Using flask to return a csv response from a dataframe
import StringIO
from flask import Flask, Response
@app.route('/some_dataframe.csv')
def output_dataframe_csv():
output = StringIO.StringIO()
some_dataframe.to_csv(output)
@antonga23
antonga23 / csv_to_flask.py
Created November 10, 2020 10:10 — forked from dasdachs/csv_to_flask.py
Upload, read and save the content of a csv file to your model
#!/usr/bin/env python
from io import TextIOWrapper
import csv
from flask import Flask, request, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
# Create Flaskk app, config the db and load the db object
# http://flask-sqlalchemy.pocoo.org/2.1/quickstart/#a-minimal-application
@antonga23
antonga23 / forwardport.sh
Created November 18, 2020 19:32 — forked from debashisbarman/forwardport.sh
Forward port 80 to 8080 on EC2 instance.
sudo iptables -t nat -L
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000
#!/usr/bin/env bash
docker run --rm --ulimit nofile=65536:65536 --name esn01 -p 9200:9200 -v esdata01:/usr/share/elasticsearch/data --network elastic-network -e "node.name=esn01" -e "cluster.name=es-cluster" -e "cluster.initial_master_nodes=esn01" -e "bootstrap.memory_lock=true" --ulimit memlock=-1:-1 -e ES_JAVA_OPTS="-Xms2g -Xmx2g" docker.elastic.co/elasticsearch/elasticsearch:7.3.0
# Create the master node for our cluster
# NB we increase max file descriptors to 65536 using the nofile argument
# Expected Output should be similar to this
docker rm -f $(docker ps -a -q)
driver.get('chrome://settings/')
driver.execute_script('chrome.settingsPrivate.setDefaultZoom(zoomValue);')
@antonga23
antonga23 / dig.py
Created April 7, 2021 16:03
With the following small function, digging into a tree-shaped dictionary becomes quite easy:
def dig(tree, path):
for key in path.split("."):
if isinstance(tree, dict) and tree.get(key):
tree = tree[key]
else:
return None
return tree
#EXAMPLE
# mydict = {