Skip to content

Instantly share code, notes, and snippets.

View shabith's full-sized avatar

Shabith Ishan Thennakone shabith

View GitHub Profile
@shabith
shabith / init-html5.html
Last active December 8, 2022 16:51
HTML5: Starting Template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title></title>
</head>
<body>
@shabith
shabith / gist:9801530
Last active November 4, 2021 12:51
Regex to extract video ID from Vimeo or Youtube URL
//check for video URL
/* http://lasnv.net/foro/839/Javascript_parsear_URL_de_YouTube */
var video_id_regExp = /^.*((youtu.be\/|vimeo.com\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/,
match = url.match(video_id_regExp),
video_id;
if (match&&match[7]){
//valid
@shabith
shabith / pre-push
Last active April 6, 2017 07:57
git hook with confirmation message
#!/bin/sh
# https://gist.github.com/shabith/653a29ed1e9835e71fb0a4662523cf85
# git hook with confimation message
# this pre-push git hook will show a confirmation message and according to the answer (y or n) by user it will proceed or exit.
# Please note that this has been tested only in OSX terminal
# Allow us to read user input below, assigns stdin to keyboard
exec < /dev/tty
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
@shabith
shabith / HTML5 Template (IE7 safe)
Last active May 13, 2016 10:58
HTML5 template with IE7 support
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="">
@shabith
shabith / tsconfig.json
Created January 31, 2016 04:31
Typescirpt config file
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "tmp",
"target": "es5",
"module": "system",
"moduleResolution": "node",
"removeComments": false,
"sourceMap": true,
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@shabith
shabith / gist:4129070
Created November 22, 2012 02:17
Check for HTML5 support in browser
/**
* Assume we want to check the placeholder HTML5 feature support in input element.
* Credit should go to Daniel Stocks, I found this on his placeholder plugin
* (https://github.com/danielstocks/jQuery-Placeholder/blob/master/jquery.placeholder.js#L71)
*/
var NATIVE_SUPPORT = !!("placeholder" in document.createElement( "input" ));
/**
* Assume we want to check for HTML5 cavas support.
@shabith
shabith / gist:3888174
Created October 14, 2012 10:16
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@shabith
shabith / .htaccess
Last active August 29, 2015 14:24 — forked from ScottPhillips/.htaccess
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/

Note: Some of these shortcuts have been remapped for my own convenience (Preferences->Keymap). These are Mac shortcuts, just use the Windows/Linux equivalent of the Cmd/Option/Ctrl/Del keys.

####Search, Go to, Navigation ####

Cmd + P - Search file

Cmd + Shift + O - Search everywhere

(I swapped the above two recently because I use Cmd + P to search for files most of the time).