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 (http://www.iport.it)
//
@bobbychopra
bobbychopra / AddColumn.ps1
Created Oct 9, 2012
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
gorhill / render_number.go
Last active Jul 9, 2020
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
/*
Author: https://github.com/gorhill
Source: https://gist.github.com/gorhill/5285193
A Go function to render a number to a string based on
the following user-specified criteria:
* thousands separator
* decimal separator
@paulodeleo
paulodeleo / .tmux.conf
Last active Jan 10, 2022
Tmux configuration to enable mouse scroll and mouse panel select, taken from: http://brainscraps.wikia.com/wiki/Extreme_Multitasking_with_tmux_and_PuTTY
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
@pankaj28843
pankaj28843 / set_outer_border_for_range_xlsx.py
Last active May 28, 2021
A simple hack - set outer border for a range using xlsxwriter, a Python library
View set_outer_border_for_range_xlsx.py
from __future__ import absolute_import
try:
import cStringIO as StringIO
except ImportError:
import StringIO
# Standard Library
import re
import string
@cdipaolo
cdipaolo / HaversinFormula.go
Created Apr 15, 2015
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
//
@josue
josue / pdf-conversion-fun.md
Last active Nov 30, 2021
Using ImageMagick to easily: Split, Merge, Remove a page from PDF.
View pdf-conversion-fun.md

Install Required libraries:

sudo apt-get update && sudo apt-get install imagemagick gs

create directory to test commands

mkdir -p pdf_conversion/{merged,split}
cd pdf_conversion
@subfuzion
subfuzion / curl.md
Last active Jan 15, 2022
curl POST examples
View curl.md

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.

@leommoore
leommoore / mongodb_ssl_with_letsencrypt.md
Last active Dec 21, 2021
MongoDB 3.2.x SSL with Letsencrypt
View mongodb_ssl_with_letsencrypt.md

MongoDB 3.2.x SSL with Letsencrypt

Letsencrypt is an initative which aims to increase the use of encryption for websites. It basically allows people to apply for free certificates provided that they prove the they control the requested domain. We will look at the what is needed to secure your MongoDB installation. For more details on setting up a MongoDB server see MongoDB 3.2.x.

Set the hostname

We sould to set the hostname to match the name of the certificate we are going to optain.

sudo hostname mongo0.example.com

Then update the hostname file to set the server name permanently.

@scottcagno
scottcagno / cmdtimeout.go
Created May 27, 2016
Golang exec.Command Timeout Wrapper
View cmdtimeout.go
package main
import (
"bytes"
"fmt"
"os/exec"
"time"
)
func run(timeout int, command string, args ...string) string {