Skip to content

Instantly share code, notes, and snippets.

View sampathsl's full-sized avatar
😊
It's working ....

Sampath Thennakoon sampathsl

😊
It's working ....
View GitHub Profile
package main
import (
"database/sql"
"log"
_ "github.com/go-sql-driver/mysql"
)
func main() {
db, err := sql.Open("mysql", "root:@tcp(:3306)/test")
@sampathsl
sampathsl / gist:69658c600735cc440022
Last active September 21, 2015 22:18 — forked from moraes/gist:2141121
LIFO Stack and FIFO Queue in golang
package main
import (
"fmt"
)
type Node struct {
Value int
}
@sampathsl
sampathsl / ConflictFix.js
Last active December 13, 2015 13:31
jQuery with Prototype usage
// Code that uses other library's $ can follow here.
var jQuery = $.noConflict(true);
@sampathsl
sampathsl / jquery_multiple_version_fix.js
Last active December 13, 2015 13:31
jQuery multiple versions in a single page
jQuery.noConflict();
@sampathsl
sampathsl / index4.js
Created December 13, 2015 13:34
ES6 Class Support
class Vehicle {
constructor(){
this.type = 'Vehicle';
}
getBrand(val){
console.log('Type: ' + val + ', This is a ' + this.type);
}
}
class Car extends Vehicle{
@sampathsl
sampathsl / index3.js
Created December 13, 2015 13:36
ES6 - Const keyword
const PI = Math.PI;
console.log(PI);
//Can not assign value - TypeError: invalid assignment to const 'PI'
//PI = '1';
@sampathsl
sampathsl / index2.js
Created December 13, 2015 13:38
ES6 - var vs let keywords
let checkDataLet = 'Test';
console.log('Outside let showES6Features: ' + checkDataLet);
while(true){
//let key word
let checkDataLet = 'Poop!';
console.log('Inside let showES6Features: ' + checkDataLet);
break;
}
@sampathsl
sampathsl / index5.js
Last active December 13, 2015 14:46
Arrow Function Usage
//ES 5
function isBigEnough(value) {
return value >= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
console.log(filtered);
//ES 6
let filtered_extended = [12, 5, 8, 130, 44].filter((e) => {
return e >= 10;