Skip to content

Instantly share code, notes, and snippets.

@Sangdol
Sangdol / unminimize.scpt
Created July 23, 2022 14:49
An AppleScript to un-minimize a window of the currently focused application.
# 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 July 23, 2022 14:28
An AppleScript that marks notifications as completed
# 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 July 23, 2022 14:23
An AppleScript that closes notifications
# 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
#!/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
$ 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 21:14
If and Switch statement for bytecode compare
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 August 16, 2012 14:20
Person.java for Bytecode example
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 June 10, 2012 08:07
Mentionless minified - Twitter bookmarklet
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 June 10, 2012 06:12
Mentionless - Twitter bookmarklet
(function() {
if (location.host != 'twitter.com')
return;
var hide = function() {
$('.stream-item').has('.twitter-atreply').hide();
};
hide();
$(document).ajaxSuccess(function() {