Skip to content

Instantly share code, notes, and snippets.

View vlrmprjct's full-sized avatar
🎹
Boing boom tschak!

Thomas vlrmprjct

🎹
Boing boom tschak!
View GitHub Profile
@vlrmprjct
vlrmprjct / checkmobile.html
Created March 20, 2014 10:55
Check if is mobile device (Example)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"/>
<title>jQuery Device Orientation</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$.noConflict();
@vlrmprjct
vlrmprjct / getmail.js
Created August 5, 2014 07:57
Function to grab emailadresses from plaintext content.
/**
* FUNCTION TO GRAB EMAILADRESSE FROM ANY PLAINTEXT
* @param text
* @returns {*|Array|{index: number, input: string}}
*/
var getEmail = function(text) {
return text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
}
@vlrmprjct
vlrmprjct / global.js
Created September 22, 2014 16:03
findurl's in string
function findUrls( text )
{
var source = (text || '').toString();
var urlArray = [];
var url;
var matchArray;
// Regular expression to find FTP, HTTP(S) and email URLs.
var regexToken = /(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)|((mailto:)?[_.\w-]+@([\w][\w\-]+\.)+[a-zA-Z]{2,3})/g;
@vlrmprjct
vlrmprjct / url.js
Created October 14, 2014 10:03
How to get current url in JavaScript and jQuery ?
var testurl = http://www.test.com:8082/index.php#tab2?foo=123
// In Javascript:
window.location.host www.test.com:8082
window.location.hostname www.test.com
window.location.port 8082
window.location.protocol http
window.location.pathname index.php
@vlrmprjct
vlrmprjct / attr_selector.js
Created November 18, 2014 08:54
jQuery attr Selector
$('a[href$="ABC"]').foobar();
// http://docs.jquery.com/Selectors
// For attributes:
// = is exactly equal
// != is not equal
// ^= is starts with
// $= is ends with
@vlrmprjct
vlrmprjct / browser_dedect.js
Created January 14, 2015 16:50
Javascript Browser Detection
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "Other";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown";
},
searchString: function (data) {
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;
this.versionSearchString = data[i].subString;
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@vlrmprjct
vlrmprjct / tar_untar.sh
Created June 18, 2015 07:23
tar and untardirectory
# tar directory
tar -czvf Output_File_Name.tar.gz Directory_Name
tar -zcvf demo.tar.gz demo
# which will create a tar file named "demo.tar.gz"
# to untar directory
tar -xzvf Input_File_Name.tar.gz
@vlrmprjct
vlrmprjct / numericonly.js
Created July 16, 2015 08:07
Input Numeric only
// Numeric only control handler
jQuery.fn.ForceNumericOnly =
function()
{
return this.each(function()
{
$(this).keydown(function(e)
{
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY
@vlrmprjct
vlrmprjct / randomkeys.php
Created July 20, 2015 08:49
Get a random alphanumeric string.
/**
* @param $prefix
* @param $suffix
* @param $size
*
* @return string
*/
private function randomKey($prefix, $suffix, $size)
{
$key = "";