Skip to content

Instantly share code, notes, and snippets.

@paulund
paulund / javascript-copy-paste.js
Created August 26, 2018 12:54
Copy variable contents to the user clipboard
copyText (textToCopy) {
this.copied = false
// Create textarea element
const textarea = document.createElement('textarea')
// Set the value of the text
textarea.value = textToCopy
// Make sure we cant change the text of the textarea
@kamermans
kamermans / url_cleaner.php
Created June 6, 2017 18:07
PHP function to cleanup/re-encode a URL
<?php
$url = 'http://foo.com/path with spaces/index.php?something=something else#foo-29 32';
$reencode_url = function ($url) {
$url_parts = parse_url($url);
// Add scheme
$scheme = array_key_exists('scheme', $url_parts)? $url_parts['scheme']: 'http';
$new_url = "$scheme://";
@kamermans
kamermans / mysql_countries.sql
Created December 7, 2011 04:43
MySQL Dump - continents and countries with 2 and 3 char codes, names and full names - Braintree compatible as of Dec 2011
/**
* Continents and Countries MySQL Tables compiled from Wikipedia, Braintree Payments documentation
* and a couple other places I don't recall at the moment. This data is compatible with the Braintree
* Payment API as of Dec 2011
*
* Compiled by Steve Kamerman, 2011
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------