Skip to content

Instantly share code, notes, and snippets.

@Sangdol
Sangdol / unminimize.scpt
Created Jul 23, 2022
An AppleScript to un-minimize a window of the currently focused application.
View unminimize.scpt
# https://talk.automators.fm/t/unminimize-windows-of-the-current-application/12360/5
tell application id ("com.apple.systemevents") ¬
to tell (process 1 where it is frontmost) ¬
to tell (windows whose attribute named "AXMinimized"'s value is true) ¬
to if (it exists) then set the value of its attribute named "AXMinimized" of item 1 to false
@Sangdol
Sangdol / complete-notifications.scpt
Created Jul 23, 2022
An AppleScript that marks notifications as completed
View complete-notifications.scpt
# https://apple.stackexchange.com/questions/408019/dismiss-macos-big-sur-notifications-with-keyboard
my closeNotif()
on closeNotif()
tell application "System Events"
tell process "Notification Center"
set theWindow to group 1 of UI element 1 of scroll area 1 of window "Notification Center"
# click theWindow if you want to open the app
set theActions to actions of theWindow
repeat with theAction in theActions
@Sangdol
Sangdol / close-notifications.scpt
Created Jul 23, 2022
An AppleScript that closes notifications
View close-notifications.scpt
# https://apple.stackexchange.com/questions/408019/dismiss-macos-big-sur-notifications-with-keyboard
my closeNotif()
on closeNotif()
tell application "System Events"
tell process "Notification Center"
set theWindow to group 1 of UI element 1 of scroll area 1 of window "Notification Center"
# click theWindow if you want to open the app
set theActions to actions of theWindow
repeat with theAction in theActions
View highest-cpu.sh
#!/usr/bin/env bash
#
# Threadhold 값 (30%) 이상 CPU 점유하고 있는 프로세스 중 가장 높은 CPU 점유하고 있는 프로세스 반환합니다.
# Better Touch Tool과 연동하여 TaskBar에 노출시키기 위해 사용하거나
# TextBar http://richsomerfield.com/apps/textbar/ 와 함께 사용할 수 있습니다.
# 5초에 한번 정도 실행하도록 설정하면 적당합니다.
#
# https://stackoverflow.com/questions/24129903/notifying-when-using-high-cpu-via-applescript-or-automator
SAMPLE_SIZE=2
View cpu_monitor_example.log
$ SAMPLE_SIZE=3
DELAY_SECS=1
TOP_APP_NUM=5 # number of apps to sum up
$ /usr/bin/top -s $DELAY_SECS -l $SAMPLE_SIZE -n $TOP_APP_NUM -F -o cpu -stats cpu,pid,command | \
grep -A$TOP_APP_NUM "%CPU"
%CPU PID COMMAND
0.0 99989 fish
0.0 99752 mdworker_shared
0.0 99640 CategoriesServic
@Sangdol
Sangdol / IfAndSwitch.java
Last active May 15, 2021
If and Switch statement for bytecode compare
View IfAndSwitch.java
public class IfAndSwitch {
public static void ifFunc(int v) {
if (v == 1) {
System.out.println(1);
} else if (v == 2) {
System.out.println(2);
}
}
public static void switchFunc(int v) {
@Sangdol
Sangdol / Person.java
Created Aug 16, 2012
Person.java for Bytecode example
View Person.java
public class Person {
int age = 10;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Sangdol
Sangdol / mentionless.min.js
Created Jun 10, 2012
Mentionless minified - Twitter bookmarklet
View mentionless.min.js
javascript:(function(){if(location.host!='twitter.com')return;var hide=function(){$('.stream-item').has('.twitter-atreply').hide()};hide();$(document).ajaxSuccess(function(){setTimeout(hide,100)})})()
@Sangdol
Sangdol / mentionless.js
Created Jun 10, 2012
Mentionless - Twitter bookmarklet
View mentionless.js
(function() {
if (location.host != 'twitter.com')
return;
var hide = function() {
$('.stream-item').has('.twitter-atreply').hide();
};
hide();
$(document).ajaxSuccess(function() {