Skip to content

Instantly share code, notes, and snippets.

View aramkoukia's full-sized avatar
🏠
Working from home

Aram Koukia aramkoukia

🏠
Working from home
View GitHub Profile
@aramkoukia
aramkoukia / behavior-factories.js
Created December 18, 2016 20:37
behavior-factories defining the behaviours
var speaker = function (state) {
var words = state.words;
return {
talk: function () {
console.log(state.name + ' says ' + words);
}
};
};
@aramkoukia
aramkoukia / object-factories.js
Created December 18, 2016 20:40
object-factories creating objects and assign behaviors sample
var person = function (name, age) {
var state = {
name: name,
age: age,
words: 'Hello'
};
return Object.assign( // Merge our 'behavior objects
{},
speaker(state),
@aramkoukia
aramkoukia / composition-over-inheritance-usage.js
Created December 18, 2016 20:43
composition-over-inheritance-usage
var James = person('James', 36);
fred.talk(); // outputs: James says Hello
fred.walk(); // outputs: James is walking
var myOwl = owl('SleepyOwl', 'grey');
myOwl.walk(); // outputs: SleepyOwl is walking
myOwl.run(); // outputs: SleepyOwl is running
myOwl.talk(); // ERROR: myOwl.talk is not a function
CREATE PROC SearchAllTables ( @SearchStr nvarchar(100) ) AS
BEGIN
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
SET NOCOUNT ON
DECLARE @TableName nvarchar(256),
@ColumnName nvarchar(128),
@SearchStr2 nvarchar(110)
@aramkoukia
aramkoukia / es6-js-class.js
Last active December 22, 2016 17:49
JavaScript Class, Class constructor and usage
class Profile {
constructor(name) {
console.log('User ${name} was created.');
this.name = name;
}
}
// How to instantiate the class
const user = new MyClass('Aram'); // logs: "User Aram was created"
@aramkoukia
aramkoukia / es6-javascript-inheritance.js
Last active December 22, 2016 17:49
Inheritance in JavaScript ES6
class Car {
constructor() {
this.logger = console.log;
}
log() {
this.logger(`Hello ${this.name}`);
}
}
class SuvCar extends Car {
@aramkoukia
aramkoukia / es6-javascript-static-methods.js
Created December 22, 2016 17:51
ES6 JavaScript static methods definition
class MyClass {
static myStaticMethod() {
return 'Hello';
}
static get myStaticProperty() {
return 'Goodbye';
}
}
@aramkoukia
aramkoukia / SQL Filling NULL values with Preceding Non-NULL values - Option 1.sql
Created December 22, 2016 18:13
SQL Filling NULL values with Preceding Non-NULL values - Option 1
;With
CTE1 AS (
SELECT Id, ProductName , ROW_NUMBER() OVER(ORDER BY Id ) AS RowId FROM @MyTable ),
CTE2 AS (
SELECT ProductName, RowId, RowId As MyGroup
FROM CTE1 WHERE [Group] IS NOT NULL
Union All SELECT A.ProductName, A.RowId, B.MyGroup
FROM CTE1 A
INNER JOIN CTE2 B
On A.RowId = B.RowId + 1 Where A.[Group] IS NULL )
@aramkoukia
aramkoukia / Filling NULL values with Preceding Non-NULL values - Option 2.sql
Created December 22, 2016 18:15
Filling NULL values with Preceding Non-NULL values - Option 2
-- First of all I'll just put the data from my main table into a temp table
-- just to make sure i am not destroying the actual data if something went wrong.
SELECT * INTO #Temp FROM ImportedSales;
;With CTE As
(
SELECT ProductName , Id , COUNT(ProductName)
OVER(ORDER BY Id ROWS UNBOUNDED PRECEDING) As MyGroup FROM #Temp ), GetProduct AS (
SELECT [ProductName] , First_Value(ProductName)
OVER(PARTITION BY MyGroup
ORDER BY Id ROWS UNBOUNDED PRECEDING
@aramkoukia
aramkoukia / angular-built-in-pipe.ts
Created December 27, 2016 17:56
angular built-in pipe sample
import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'hotel-reservation',
templateUrl: './hotel-reservation.template.html'
})
export class HotelReservationComponent {
public fName: string = 'Joe';
public lName: string = 'SCHMO';