Skip to content

Instantly share code, notes, and snippets.

View hperantunes's full-sized avatar

Hilton Perantunes hperantunes

  • Montreal, Canada
View GitHub Profile
@hperantunes
hperantunes / convert_coordinates_NAD83_to_WGS84.py
Last active June 2, 2025 14:34
Converts latitude and longitude columns in a CSV file from EPSG:3347 NAD83 / Statistics Canada Lambert to EPSG:4326 WGS 84 coordinate system
import csv
import os # For splitting filename and extension
import argparse # For command-line arguments
from pyproj import Transformer, CRS
from pyproj.exceptions import ProjError
def convert_coords_write_newfile_replace_values(
input_csv_path,
output_csv_path,
lon_column_name, # Column to read EPSG:3347 from AND write EPSG:4326 to
Get-ChildItem "C:\Path\To\Your\Folder" -Filter "Slice *.png" | Rename-Item -NewName { $_.Name -replace "^Slice\s", "" }
@hperantunes
hperantunes / goldberg-polyhedra-faces.js
Last active May 28, 2025 15:44
Number of faces in a Goldberg polyhedra class I
var faces = (m, n) => 10 * (m * m + m * n + n * n) + 2
rem regular version
for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")
rem recursive
for /f "Tokens=*" %f in ('dir /l/b/a-d/s') do (rename "%f" "%f")
using System;
using System.Linq;
public class Program
{
public static void Main()
{
var a = new string[] { "something", "something else" };
var b = new string[] { "something", "something else" };
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test("[email protected]")
This file has been truncated, but you can view the full file.
<style>
// https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));
var request = new XMLHttpRequest();
request.open('GET', '/bar/foo.txt', false); // `false` makes the request synchronous
request.send(null);
if (request.status === 200) {
console.log(request.responseText);
}