Curated List of Management Literature

James Clear

Atomic Habits

Brian Tracy

Eat that frog

Daniel H. Pink

Drive: The Surprising Truth About What Motivates Us

Jurgen Appelo

Management 3.0

Managing for Happiness

Startup, Scaleup, Screwup

Peter Drucker

The Effective Executive

Managing Oneself (Harvard Business Review Classics)

Jocko Willink

Extreme Ownership: How US Navy Seals Lead and Win

Jason Fried / David Heinemier Hansson

It Doesn’t Have to Be Crazy at Work

ReWork: Change the Way You Work Forever

Remote: Office Not Required

Blenchard / Johnson

The New One Minute Manager

Michael Bungay Stanier

The Coaching Habit: Say Less, Ask More & Change the Way You Lead Forever

Gary Keller

The One Thing: The Surprisingly Simple Truth Behind Extraordinary Results

Emily Webber

Building Successful Communities of Practice

Angela Duckworth

Grit: Why passion and resilience are the secrets to success

Shawn Coyne

The War of Art: Break Through the Blocks and Win Your Inner Creative Battles

Judy Robinett

How to Be a Power Connector: The 5+50+100 Rule

Robert Caldini

influence: The Psychology of Persuasion

Keith Ferrazzi

Never Eat Alone

Seth Godin

What to Do When It’s Your Turn

Carol Dweck

Mindset – Updated Edition: Changing The Way You think To Fulfil Your Potential

Dale Carnegie

How To Win Friends And Influence People

How to Stop Worrying and Start Living

Frederic Laloux

Reinventing Organizations: A Guide to Creating Organizations Inspired by the Next Stage in Human Consciousness

Marshall Goldsmith

What Got You Here Won’t Get You There: How Successful People Become Even More Successful

Triggers: Creating Behavior That Lasts–Becoming the Person You Want to Be

 

Sound and music with pygame

pip install pygame

Sound

import pygame

if __name__ == '__main__':
    pygame.mixer.init()
    sound = pygame.mixer.Sound("./sound.wav")
    channel = sound.play()
    while channel.get_busy():
        pygame.time.wait(100)
        print("Playing...")
    print("Finished.")

 

Music

import pygame

if __name__ == '__main__':
    pygame.mixer.init()
    pygame.mixer.music.load("./sound.mp3")
    pygame.mixer.music.play()
    while pygame.mixer.music.get_busy():
        pygame.time.wait(100)  # ms
        print("Playing...")
    print("Finished.")

Getting Location Info in Android

Manifest

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Activity

 

public static final int REQUEST_CODE = 123;
LocationManager mLocationManager; 
LocationListener mLocationListener;
@Override
protected void onResume(){
    super.onResume();
    getCurrentLocation();
}
private void getCurrentLocation() {
    Log.d("Clima", "getWeatherForCurrentLocation");
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mLocationListener = new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
            Log.d("Clima", "onLocationChanged");
            String longitude = String.valueOf(location.getLongitude());
            String latitude = String.valueOf(location.getLatitude());
            Log.d("Clima", "longitude is: " +longitude);
            Log.d("Clima","latitude is: " + latitude);
        }

        @Override
        public void onStatusChanged(String s, int i, Bundle bundle) {

        }

        @Override
        public void onProviderEnabled(String s) {

        }

        @Override
        public void onProviderDisabled(String s) {

        }
    };
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE);
        return;
    }
    mLocationManager.requestLocationUpdates(LOCAION_PROVIDER, MIN_TIME, MIN_DISTANCE, mLocationListener);
}

 

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    Log.d("Clima", "onRequestPermissionsResult");
    if (requestCode == REQUEST_CODE) {
        if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
            getCurrentLocation();
        }
    }
}

Passing data between AndroidActivities

Sending data

private void openVideoActivity(String video) {
    Intent newActivity = new Intent(this, PlayerActivity.class);
    newActivity.putExtra("videoId", video);
    startActivity(newActivity);
}

Retrieving data

final String videoID = getIntent().getExtras().getString("videoID");

Python variable length arguments

def print_person_varargs(name, *vargs):
    print(name)
    print(vargs)
    for arg in vargs:
        print(arg)


def print_person_kwargs(name, **kwargs):
    print(name)
    print(kwargs)
    for i, j in kwargs.items():
        print(i, j)


print_person_varargs("Jörn", 38, "Emskirchen")
print_person_kwargs("Jörn", age=38, city="Emskirchen")

Android Services

Service Manager

$ adb shell service list
shell@g3:/ $ service list
Found 132 services:
0 AtCmdFwd: [com.qualcomm.atfwd.IAtCmdFwd]
1 lge.apdu: [com.lge.smartcard.internal.apdu.uicc.IUiccAccess]
2 telecom: [com.android.internal.telecom.ITelecomService]
3 phone: [com.android.internal.telephony.ITelephony]

Android Spinner

Spinner spinner = findViewById(R.id.currency_spinner);

// Create an ArrayAdapter using the String array and a spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
        R.array.spinner_values, R.layout.spinner_item);

// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);

// Apply the adapter to the spinner
spinner.setAdapter(adapter);


spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        Log.d("Spinner Demo", "" + parent.getItemAtPosition(position));
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {
        Log.d("Spinner Demo", "Nothing selected");
    }
});

Switch between activities

public class MainActivity extends AppCompatActivity {
    private Button mAddButton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mAddButton = findViewById(R.id.addButton);
        mAddButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                openAddActivity();
            } 
        });
}

    public void openAddActivity(){
       Intent intent = new Intent(this, Main2Activity.class);
       startActivity(intent);
}

Android screen orientation

disable orientation change

<activity android:name=".MainActivity"
    android:screenOrientation="portrait"
    tools:ignore="LockedOrientationActivity">

Handling orientation state
Saving instance state

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putInt("ScoreKey", mScore);
    outState.putInt("IndexKey", mIndex);

}

Retrieving instance state

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (savedInstanceState != null){
        mScore = savedInstanceState.getInt("ScoreKey");
        mIndex = savedInstanceState.getInt("IndexKey");

    } else {
        mScore = 0;
        mIndex = 0;
    }