Skip to content

Instantly share code, notes, and snippets.

View saostad's full-sized avatar
🤠

saostad

🤠
View GitHub Profile
@saostad
saostad / typescript-typescript-type-required-fields-based-on-other-fields.ts
Created July 7, 2021 21:21
typescript type required fields based on other fields
type a = {
c: "Hello";
/** ggg */
d: boolean;
e?: never;
} | {
c: "World";
d?: never;
/** hhh */
e: string;
@saostad
saostad / decode-base64-columns.sql
Last active August 18, 2021 13:30
How to decode base64 columns inline with T-SQL query
SELECT convert(varchar(max),cast(N'' as xml).value('xs:base64Binary(sql:column("MBAMPolicy.EncodedComputerName0"))', 'VARBINARY(MAX)')) AS [Computer Name]
@saostad
saostad / MyAuthenticationProvider.ts
Last active March 11, 2021 14:31
get Azure graph token by custom authentication provider by client_id and client_secret
import { AuthenticationProvider } from "@microsoft/microsoft-graph-client";
const axios = require("axios").default;
const qs = require("qs");
const msGraph_AuthUrl = process.env.msGraph_AuthUrl;
const msGraph_client_id = process.env.msGraph_client_id;
const msGraph_client_secret = process.env.msGraph_client_secret;
const msGraph_tenant_id = process.env.msGraph_tenant_id;
export class MyAuthenticationProvider implements AuthenticationProvider {
/**
* This method will get called before every request to the msgraph server
@saostad
saostad / read_from_windows_credential_manager.cpp
Last active February 26, 2021 03:38
read_from_windows_credential_manager.cpp
#include <Windows.h>
#include <WinCred.h>
#include <iostream>
using namespace std;
main()
{
PCREDENTIALA cred;
@saostad
saostad / clean-up-boot-partition-ubuntu.md
Created June 24, 2020 15:29 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@saostad
saostad / project-folder-structure.md
Last active April 14, 2020 13:49
project folder structure

folder name to keep all:

  • [logs]
  • [docs]
  • [dist]
  • [bin]
  • [genearated]
  • [src] parent folder
    • [services] io related codes
    • [helpers] small functions to data massage
  • [templates]
@saostad
saostad / git-commit-prefixes.md
Last active March 16, 2021 00:30
git commit prefixes

it's recommended to have separate commit for each change

order in commit messages when multi line needed:

  • pub: x.x.x /** publish in package repository version: semver majon.minor.bugfix == breaking.feat.fix */
  • breaking: /** explanation of breaking change */
  • feat: /** added a feature */
  • fix: /** bug fix */
  • enhance: /** improve existing functionality (mostly performance) */
  • depricate: /** deprication of existing functionality */

generated typescript type definitions and functions to interact with ProjectSight api

Steps:

  • get ProjectSight api swagger spec and save it as file project-sight-api-spec.json
  • download latest version of swagger-codegen
  • generate type def and functions with swagger-codegen (it's a Java command line tool)
    • Oracle JRE needed to run command
  • command to generate the types java -jar swagger-codegen-cli.jar generate -l typescript-node -o ./api/ -i ./project-sight-api-spec.json --config typescript-node.json
@saostad
saostad / index.js
Created October 14, 2019 15:07 — forked from akexorcist/index.js
Axios post method requesting with x-www-form-urlencoded content type
const axios = require('axios')
const qs = require('querystring')
...
const requestBody = {
name: 'Akexorcist',
age: '28',
position: 'Android Developer',
description: 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/',
@saostad
saostad / GitHub-GraphQL-PowerBI.m
Created August 13, 2019 18:31 — forked from petrsvihlik/GitHub-GraphQL-PowerBI.m
Loading GraphQL data (GitHub API v4) into PowerBI
// This script shows how to use M language (Power Query Formula Language)
// to read data from GitHub API v4 using a POST request.
// This can come in handy when building PowerBI reports that utilize GraphQL endpoints for loading data.
let
Source = Web.Contents(
"https://api.github.com/graphql",
[
Headers=[
#"Method"="POST",