Skip to content

Instantly share code, notes, and snippets.

😁

Andrea Parisi devhero

😁
Block or report user

Report or block devhero

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@devhero
devhero / python sqlite3 pyenv macos
Created Jun 26, 2019
python_sqlite3_pyenv_macos
View python sqlite3 pyenv macos
# https://github.com/pyenv/pyenv/issues/108
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.6.8
@devhero
devhero / python_build_failed_mojave
Created Jun 5, 2019
python build failed macos mojave #build #python #macos
View python_build_failed_mojave
# BUILD FAILED (OS X 10.14.5 using python-build ...)
# zipimport.ZipImportError: can't decompress data; zlib not available
brew install zlib
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"
export KEEP_BUILD_PATH=true
@devhero
devhero / virtualbox_access_guest_ip
Created Mar 22, 2019
virtualbox access guest ip
View virtualbox_access_guest_ip
# VirtualBox
# 1. add network adapter
# 2. select: host-only
# 3. select: vboxnet0
# centos
cd /etc/sysconfig/network-scripts/
cp ifcfg-enp0s3 ifcfg-enp0s8
View array_compare.js
array1.length === array2.length && array1.sort().every(function(value, index) { return value === array2.sort()[index]});
@devhero
devhero / recursive_op_key.py
Created Oct 24, 2018
recursive operation on key
View recursive_op_key.py
def lower(obj):
return obj.lower()
def lower_dict(obj):
return _recursive_key_op(obj, lower)
def _recursive_key_op(obj, op=None):
if isinstance(obj, dict):
return {op(k): _recursive_key_op(v, op) for k, v in obj.items()}
elif isinstance(obj, (list, set, tuple)):
@devhero
devhero / flask_tips
Last active Feb 1, 2019
flask tips
View flask_tips
# from http://flask.pocoo.org/docs/1.0/cli/
# Setting Command Options
# Click is configured to load default values for command options from environment variables. The variables use the pattern FLASK_COMMAND_OPTION. For example, to set the port for the run command, instead of flask run --port 8000:
export FLASK_RUN_PORT=8000
flask run
* Running on http://127.0.0.1:8000/
@devhero
devhero / jest_webpack_babel
Last active Jun 15, 2018
jest webpack babel
View jest_webpack_babel
// https://redux.js.org/recipes/writing-tests
// https://facebook.github.io/jest/docs/en/webpack.html
npm i -D jest babel-jest transform-es2015-modules-commonjs
// package.json
{
...
"jest": {
@devhero
devhero / babel_unexpected_token
Created May 22, 2018
ERROR in ./index.js Module build failed: SyntaxError: Unexpected token
View babel_unexpected_token
// https://stackoverflow.com/questions/34614812/error-in-index-js-module-build-failed-syntaxerror-unexpected-token#34619867
// .babelrc
{
"presets": [
"react",
"env"
],
"plugins": [
@devhero
devhero / image_conversion_svg_png
Created May 11, 2018
image conversion svg to png
View image_conversion_svg_png
rsvg-convert img.svg > img.png
rsvg-convert -h 256 img.svg > img.png
@devhero
devhero / django_client_request_testing
Created Apr 30, 2018
django client request testing
View django_client_request_testing
from django.test.client import Client
client = Client()
response = client.get(some_url)
request = response.wsgi_request
You can’t perform that action at this time.