Skip to content

Instantly share code, notes, and snippets.

View brsc2909's full-sized avatar

Brendan Scullion brsc2909

View GitHub Profile
@brsc2909
brsc2909 / rust_file_reader_with_iter.rs
Created December 7, 2022 21:38
Rust File reader that can iterate over lines of file
fn main() -> std::io::Result<()>{
for item in file_reader::BufReader::open("file.txt")? {
println!("{}", item?);
}
Ok(())
}
mod file_reader {
use std::{
fs::File,
@brsc2909
brsc2909 / emojizip.py
Created July 17, 2022 14:40
State of the art compression based on emojis
import emoji
import re
import gzip
def gzip_str(string_: str) -> bytes:
return gzip.compress(string_.encode("utf-8"))
def ezip_str(string_: str) -> str:
@brsc2909
brsc2909 / get_search_params.js
Created March 30, 2022 11:38
easily get url search params from list
function getSearchParams() {
const query = new URLSearchParams(window.location.search);
const filters = ["client_group", "platform", "date_since", "date_until"];
const filterObject = Object.assign(
{},
...filters.map((filter) => {
const value = query.get(filter);
if (value) return { [filter]: query.get(filter) };
})

Keybase proof

I hereby claim:

  • I am brsc2909 on github.
  • I am brsc2909 (https://keybase.io/brsc2909) on keybase.
  • I have a public key ASCI5DuRLNhfWMMLFMhO5dyu8pGpksEuMtq7b95w7n7eigo

To claim this, I am signing this object:

@brsc2909
brsc2909 / archive-dovecot.sh
Last active May 12, 2020 13:09
Script to automatically Archive emails in all mailboxes, Does not require doveadm which is useful as often shared hosting does not have this installed
#!/bin/bash
##############################################################
# Author: Brendan Scullion
# Date: 11-May-2020
# Description:
# Run on a weekly or daily basis from crontab. In this example i am
# archiving all emails in every mailbox older that 1.5 Years. emails are moved to
# to the archive folder grouped by month and keep the original folder structure.
##############################################################
MAILROOT=/home/user/mail/domain.example.com
@brsc2909
brsc2909 / ReadBookmarks.java
Created April 9, 2016 08:30
reads urls from a given folder from google chrome bookmarks into an array
package com.dropship;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
@brsc2909
brsc2909 / GetTimes.java
Created April 9, 2016 08:26
function to return the current time in a given format "yyyy-MM-dd HH:mm:ss
package com.dropship;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by brsc2909 on 4/7/16.
* returns the current time in desired time format
*/
class GetTimes {