Skip to content

Instantly share code, notes, and snippets.

View cescapa's full-sized avatar
🏠
La chance ne sourit qu'aux esprits bien préparés (Pasteur)

Carlos Escapa cescapa

🏠
La chance ne sourit qu'aux esprits bien préparés (Pasteur)
  • East Palo Alto, CA USA
  • 13:53 (UTC -07:00)
View GitHub Profile
@cescapa
cescapa / modifyCreationDate.py
Last active January 3, 2021 06:15
Modify creation date in OS X
# newCreationTime is the Linux time stamp of the photo or video (seconds since 1970-1-1)
# mediaPath is the full path of the photo or video
import os
from datetime import datetime
os.system(f"SetFile -d \"{datetime.fromtimestamp(newCreationTime).strftime('%m/%d/%Y %H:%M:%S')}\" \"{mediaPath}\"")
@cescapa
cescapa / gist:c655e8e0c1558660150f
Last active May 23, 2021 11:30
Checks if a number is prime in a single line of Python
# Assumes that "a" contains an integer > 2 whose primality needs to be verified
# The algorithm builds a list of factors including the number 2 and all odd numbers
# up to the square root of "a", and then checks if any of those numbers divides "a"
# without a remainder - if so then "a" is not prime, else it is
if sum([ True if a%factor == 0 else False for factor in ( [2] + list(range(3,int(math.sqrt(a))+1,2) )) ]):
print("Number is composite")
else:
print("Number is prime")