- Enable invert colors shortcut:
System Preferences... -> Keyboard -> Accessibility -> Invert colors [x] - Allow macscript to modify Accessibility
System Preferences... -> Security & Privacy -> Accessibility -> Privacy -> + -> osascript - Test that it's working from your shell:
osascript -e "tell application \"System Events\"" -e "key code 28 using {command down, option down, control down}" -e "end tell" - Create the script
sudo vim /etc/batteryScript.applescript
set Cap to (do shell script "ioreg -w0 -l | grep ExternalChargeCapable")
tell Cap to set {wallPower} to {last word of paragraph 1}
if wallPower = "Yes" then
return 0
else
set Cap to (do shell script "ioreg -wO -l | grep AppleRaw")
tell Cap to set {Max, Available} to {last word of paragraph 2, last word of paragraph 1}
set Pct to round (100 * Available / Max)
if Pct <= 5 then
tell application "System Events" key code 28 using {command down, option down, control down}
end tell
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
if Pct <= 3 then
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
if Pct <= 1 then
display notification "Computer is about to shutdown!" with title "---=== WARNING ===---"
beep 5
do shell script "say -v \"Alex\" \"PLUG ME IN NOW\""
end if
end if
end if
end if - Configure script access:
sudo chmod +rx /etc/batteryScript.applescript - Invoking script
vim ~/Library/LaunchAgents/batteryAlert.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>batteryAlert</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>/etc/batteryScript.applescript</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Battery Alert</string>
<key>StartInterval</key>
<integer>30</integer>
</dict>
</plist>
- Reboot the OS or manually load the launchd module.
launchctl load ~/Library/LaunchAgents/batteryAlert.plist
Teky Wiki
Random stuff about computer science
Thursday, October 10, 2019
Blink the screen when your Mac needs to charge
Saturday, March 14, 2015
macOS config for Finder
Open the terminal
Full path in Finder title bar$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
Show all files
$ defaults write com.apple.finder AppleShowAllFiles YES
Hold 'alt' on your keyboard, then right click on the Finder icon in the dock and click Relaunch.
OR
$ killall Finder
To unable the F* keys on the keyboard:
Choose Apple Menu > System Preferences.
Click Keyboard.
Click the Keyboard tab.
Select the option Use All F1, F2, etc. keys as standard function keys.
Quit System Preferences.
IMPORTANT: When this option is selected, press the Fn key to use the special features printed on each key.
Full path in Finder title bar$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
Show all files
$ defaults write com.apple.finder AppleShowAllFiles YES
Hold 'alt' on your keyboard, then right click on the Finder icon in the dock and click Relaunch.
OR
$ killall Finder
To unable the F* keys on the keyboard:
Choose Apple Menu > System Preferences.
Click Keyboard.
Click the Keyboard tab.
Select the option Use All F1, F2, etc. keys as standard function keys.
Quit System Preferences.
IMPORTANT: When this option is selected, press the Fn key to use the special features printed on each key.
Wednesday, December 24, 2014
Macbook Pro setup
===========================
Configure Keyboard
———————————————————————
Download the Fr-Ca
Copy:
cf.icns and cf.keylayout
To:
/Library/Keyboard
In the .profile:
# .profile
bash
In the ".bashrc" file, you can add...
To add the time/date in the history:
HISTTIMEFORMAT="%d/%m/%y %T "
Shortcut for "ls -l":
alias ll='ls -l'
Modify the prompt:
export PS1="\n\u@\h \w\n$ "
Add magic to the space !cmd ...
bind Space:magic-space
Monday, December 22, 2014
Configure IntelliJ
Remove some files from the projet view
File -> Settings -> File Types :
Ignore files and folders
...;.surefire-*;*.iml;.idea;.gitignore
Plugins
CheckStyle-IDEA
String Manipulation
Copy on steroids - http://plugins.jetbrains.com/plugin/7198
Markdown
Lombok
Sunday, November 2, 2014
HTML report for unit tests
# Run tests and generate .xml reports
mvn clean test
# Convert .xml reports into .html report, but without the CSS or images
mvn surefire-report:report-only
# Put the CSS and images where they need to be without the rest of the
# time-consuming stuff
mvn site -DgenerateReports=false
Go to target/site/surefire-report.html for the report.
mvn clean test
# Convert .xml reports into .html report, but without the CSS or images
mvn surefire-report:report-only
# Put the CSS and images where they need to be without the rest of the
# time-consuming stuff
mvn site -DgenerateReports=false
Go to target/site/surefire-report.html for the report.
Terminal code \E?1034h
When I was working with cqlsh (the command line client for Cassandra database), I tried to create a cleanup script which execute some CQL delete queries. It turns out, the cqlsh client is a python-based command line client and it could generate a special code, a shell escape sequence (\E[?1034h).
I found more inforation here.
I found more inforation here.
Wednesday, October 22, 2014
Libraries / frameworks
Java libs
JHipster
Spring Boot
Metrics
Logback
Ehcache
Jersey
Java Tools
Maven (plugins: surefire, surefire-report, assembly, antrun, javadoc, source, checkstyle, eclipse, help)
Ant
Tomcat / Jetty
Eclipse / IntelliJ
JavaScript
AngularJS
KnockoutJS
Deck.js
highlight.js
JavaScript Tools / Node.js
GruntJS
Bower
Karma
NodeJS
Jasmine
Mustache
UnderscoreJS
Firebug
CSS
SASS
LESS
CSS Tools
Compass
API References
JavaScript
Graphite
Subscribe to:
Posts (Atom)