- By Edmond Lau
- Highly Recommended 👍
- http://www.theeffectiveengineer.com/
- They are the people who get things done. Effective Engineers produce results.
| ### Keybase proof | |
| I hereby claim: | |
| * I am waynehuang13 on github. | |
| * I am whuang1220 (https://keybase.io/whuang1220) on keybase. | |
| * I have a public key ASDuwWJ4kcTDU7H-x1W5jzXI1kDf0Ju9EmKPRyZ-CTDUNwo | |
| To claim this, I am signing this object: |
| #EXTM3U x-tvg-url="https://iptv-org.github.io/epg/guides/af/arianaafgtv.com.epg.xml,https://iptv-org.github.io/epg/guides/ar/mi.tv.epg.xml,https://iptv-org.github.io/epg/guides/at/magentatv.at.epg.xml,https://iptv-org.github.io/epg/guides/bf/canalplus-afrique.com.epg.xml,https://iptv-org.github.io/epg/guides/bo/comteco.com.bo.epg.xml,https://iptv-org.github.io/epg/guides/bs/rev.bs.epg.xml,https://iptv-org.github.io/epg/guides/co/mi.tv.epg.xml,https://iptv-org.github.io/epg/guides/cz/m.tv.sms.cz.epg.xml,https://iptv-org.github.io/epg/guides/dk/allente.se.epg.xml,https://iptv-org.github.io/epg/guides/gr/cosmote.gr.epg.xml,https://iptv-org.github.io/epg/guides/in/dishtv.in.epg.xml,https://iptv-org.github.io/epg/guides/it/guidatv.sky.it.epg.xml,https://iptv-org.github.io/epg/guides/my/astro.com.my.epg.xml,https://iptv-org.github.io/epg/guides/nl/delta.nl.epg.xml,https://iptv-org.github.io/epg/guides/ph/clickthecity.com.epg.xml,https://iptv-org.github.io/epg/guides/pl/programtv.onet.pl.epg.xml,https://iptv-org.git |
I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6
apt-get update && apt-get install gdb
Beautiful is better than ugly. Explicit is better than implicit.
I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.
All of the tasks presented in the examples can be accomplished with the extensive standard library available in Python. These solutions would arguably be more terse and efficient in some cases. I don't have anything against the standard library. To me there is a certain
| #!/bin/bash | |
| set -x | |
| USAGE() { | |
| cat << EOF | |
| Usage: ${0##*/} <-i ident.p12> [-p password] <-m profile.mobileprovision> [-a com.example.app] [-n NewName] [-I Info.plist] | |
| -i ident.p12 The signing identity file. | |
| -p password The password of signing identity file. | |
| -m profile.mobileprovision Signing provision profile | |
| -a com.example.app Override CFBundleIdentifier |
| The basic idea here is to substantiate the claims made by this square post: | |
| http://corner.squareup.com/2011/06/postgresql-data-is-important.html | |
| In PostgreSQL, and MySQL (MyISAM and InnoDB) I create millions of rows and then add | |
| and remove columns and add and remove indexes. For columns without defaults this is | |
| basically free in PostgreSQL and O(n) in MySQL. For adding indexes its at best O(n) | |
| everywhere, but with PostgreSQL it claims not to do any locking that would otherwise | |
| prevent table interaction. | |
| Also, PostgreSQL has _awsome_ documentation (it has real examples!). I always get |
| # LBs have 8 cores. One is used for haproxy, rest are used for nginx workers | |
| worker_processes 7; | |
| worker_rlimit_nofile 90000; | |
| pid <PID_FILE>; | |
| events { | |
| use epoll; | |
| multi_accept off; | |
| accept_mutex off; |
| # gem 'activerecord', '4.1.1' # passes | |
| gem 'activerecord', '4.1.2.rc1' # fails with ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes for Membership: group_id | |
| gem 'protected_attributes', '1.0.7' | |
| require 'active_record' | |
| require 'minitest/autorun' | |
| require 'logger' | |
| require 'protected_attributes' | |
| # Ensure backward compatibility with Minitest 4 | |
| Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) |
| # inspired by http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs | |
| # retry all failed Resque jobs except the ones that have already been retried | |
| # This is, for instance, useful if you have already retried some jobs via the web interface. | |
| Resque::Failure.count.times do |i| | |
| Resque::Failure.requeue(i) unless Resque::Failure.all(i, 1)['retried_at'].present? | |
| end | |
| # retry all :) | |
| Resque::Failure.count.times do |i| |