Skip to content

Instantly share code, notes, and snippets.

View enab-dev's full-sized avatar

Bane Debeljevic enab-dev

View GitHub Profile
@enab-dev
enab-dev / SQL Table Schema
Created February 2, 2015 21:24
Get the column names, data types, max lengt, precision, scale, nullable flag and primary key flag from a SQL table
/* Get the column names, data types, max lengt, precision, scale, nullable flag and primary key flag from a SQL table. Works for SQL 2005 and above. Simply replace the 'TABLE_NAME_HERE' with your table name. */
SELECT
c.name 'Column Name',
t.Name 'Data type',
c.max_length 'Max Length',
c.precision ,
c.scale ,
c.is_nullable,
ISNULL(i.is_primary_key, 0) 'Primary Key'
FROM
@enab-dev
enab-dev / angular.numbers_only.js
Created June 4, 2014 03:58
AngularJS Directive To Allow Only Numbers and CTRL+C or CTRL+V
.directive('numbersOnly', function () {
return {
restrict: 'A',
link: function (scope, elm, attrs, ctrl) {
// record ctrl key being down for ctrl+v and ctrl+c
var ctrlDown = false;
// reset the ctrl key flag on keyup
elm.on('keyup', function (event) {
ctrlDown = false;
});
@enab-dev
enab-dev / profile.ps1
Last active August 29, 2015 13:58
Windows Powershell custom profile file
set-alias np C:\Windows\notepad.exe
set-alias subl "C:\Program Files\Sublime Text 3\sublime_text.exe"
set-alias grep select-string
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() )
$isAdmin = $currentPrincipal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator )
$host.ui.RawUI.BackgroundColor = [ConsoleColor]::Black
function prompt
{
@enab-dev
enab-dev / Linux: .bash_profile
Created March 26, 2014 06:30
.bashrc for Linux. Assumes Sublime Text is installed and accessible from the bash shell via the 'subl' command
alias c='clear'
alias 1='clear; ls -1F --color=always | more'
alias 2='clear; ls -lF --color=always | more'
alias 3='clear; ls -laF --color=always | more'
alias hosts='subl /private/etc/hosts'
PS1='\[\e[31m\][\[\e[34m\]$PWD\[\e[31m\]]\[\e[0m\]# '
export PATH=/usr/local/bin:$PATH::
shopt -s extglob
umask 022
@enab-dev
enab-dev / OSX: .bash_profile
Created March 26, 2014 06:25
.bash_profile file for OSX. Assumes Sublime Text is installed and usable via command line using 'subl" command.
alias c='clear'
alias 1='clear; CLICOLOR_FORCE=1; ls -1FG | more -R; CLICOLOR_FORCE=0'
alias 2='clear; CLICOLOR_FORCE=1; ls -lFG | more -R; CLICOLOR_FORCE=0'
alias 3='clear; CLICOLOR_FORCE=1; ls -laFG | more -R; CLICOLOR_FORCE=0'
alias hosts='subl /private/etc/hosts'
PS1='\[\e[31m\][\[\e[34m\]$PWD\[\e[31m\]]\[\e[0m\]# '
export PATH=/usr/local/bin:$PATH::
shopt -s extglob
umask 022
@enab-dev
enab-dev / node.js: update node via npm
Created March 26, 2014 05:42
Update node.js via npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
@enab-dev
enab-dev / C#: Singleton
Last active January 3, 2016 02:29
Simple Singleton pattern implementation using System.Lazy<T>. The extending class needs to implement a private parameterless constructor to complete the pattern. Generic type parameter passed to Singleton should be the extending class type.
using System;
public abstract class Singleton<T> where T : class
{
private static readonly Lazy<T> _instance = new Lazy<T>(() => CreateInstance());
public static T Instance { get { return _instance.Value; } }
private static T CreateInstance()
{