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() {