Skip to content

Instantly share code, notes, and snippets.

View ferbass's full-sized avatar
:octocat:
ι(`ロ´)ノ

Fernando Bass ferbass

:octocat:
ι(`ロ´)ノ
View GitHub Profile
@ferbass
ferbass / check-for-updates.sh
Last active August 16, 2023 02:52
Check for Linux host (Debian) available updates and post to slack
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
# Check for upgradable packages
@ferbass
ferbass / check-for-reboot.sh
Created August 14, 2023 01:49
Post to slack if your host requires reboot
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
# Function to send a message to Slack
@ferbass
ferbass / shutdown-cause.md
Last active December 7, 2022 04:46
macOS Shutdown Cause

Finding shutdown cause

log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h

Software Codes

1            Power adapter disconnected
3            Dirty Shutdown/Sleep resulting from forced restart or shutdown
5 Clean Shutdown/Sleep initiated by the user
@ferbass
ferbass / proc-mem-info-awk.sh
Last active October 26, 2022 02:53
Convert /proc/meminfo to KB, MB and GB as appropriate
# convert any kB lines to MB:
awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo
# converts to gigabytes:
awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo
# convert to MB or GB as appropriate:
awk '$3=="kB"{if ($2>1024^2){$2=$2/1024^2;$3="GB";} else if ($2>1024){$2=$2/1024;$3="MB";}} 1' /proc/meminfo
@ferbass
ferbass / enable_snap.sh
Created September 3, 2022 01:44
WSL2 Ubuntu enable snap
sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME
snap version
class Solution {
public:
vector<vector<string>> partition(string s) {
vector<vector<string>> result;
vector<string> part;
dfs(0, s, part, result);
return result;
}
void dfs(int i, string& s, vector<string>& part, vector<vector<string>>& result){
if(i>=s.size()){
@ferbass
ferbass / instructions.md
Last active December 29, 2022 03:22
Linkedin unfollow all
@ferbass
ferbass / solution.py
Created May 5, 2020 06:07
1.3 Hidden Messages in the Replication Origin (Part 2)
# Copy your updated FrequentWords function (along with all required subroutines) below this line
def FrequentWords(Text, k):
FrequentPatterns = [] # output variable
# your code here
Count = CountDict(Text, k)
m = max(Count.values())
for i in Count:
if Count[i] == m:
FrequentPatterns.append(Text[i:i+k])
@ferbass
ferbass / problem.py
Created May 5, 2020 05:58
1.3 Hidden Messages in the Replication Origin (Part 2) 10 out of 13 steps passed
# Input: A string Text and an integer k
# Output: A list containing all most frequent k-mers in Text
def FrequentWords(Text, k):
words = []
freq = FrequencyMap(Text, k)
m = max(freq.values())
for key in freq:
if freq[key] == m:
words.append(key)
return words
def FrequencyMap(Text, k):
# your code here
freq = {}
n=len(Text)
for i in range (n-k+1):
Pattern = Text [i:i+k]
if Pattern not in freq:
freq [Pattern] = 1
else:
freq [Pattern] +=1