Shut down without showing a confirmation dialog:
osascript -e 'tell app "System Events" to shut down'
Shut down after showing a confirmation dialog:
osascript -e 'tell app "loginwindow" to «event aevtrsdn»'
# Step-1: Install Homebrew, if you don’t have it already. | |
# There are other possibilities as well to install Python3 but I recommend installing it via Homebrew for cleaner installation and easier maintenance (upgrade etc). | |
# > /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" | |
# Step-2: Install Python3 (pip3 gets installed automatically) | |
# > brew install python3 | |
# Step-3: Install Virtualenvwrapper | |
# > sudo -H pip3 install virtualenvwrapper |
# Start with Linux Alpine image as base | |
FROM alpine:latest | |
# Install curl | |
apk add --no-cache curl |
Python basics step by step examples |
This gist contains Hello World examples for several programming languages and framworks. This codes from this gist are being used (as embed code) at Hello World page at my weebsite (https://atifazad.com/tutorials/general/hello-world/) |
#import <Foundation/Foundation.h> | |
@interface Solution : NSObject | |
- (NSString *)countAndCall: (int) n; | |
- (NSString *)count:(int) n; | |
@end | |
@implementation Solution | |
- (NSString *)countAndCall: (int) n { |
# -*- coding: utf-8 -*- | |
import subprocess | |
subprocess.call(['osascript', '-e', 'tell app "loginwindow" to «event aevtrsdn»']) | |
#usage: > python mac_shutdown.py | |
# For further similar system commands: https://gist.github.com/atifazad/6afd3cbedb8819dd7ed7be92dec2dc0d |
Shut down without showing a confirmation dialog:
osascript -e 'tell app "System Events" to shut down'
Shut down after showing a confirmation dialog:
osascript -e 'tell app "loginwindow" to «event aevtrsdn»'
import subprocess | |
import sys | |
if len(sys.argv) == 1 : | |
print "missing program name to quit" | |
else: | |
program=sys.argv[1] | |
quitCommand='tell application "' + program + '" to quit' | |
print "quiting " + program | |
subprocess.call(['osascript', '-e', quitCommand]) |
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
Get hash of last commit (eg. 1fa01e4b90a09069a5aa6482a71c5f76118eef9e) | |
git rev-parse HEAD | |
Get short hash of last commit (eg. 1fa01e4) | |
git rev-parse --short HEAD |