Skip to content

Instantly share code, notes, and snippets.

View emptymalei's full-sized avatar
📡
sending EM waves to Mars

LM emptymalei

📡
sending EM waves to Mars
View GitHub Profile
@emptymalei
emptymalei / How to install redash in mac.
Last active November 20, 2019 09:26 — forked from deepak365/How to install redash in mac.
How to install redash in mac.
What is redash?
Redash is database viewer included BI tool inside. Redash has support for querying multiple databases, including: Redshift, Google BigQuery, PostgreSQL, MySQL, Graphite, Presto, Google Spreadsheets, Cloudera Impala, Hive and custom scripts.
Prerequisite :
1. Install docker
2. Install git
git clone https://github.com/getredash/redash.git
docker-compose -f docker-compose.production.yml run --rm server create_db
docker-compose -f docker-compose.production.yml up
@emptymalei
emptymalei / property_inheritance.md
Created September 6, 2019 09:21 — forked from Susensio/property_inheritance.md
Inherit property setter in python 3.7

Python @property inheritance the right way

Given a Parent class with value property, Child can inherit and overload the property while accessing Parent property getter and setter.

Although we could just reimplement the Child.value property logic completely without using Parent.value whatsover, this would violate the DRY principle and, more important, it wouldn't allow for proper multiple inheritance (as show in the example property_inheritance.py bellow).

Two options:

  • Child redefines value property completely, both getter and setter.
@emptymalei
emptymalei / execute myself
Created August 13, 2019 14:10
weird python
python
import os
__cwd__ = os.getcwd()
__location__ = os.path.realpath(
os.path.join(__cwd__, os.path.dirname(__file__))
)
print(f'location: {__location__}')
print(f'filename: {__file__}')
Solving environment: done
## Package Plan ##
environment location: /Users/leima/anaconda3
removed specs:
- numpy
User_ID Calories
14733363 231.0
14861698 66.0
11179863 26.0
16180408 71.0
17771927 35.0
15130815 123.0
19602372 112.0
11117088 143.0
12132339 134.0
@emptymalei
emptymalei / python request module
Created June 3, 2019 20:12
GIST created by python code
Python requests has 3 parameters: 1)Request URL
2)Header Fields
3)Parameter
4)Request body
@emptymalei
emptymalei / gm_2008_region.csv
Created June 3, 2019 17:48
regression_data_sample
population fertility HIV CO2 BMI_male GDP BMI_female life child_mortality Region
34811059.0 2.73 0.1 3.328944661018629 24.5962 12314.0 129.9049 75.3 29.5 Middle East & North Africa
19842251.0 6.43 2.0 1.4743533878509398 22.25083 7103.0 130.1247 58.3 192.0 Sub-Saharan Africa
40381860.0 2.24 0.5 4.78516998252535 27.5017 14646.0 118.8915 75.5 15.4 America
2975029.0 1.4 0.1 1.8041062172001 25.35542 7383.0 132.8108 72.5 20.0 Europe & Central Asia
21370348.0 1.96 0.1 18.0163132681972 27.56373 41312.0 117.3755 81.5 5.2 East Asia & Pacific
8331465.0 1.41 0.3 8.18316001754696 26.46741 43952.0 124.1394 80.4 4.6 Europe & Central Asia
8868713.0 1.99 0.1 5.10953829181389 25.65117 14365.0 128.6024 70.6 43.3 Europe & Central Asia
348587.0 1.89 3.1 3.13192132134112 27.24594 24373.0 124.3862 72.2 14.5 America
148252473.0 2.38 0.06 0.31916100201885805 20.39742 2265.0 125.0307 68.4 55.9 South Asia
# This is a really old post, in the comments (and stackoverflow too) you'll find better solutions.
def find(key, dictionary):
for k, v in dictionary.iteritems():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
@emptymalei
emptymalei / perlbrew_libgcc_s.txt
Created May 8, 2019 18:14 — forked from Dreyer/perlbrew_libgcc_s.txt
[perlbrew] ld: library not found for -lgcc_s.10.4
$ cd /usr/local/lib
$ sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib
$ sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.4.dylib
@emptymalei
emptymalei / error message installing nokogiri
Last active May 8, 2019 18:10
gem install nokogiri problem
An error occurred while installing nokogiri
(1.8.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.0'
--source 'https://rubygems.org/'` succeeds before
bundling.