Snippets Collections
https://source.unsplash.com/user/c_v_r
 const searchParams = new URLSearchParams(window.location.search);
  const id = searchParams.get('id');
  console.log(id)
https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.4.120/pdf.min.js
http://localhos/adminer.php
//Get hash of a given url

var some_url = 'https://usefulangle.com/posts?123#slider'

var hash = new URL(some_url).hash;

// "#slider"
console.log(hash);

//
//
//


//Get hash of the current url

// document.URL refers to the current url
var hash = new URL(document.URL).hash;

console.log(hash);



//
//
//


//Change hash of a given url

var some_url = 'https://usefulangle.com/posts?123#slider'

var url_ob = new URL(some_url);
url_ob.hash = '#reviews';

// new url string
var new_url = url_ob.href;

// "https://usefulangle.com/posts?123#reviews"
console.log(new_url);


//
//
//


//Change hash of the current url

// document.URL is the current url
var url_ob = new URL(document.URL);
url_ob.hash = '#345';

// new url
var new_url = url_ob.href;

// change the current url
document.location.href = new_url;


//
//
//

/*
Detecting Change in Hash of the Current URL

The window.hashchange event can be listened to know when the hash fragment in the current url changes.
*/

window.addEventListener('hashchange', function() {
	// new hash value
	console.log(new URL(document.URL).hash);
});
import UIKit
import WebKit

class ViewController: UIViewController, WKNavigationDelegate {
    var webView: WKWebView!

    override func loadView() {
        webView = WKWebView()
        webView.navigationDelegate = self
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        let url = URL(string: "https://www.google.com")!
        webView.load(URLRequest(url: url))
        webView.allowsBackForwardNavigationGestures = true
    }
    
    public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Swift.Void) {
            if(navigationAction.navigationType == .other) {
                if let redirectedUrl = navigationAction.request.url {
                    //do what you need with url
                    //self.delegate?.openURL(url: redirectedUrl)
                }
                decisionHandler(.cancel)
                return
            }
            decisionHandler(.allow)
        }
}
# Zsh
1. zsh: https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH
2. Oh My Zsh: https://github.com/ohmyzsh/ohmyzsh
3. Powerlevel10k: https://github.com/romkatv/powerlevel10k

	// Don't forget to set the theme and install the fonts
	https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf
	https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf
	https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf
	https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf

	// Execute this to configure the theme
	p10k configure

# Plugins:
// One Dark colour theme
  https://github.com/one-dark/iterm-one-dark-theme

// Look at history of previous commands used:-
  https://github.com/junegunn/fzf

// Command line auto suggestions:-
  https://github.com/zsh-users/zsh-autosuggestions
  
// Quick switch to directories
  https://github.com/agkozak/zsh-z
  
// Found these on this blog post https://udaraw.com/iterm-plugins
UIApplication.shared.open(URL(string: "http://www.google.com")!, options: [:], completionHandler: nil)
/**
 * Provides quick & simple way to verify if some
 * string is valid URL
 *
 * @param   <string>  URL to verify
 * @returns <boolean> Returns true if passed string
 *                    is valid URL, false otherwise
 */
function validateUrl (url) {
    try {
        new URL(url)
    } catch (error) {
        return false
    }
  
    return true
}
// create a schema
const eventSchema = new Schema({
  name: String,
  slug: {
    type: String,
    unique: true
  },
  description: String
});

// create the model
const eventModel = mongoose.model('Event', eventSchema);

// middleware -----
// make sure that the slug is created from the name
eventSchema.pre('save', function(next) {
  this.slug = slugify(this.name);
  next();
});

// function to slugify a name
function slugify(text) {
  return text.toString().toLowerCase()
    .replace(/\s+/g, '-')           // Replace spaces with -
    .replace(/[^\w\-]+/g, '')       // Remove all non-word chars
    .replace(/\-\-+/g, '-')         // Replace multiple - with single -
    .replace(/^-+/, '')             // Trim - from start of text
    .replace(/-+$/, '');            // Trim - from end of text
}
# There are a few ways to change the url in wordpress


