Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Mark Bolden MarkBolden

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

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 Mar 12, 2021
Getting Zip Code by GeoLocation using Google Maps API
View geoLocation.js
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 Oct 26, 2021
Pretty PHP Numbers, convert a number to K, M, B, etc.
View pretty-php-numbers.php
<?php
function human_number($number) {
$number = preg_replace('/[^\d]+/', '', $number);
if (!is_numeric($number)) {
return 0;
}
if ($number < 1000) {
@contemplate
contemplate / functions.php
Created May 1, 2016
WooCommerce - Allow guest checkout for certain products when Guest checkout is Disabled globally
View functions.php
/*--------------------------------------
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 Dec 4, 2015
Generate self-signed wildcard SSL certificate for development environment
View generate-wildcard-certificate.sh
#!/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 Dec 17, 2019
Vagrant: Shortcut command
View vagrant-shortcut.md

Creating initial vagrant file

$ vagrant init

Running precise32

$ vagrant init hashicorp/precise32
View gist:36453a75c39c539f5c7d
/*
var Trait1 = {
method1() {}
};
var Trait2 = {
method2() {}
};
var Trait3 = mixin({
@nixta
nixta / .htaccess
Last active Oct 20, 2021
.htaccess to add CORS to your website
View .htaccess
# 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 Mar 27, 2019
Ninja Forms countries dropdown select field
View ninja-forms-countries-dd.php
<?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 Dec 4, 2020
Snippit: PHP: Format 10 or 7 digit phone number
View gist:5992271
<?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);
}