Skip to content

Instantly share code, notes, and snippets.

@banan88
banan88 / excel_finder.py
Created June 12, 2018 13:54
Return column header of column that contains exactly the search string.
import openpyxl
import argparse
from openpyxl import load_workbook
from openpyxl.utils import get_column_letter
parser = argparse.ArgumentParser(description='Search first excel worksheet from given file for a string.')
parser.add_argument('-f', dest='filepath', help="Path to file to be searched", required=True)
parser.add_argument('-s', dest='searchstring', help="String to be searched in file", required=False, default='X')
@banan88
banan88 / count.py
Created December 22, 2014 11:01
Counts substring ocurrences in files with specific extensions from directory it is being run in
import os
string_to_search = '[Tags]'
file_extension = 'txt'
current_dir = os.path.dirname(os.path.realpath(__file__))
count = 0
for path, subdirs, files in os.walk(current_dir):
for filename in files:
if filename.endswith(file_extension):
@banan88
banan88 / cpu_load.sh
Last active August 29, 2015 14:05
shell script to load cpu. Run it via: nohup ./cpu_load.sh & and remember to killall dd when the load is no longer needed.
#!/bin/bash
#shell script to load cpu.
#Run it via: nohup ./cpu_load.sh & and remember to killall dd when the load is no longer needed.
#if load on more then 2 cores is required, add more " | dd if=/dev/zero of=/dev/null " entries inside.
fulload() { dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null & }; fulload;
@banan88
banan88 / async_server.pl
Created June 7, 2014 13:48
proper async perl server
#!/usr/bin/perl
use v5.14;
use warnings;
use Net::Async::HTTP::Server;
use IO::Async::Loop;
use HTTP::Request;
use HTTP::Response;