# The prefered method is the wp-cli via search-replace.
$ wp search-replace 'http://example.test' 'http://example.com' --skip-columns=guid

# You can also test with a dry run
$ wp search-replace 'foo' 'bar' wp_posts wp_postmeta wp_terms --dry-run


# If the wp-cli is not available or you can't use SSH there are three other ways to try inside the files wp-config and functions.php

# At the beginning of wp-config.php, add
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );

# At the end of the file, before the comment to stop editing here, you can set the relocate method. This always takes the current url calling "/wp-login.php" as slug as site url.
define('RELOCATE',true);

# Inside funcions.php, as first call, you can set
update_option( 'siteurl', 'http://example.com');
update_option( 'home', 'http://example.com');

# Use Plugin

The plugin 'Better search replace' is also able to change the links in the database quite easily.


# As last resort, you can change the database values manually.You will have to look for "siteurl" in the table "wp_options" and change the values to the correct url.

# After changing the url, don't forget to remove the above settings again. Move to your settings in the backend and check the url. Also, inside the options section, look for "permalinks". It will bring you to an options page where you can regenerate the dynamic links. Without this regenerating, links for assets, media files and so an would possibly keep pointing to the old url. 
const urlString = window.location.search
const urlParameters = new URLSearchParams(urlString)

if (urlParameters.has('parameter')) {
  urlParameters.get('parameter')
}
const getURLParameters = url =>
  (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce(
    (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a),
    {}
  );

// Examples
getURLParameters('http://url.com/page?n=Adam&s=Smith'); // {n: 'Adam', s: 'Smith'}
getURLParameters('google.com'); // {}
star

Tue Apr 09 2024 01:29:12 GMT+0000 (Coordinated Universal Time)

#random #image #url
star

Tue Mar 21 2023 06:14:02 GMT+0000 (Coordinated Universal Time)

#searchparams #url #search #id
star

Tue Mar 14 2023 05:33:07 GMT+0000 (Coordinated Universal Time) https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.4.120/pdf.min.js

#cdn #javascript #url #code #html
star

Mon Jan 30 2023 05:15:52 GMT+0000 (Coordinated Universal Time)

#url #detabase
star

Thu Jun 23 2022 15:32:32 GMT+0000 (Coordinated Universal Time) https://usefulangle.com/post/298/javascript-url-hash

#jquery #event #change #hash #url
star

Wed Mar 30 2022 07:50:10 GMT+0000 (Coordinated Universal Time)

#ios #swift #url #geturl
star

Fri Feb 11 2022 23:22:04 GMT+0000 (Coordinated Universal Time)

#url #zsh #ohmyzsh #terminal #ubuntu #git #shell #bash
star

Thu Feb 03 2022 12:20:28 GMT+0000 (Coordinated Universal Time)

#ios #swift #webpage #page #web #url #link
star

Sat Jan 08 2022 17:15:53 GMT+0000 (Coordinated Universal Time)

#javascript #url #validation #string
star

Mon Jun 14 2021 12:21:17 GMT+0000 (Coordinated Universal Time) https://scotch.io/courses/create-a-crud-app-with-node-and-mongodb/a-mongoose-model

#express #nodej #mongodb #mongoose #slug #url
star

Fri Jun 11 2021 14:15:50 GMT+0000 (Coordinated Universal Time) https://developer.wordpress.org/cli/commands/search-replace/, https://wordpress.org/support/article/changing-the-site-url/

#wordpress #configuration #url #network
star

Thu Apr 08 2021 13:13:09 GMT+0000 (Coordinated Universal Time)

#javascript #url
star

Wed Nov 04 2020 08:47:54 GMT+0000 (Coordinated Universal Time) https://medium.com/swlh/24-modern-es6-code-snippets-to-solve-practical-js-problems-3609f301859e

#javascript #http #get #url

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension