Skip to content

Instantly share code, notes, and snippets.

@sangheestyle
sangheestyle / httpRequest.js
Last active November 21, 2018 23:09
Three different ways with https.get() in node.js
const https = require('https');
https.get('https://google.com', resp => {
let data = '';
resp.on('data', chunk => data += chunk);
resp.on('end', () => console.log(data));
}).on('error', err => console.log(`Error: ${err}`));
@sangheestyle
sangheestyle / package.json
Last active November 19, 2018 18:41
Practice adal node.js
{
"name": "practice_adal",
"version": "0.0.1",
"description": "Nothing special",
"main": "index.js",
"scripts": {
"start": "ts-node server.ts"
},
"author": "",
"license": "ISC",
@sangheestyle
sangheestyle / app.py
Created November 19, 2018 17:05
Practice adal python for certificate credentials
"""
Requirement:
Generate key pairs:
```
openssl genrsa -out server.pem 2048
openssl req -new -key server.pem -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.pem -out server.crt
```
@sangheestyle
sangheestyle / app.ts
Created November 18, 2018 22:10
Practice Ramda.js
// Practice Ramda
import * as R from 'ramda'
const guys: Array<string> = ["Tom", "Jim"]
const ladies: Array<string> = ["Marry", "Jane"]
// any
R.any(x => x == "Tom")(guys); // true
R.any(x => x == "Tony")(guys); // false
// TS basic types
// from https://www.typescriptlang.org/docs/handbook/basic-types.html
// Boolean
let isDone: boolean = false;
// Number (floating point values like JS)
let decimal: number = 6;
let float: number = 6.1;
let hex: number = 0xf00d;
@sangheestyle
sangheestyle / app.ts
Created November 17, 2018 20:45
Practice the observer pattern in typescript
import { Subject } from "./subject";
import { Observer } from "./observer";
const subject = new Subject();
const observer1 = new Observer('John');
const observer2 = new Observer('Tae');
const observer3 = new Observer('Jin');
subject.subscribe(observer1);
subject.subscribe(observer2);
@sangheestyle
sangheestyle / adult.ts
Created November 17, 2018 17:36
Practice the factory pattern in typescript
import { Person } from "./person";
export class Adult extends Person {
getStatus(): void {
console.log('I am an adult!');
}
}
@sangheestyle
sangheestyle / app.ts
Last active November 17, 2018 17:14
Practice the Facade Pattern in typescript
import { Facade } from "./facade";
const facade: Facade = new Facade();
const isEligibile: boolean = facade.checkEligibility();
console.log(`You are${isEligibile ? '' : 'not'} eligible.`);
@sangheestyle
sangheestyle / Program.cs
Created November 16, 2018 13:06
C# event practice
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Counter c = new Counter(new Random().Next(10));
c.ThresholdReached += c_ThresholdReached;
@sangheestyle
sangheestyle / README.md
Created November 14, 2018 12:40
Creating PowerShell module from Mac

Creating PowerShell module from Mac

Requirement

Install up-to-date PowerShell Core.

$brew cask install powershell
...
$ pwsh --version