Skip to content

Instantly share code, notes, and snippets.

View gayanvirajith's full-sized avatar
:octocat:

Gayan Virajith gayanvirajith

:octocat:
View GitHub Profile
@gayanvirajith
gayanvirajith / enable-ssh-on-ubuntu.md
Last active August 29, 2015 14:23
Enable ssh on ubuntu

Enable ssh on ubuntu

How do I configure a new Ubuntu installation to accept ssh connections?

Credit link

sudo apt-get update

sudo apt-get install openssh-server

@gayanvirajith
gayanvirajith / yoeman-gh-pages.md
Last active August 29, 2015 14:24
How to put yoeman webapp in github gh-pages

Reference: http://yeoman.io/learning/deployment.html

Git subtree command

You can also maintain the source and built code on the same branch, and deploy only the dist directory with the git subtree command.

  1. Remove the dist directory from the .gitignore file. Yeoman projects ignore it by default.
  2. Add the dist directory to your repository:
@gayanvirajith
gayanvirajith / formatArrayIntoComma.js
Created July 23, 2015 11:14
Join the elements in an javascript array, but let the last separator be different eg: `and` / `or`
/*
* Join the elements in an javascript array,
* but let the last separator be different eg: `and` / `or`
* Stackoverflow link: http://stackoverflow.com/questions/15069587/is-there-a-way-to-join-the-elements-in-an-js-array-but-let-the-last-separator-b
* Credit: Chris Barr - http://stackoverflow.com/users/79677/chris-barr
*/
function formatArray(arr){
var outStr = "";
if (arr.length === 1) {
outStr = arr[0];
@gayanvirajith
gayanvirajith / change-engine-type.sql
Last active August 29, 2015 14:27
Change mysql database engine
-- ----------
-- http://dev.mysql.com/doc/refman/5.0/en/converting-tables-to-innodb.html
-- ----------
SELECT CONCAT('ALTER TABLE ',TABLE_NAME,' ENGINE=InnoDB;') FROM INFORMATION_SCHEMA.TABLES
WHERE ENGINE='MyISAM'
AND table_schema = 'mydatabase'
-- -------
-- To very run
@gayanvirajith
gayanvirajith / after-render.js
Created August 26, 2015 06:25
Angular after render directive trick
define(['angular'], function (angular) {
'use strict';
return angular.module('app.common.after-render', [])
.directive('afterRender', [ '$timeout', function($timeout) {
var def = {
restrict : 'A',
terminal : true,
transclude : false,
link : function(scope, element, attrs) {
@gayanvirajith
gayanvirajith / index.html
Created September 1, 2015 14:15
Angular directive template - avoid round trip to the server by having script tag with an id
<!--
Credit:
Dave Smith - Deep Dive into Custom Directives - NG-Conf 2014
https://www.youtube.com/watch?v=UMkd0nYmLzY&list=WL&index=24
-->
<script type="text/ng-template"
id="/partials/my-social-buttons.html"></script>
@gayanvirajith
gayanvirajith / mysql-backup.sh
Last active July 7, 2017 04:38
Backup mysql databases into seperate sql files
#!/bin/bash
# Credit goes to jruzafa
# stackoverflow link - http://stackoverflow.com/questions/9497869/export-and-import-all-mysql-databases-at-one-time
USER="root"
PASSWORD=""
#OUTPUT="/Users/rabino/DBs"
# Parent backup directory
@gayanvirajith
gayanvirajith / top-10-large-directories-command.sh
Created June 20, 2016 04:59
Get the top 10 largest directories on Linux
# Credit: http://www.keyboardninja.eu/linux/find-the-10-largest-directories-in-linux
du -BM / | sort -n -r | head -n 10
@gayanvirajith
gayanvirajith / lsof-check.sh
Created July 11, 2016 09:17
Find process locking port 3000 on Mac
# Credit: http://stackoverflow.com/a/3855359
lsof -i tcp:3000
@gayanvirajith
gayanvirajith / how-to-install-node-in-ubuntu.md
Last active July 25, 2016 04:08
How to install node & npm on ubuntu 16