This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check_sleep_problems() { | |
echo "pmset -g assertions (sleep blockers):" | |
pmset -g assertions | grep -A10 "Listed by owning process" | |
echo "" | |
echo "Wake reasons from the last hour:" | |
log show --style syslog --last 1h | grep -i "Wake reason" | tail -10 | |
echo "" | |
echo "Current pmset configuration:" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fix_sleep() { | |
echo "Current power settings:" | |
pmset -g custom | |
echo "" | |
echo "Disabling hibernation, standby, Power Nap and other wake triggers..." | |
sudo pmset -a hibernatemode 0 | |
sudo pmset -a autopoweroff 0 | |
sudo pmset -a standby 0 | |
sudo pmset -a powernap 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
class HeadingsParser | |
def initialize(headings) | |
@headings = headings | |
@number = [] | |
end | |
def parse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
if RUBY_VERSION < '2.7.0' | |
puts 'To run this script you need ruby version to be at least 2.7.0.' | |
return | |
end | |
# test data | |
data1 = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [2,3,9,2,5,1,3,7,10] | |
b = [2,1,3,4,3,10,6,6,1,7,10,10,10] | |
c = [2,9,2,5,7,10] | |
def prime?(num) | |
return true if num == 2 | |
return false if num <= 1 || num.even? | |
i = 3 | |
top = Math.sqrt(num).floor | |
loop do |