Skip to content

Instantly share code, notes, and snippets.

View shabith's full-sized avatar
😷
Stay Safe

Shabith Ishan Thennakone shabith

😷
Stay Safe
View GitHub Profile
@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 / 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,
@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).

@shabith
shabith / README.md
Last active August 29, 2015 14:08
Javascript Scaffold Template

#Javascript Scaffold Template

##Instructions

Replace PN with Project Name Abbrivation. Make it Simple and CAP, and make sure it doesn't be longer than 3 Characters.

Replace page-name with Page Name (Obviously!). Make it simple and understandable.

##PhpStrom/WebStrom Template

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
@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
(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 / 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="">