Skip to content

Instantly share code, notes, and snippets.

View mickaelpham's full-sized avatar
🇫🇷

Mickaël Pham mickaelpham

🇫🇷
View GitHub Profile
@mickaelpham
mickaelpham / exec.ts
Created December 21, 2023 14:19
Generic function with proper typing
const sum = (a: number, b: number): number => a + b
const repeat = (word: string, times: number): string[] => {
const result = []
for (let i = 0; i < times; i++) {
result.push(word)
}
return result
}
@mickaelpham
mickaelpham / pdf_zip.py
Created October 30, 2022 09:45
Zip two PDFs together (odd and even pages)
from PyPDF2 import PdfReader, PdfMerger
merger = PdfMerger()
odd_document = open("loan-offer.pdf", "rb")
even_document = open("loan-offer-page-paires.pdf", "rb")
num_pages_odd = len(PdfReader(odd_document).pages)
num_pages_even = len(PdfReader(even_document).pages)

Keybase proof

I hereby claim:

  • I am mickaelpham on github.
  • I am mickaelpham (https://keybase.io/mickaelpham) on keybase.
  • I have a public key ASDnjoDGu2dtez6jd4L8hKkJJ_LKs0S-D0HRyF0H4w3EFQo

To claim this, I am signing this object:

@mickaelpham
mickaelpham / gist:51d1e6446604dff104ef
Created June 10, 2014 17:29
Simple ruby script to execute a git shell command (renaming files in bulk)
directory = "/Users/mpham/Desktop"
Dir.chdir(directory)
puts Dir.pwd
Dir.foreach(".") do |x|
# Let's replace the weird filename by the correct one
f = x.gsub "%0025", "%"
if f != x
previous = "\"" + directory + "/" + x + "\""
new_name = "\"" + directory + "/" + f + "\""
# will make the changes here