Skip to content

Instantly share code, notes, and snippets.

View regex-weburl.js
// Regular Expression for URL validation
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
// Copyright (c) 2010-2018 Diego Perini (
bobbychopra / AddColumn.ps1
Created October 9, 2012 21:28
Add Date column to an existing csv file
View AddColumn.ps1
$today = [System.DateTime]::Today.ToString("yyyyMMdd")
Import-Csv -Header Column1,Column2 -Delim ',' 'C:\sample.csv' |
ForEach {
New-Object psobject -Property @{Date=$today;Col1=$_.Column1; Col2=$_.Column2}
} | Select-Object Date,Col1,Col2 | Export-Csv -NoTypeInformation 'C:\sample.csv'
gorhill / render_number.go
Last active March 11, 2023 13:08
A Go function to render a number to a string based on the following user-specified criteria: thousands separator, decimal separator, decimal precision. I didn't feel it was worth to publish a library just for this piece of code, hence the snippet. Feel free to reuse as you wish.
View render_number.go
A Go function to render a number to a string based on
the following user-specified criteria:
* thousands separator
* decimal separator
paulodeleo / .tmux.conf
Last active July 15, 2022 10:16
Tmux configuration to enable mouse scroll and mouse panel select, taken from:
View .tmux.conf
# Make mouse useful in copy mode
setw -g mode-mouse on
# Allow mouse to select which pane to use
set -g mouse-select-pane on
# Allow mouse dragging to resize panes
set -g mouse-resize-pane on
# Allow mouse to select windows
yyx990803 / starcounter.js
Last active July 8, 2023 23:36
Count your total stars!
View starcounter.js
var https = require('https'),
user = process.argv[2],
opts = parseOpts(process.argv.slice(3))
request('/users/' + user, function (res) {
if (!res.public_repos) {
var pages = Math.ceil(res.public_repos / 100),
pankaj28843 /
Last active September 1, 2022 21:48
A simple hack - set outer border for a range using xlsxwriter, a Python library
from __future__ import absolute_import
import cStringIO as StringIO
except ImportError:
import StringIO
# Standard Library
import re
import string
cdipaolo / HaversinFormula.go
Created April 15, 2015 01:31
Golang functions to calculate the distance in meters between long,lat points on Earth.
View HaversinFormula.go
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
gboone / midpoint
Created November 28, 2015 23:47
How to find a geographic midpoint in js
View midpoint
function setLatLng(dataset) {
var lat =
var lng = dataset.lng
return new L.LatLng(lat, lng)
function latLngRadians(dataset) {
return, function(item) {
var latRad =*(Math.PI/180)
var lngRad = item.lng*(Math.PI/180)
josue /
Last active April 22, 2023 07:47
Using ImageMagick to easily: Split, Merge, Remove a page from PDF.
subfuzion /
Last active September 26, 2023 04:47
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.