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 / reverse_complement.py
Created May 4, 2020 06:33
Reverse complement of DNA strand using Python
alt_map = {'ins':'0'}
complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
def reverse_complement(seq):
for k,v in alt_map.iteritems():
seq = seq.replace(k,v)
bases = list(seq)
bases = reversed([complement.get(base,base) for base in bases])
bases = ''.join(bases)
for k,v in alt_map.iteritems():
@ferbass
ferbass / instructions.md
Last active December 29, 2022 03:22
Linkedin unfollow all
@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 / button.swift
Created May 3, 2016 04:14
Adding a closure as target to a UIButton
import UIKit
extension UIButton {
private func actionHandleBlock(action:(() -> Void)? = nil) {
struct __ {
static var action :(() -> Void)?
}
if action != nil {
@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])