This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url = "https://www.youtube.com/watch?v=zKx2B8WCQuw"; | |
var videoid = url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/); | |
if(videoid != null) { | |
console.log("video id = ",videoid[1]); | |
} else { | |
console.log("The youtube url is not valid."); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_enum_values( $table, $field ) | |
{ | |
$type = $this->db->query( "SHOW COLUMNS FROM {$table} WHERE Field = '{$field}'" )->row( 0 )->Type; | |
preg_match("/^enum\(\'(.*)\'\)$/", $type, $matches); | |
$enum = explode("','", $matches[1]); | |
return $enum; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vimeo_Reg = /(?:https?:\/\/)?(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/; | |
function vimeoID(url) { | |
var match = url.match(vimeo_Reg); | |
if (match){ | |
return "<span>"+match[3]+"</span>"; | |
}else{ | |
return "<span class='error'>error</span>"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_file_extension($file_name = '') { | |
$file_name = (empty($file_name)) ? 'bla.bla..pdf' : $file_name; | |
preg_match('/[^\.]+$/i', $file_name, $ext); | |
return $ext[0]; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmd /k wmic os get installdate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ArrayToURL(array) { | |
var pairs = []; | |
for (var key in array) | |
if (array.hasOwnProperty(key)) | |
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(array[key])); | |
return pairs.join('&'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return an array | |
function get_object_values(obj) { | |
'use strict'; | |
return Object.keys(obj).map(function (k) { | |
return obj[k]; | |
}); | |
} | |
var object_values = get_object_values({key1: "value1", key2: "value2", key3: "value3"}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add the remote, call it "upstream": | |
git remote add upstream https://github.com/whoever/whatever.git | |
# Fetch all the branches of that remote into remote-tracking branches, | |
# such as upstream/master: | |
git fetch upstream | |
# Make sure that you're on your master branch: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.console.time("answer time"); | |
window.alert("Click to continue"); | |
window.console.timeEnd("answer time"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function htmlEncode(value){ | |
//create a in-memory div, set it's inner text(which jQuery automatically encodes) | |
//then grab the encoded contents back out. The div never exists on the page. | |
return $('<div/>').text(value).html(); | |
} | |
function htmlDecode(value){ | |
return $('<div/>').html(value).text(); | |
} |