Skip to content

Instantly share code, notes, and snippets.

View bmaingret's full-sized avatar

Baptiste Maingret bmaingret

View GitHub Profile
@bmaingret
bmaingret / gist:5402111
Last active December 16, 2015 07:58
Bash script - saving output to input file for commands like iconv
for file in *.php
do
iconv -f cp1251 -t utf8 -o "$file.new" "$file" &&
mv -f "$file.new" "$file"
done
@bmaingret
bmaingret / clean_old_files.ps1
Last active February 1, 2019 08:20
Copy/Move all files that have been modified a few days ago from a source to a daily backup directory
<#
#
.Synopsis
.DESCRIPTION
Copy all files from $sourceDirectory to a directory named $targetDirectory\'yyyy-mm-dd' based on current day that have been modified at least $minimumAgeInDays days ago
Typical usage is the purge of a directory: copy files older than $minimumAgeInDays days to another directory
.NOTES
Created By: Baptiste Maingret
# History files
.Rhistory
.Rapp.history
# Session Data files
.RData
# User-specific files
.Ruserdata
@bmaingret
bmaingret / README.md
Created April 29, 2020 18:03 — forked from JamesMessinger/README.md
VSCode GitHub Markdown Theme

GitHub Markdown Theme for Visual Studio Code

This CSS stylesheet allows you to preview markdown files in VSCode using GitHub's mardown theme. This CSS was taken directly from the official GitHub Markdown repo. I replaced their top-level .markdown-body class with the body tag so it would work in VSCode, and added styling for the html tag to match GitHub's fixed-width container.

Instructions

  1. Copy the CSS file to your computer
    Copy the github-markdown.css file below to your computer. You can put it anywhere you want, but I chose to put it in the same folder as my VSCode settings file.

  2. Edit your VSCode settings
    If you want to use this theme for all of your projects, then edit your User Settings file. If you just want to use this them

@bmaingret
bmaingret / xlsx_to_csv.py
Created March 20, 2021 17:57
Convert XLSX to CSV supporting multi-line cells
import pandas as pd
infile = pd.read_excel(r'myfile.xlsx')
infile = infile.replace(to_replace=[r"\\t|\\n|\\r", "\t|\n|\r"], value=["",""], regex=True)
infile.to_csv(r'myfile.csv', index=False, header=True, quoting=csv.QUOTE_ALL)