Skip to content

Instantly share code, notes, and snippets.

View MarkBolden's full-sized avatar
🎯
Focusing

Mark Bolden MarkBolden

🎯
Focusing
View GitHub Profile
@dentechy
dentechy / WSL-ssh-server.md
Last active March 30, 2024 16:16
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:
@pedrohma
pedrohma / geoLocation.js
Last active June 2, 2023 11:18
Getting Zip Code by GeoLocation using Google Maps API
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
alert("Sorry, but Geolocation is not supported by this browser.");
}
}
function showPosition(position) {
var lat = position.coords.latitude;
@gcphost
gcphost / pretty-php-numbers.php
Last active October 26, 2021 08:40
Pretty PHP Numbers, convert a number to K, M, B, etc.
<?php
function human_number($number) {
$number = preg_replace('/[^\d]+/', '', $number);
if (!is_numeric($number)) {
return 0;
}
if ($number < 1000) {
@contemplate
contemplate / functions.php
Last active November 14, 2023 12:59
WooCommerce - Allow guest checkout for certain products when Guest checkout is Disabled globally
/*--------------------------------------
Woocommerce - Allow Guest Checkout on Certain products
----------------------------------------*/
// Display Guest Checkout Field
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
@PowerKiKi
PowerKiKi / generate-wildcard-certificate.sh
Created December 4, 2015 07:31
Generate self-signed wildcard SSL certificate for development environment
#!/usr/bin/env bash
# print usage
DOMAIN=$1
if [ -z "$1" ]; then
echo "USAGE: $0 domain.lan"
echo ""
echo "This will generate a non-secure self-signed wildcard certificate for given domain."
echo "This should only be used in a development environment."
@tomysmile
tomysmile / vagrant-shortcut.md
Last active December 17, 2019 19:47
Vagrant: Shortcut command

Creating initial vagrant file

$ vagrant init

Running precise32

$ vagrant init hashicorp/precise32
@lukescott
lukescott / gist:36453a75c39c539f5c7d
Last active February 12, 2024 00:00
Traits in ES6 now
/*
var Trait1 = {
method1() {}
};
var Trait2 = {
method2() {}
};
var Trait3 = mixin({
@nixta
nixta / .htaccess
Last active March 19, 2024 22:52
.htaccess to add CORS to your website
# Add these three lines to CORSify your server for everyone.
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET,PUT,POST,DELETE"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"
@maor
maor / ninja-forms-countries-dd.php
Last active March 27, 2019 03:10
Ninja Forms countries dropdown select field
<?php
/**
* Add a new <select> field, pre-populated with all countries in our tiny, tiny world.
*
* @author Maor Chasen
*/
function aff_register_ninja_forms_fields() {
$args = array(
@jefferyrdavis
jefferyrdavis / gist:5992271
Last active December 4, 2020 07:16
Snippit: PHP: Format 10 or 7 digit phone number
<?php
/* formats a 10 or 7 digit phone number (number only) by adding dashes at the appropriate locations */
function phoneFormat($number) {
if(ctype_digit($number) && strlen($number) == 10) {
$number = substr($number, 0, 3) .'-'. substr($number, 3, 3) .'-'. substr($number, 6);
} else {
if(ctype_digit($number) && strlen($number) == 7) {
$number = substr($number, 0, 3) .'-'. substr($number, 3, 4);
}