Skip to content

Instantly share code, notes, and snippets.

📡
sending EM waves to Mars

LM emptymalei

📡
sending EM waves to Mars
Block or report user

Report or block emptymalei

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
@emptymalei
emptymalei / property_inheritance.md
Created Sep 6, 2019 — forked from Susensio/property_inheritance.md
Inherit property setter in python 3.7
View property_inheritance.md

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.
View execute myself
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__}')
View gist:e292726304bb01bb2daf016664329079
Solving environment: done
## Package Plan ##
environment location: /Users/leima/anaconda3
removed specs:
- numpy
View calories.csv
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 Jun 3, 2019
GIST created by python code
View python request module
Python requests has 3 parameters: 1)Request URL
2)Header Fields
3)Parameter
4)Request body
@emptymalei
emptymalei / gm_2008_region.csv
Created Jun 3, 2019
regression_data_sample
View gm_2008_region.csv
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
View gist:3b517b6382357e8b4183c455d0ce38fb
# 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 — forked from Dreyer/perlbrew_libgcc_s.txt
[perlbrew] ld: library not found for -lgcc_s.10.4
View perlbrew_libgcc_s.txt
$ 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
gem install nokogiri problem
View error message installing nokogiri
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.
View gist:0db5dc160449ed8637433803cb86d067

some tools for diagrams in software documentation

Diagrams For Documentation

Obvious Choices

ASCII

You can’t perform that action at this time.