Skip to content

Instantly share code, notes, and snippets.

View nivrith's full-sized avatar
🎸
Recreational Mathemusician

Nivrith nivrith

🎸
Recreational Mathemusician
View GitHub Profile
@nivrith
nivrith / sample-nginx.conf
Created July 6, 2018 03:16 — forked from dimitardanailov/sample-nginx.conf
Configuration for Laravel 5 application and Nginx
server {
listen 80 default deferred;
server_name laravel-application.com;
# http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
access_log /var/www/laravel-app/access.log;
error_log /var/www/laravel-app/error.log;
root /var/www/laravel-app/public/;
@nivrith
nivrith / background-image.ts
Created July 6, 2018 06:14 — forked from fer-ri/background-image.ts
Background Image Style Directive for Angular 2 and Ionic 2
import {Directive, ElementRef, Input} from '@angular/core';
@Directive({
selector: '[background-image]'
})
export class BackgroundImage {
private el: HTMLElement;
constructor(el: ElementRef) {
this.el = el.nativeElement;
@nivrith
nivrith / Makefile
Created April 18, 2019 09:22 — forked from kristopherjohnson/Makefile
Makefile that uses Pandoc to generate HTML, PDF, DOCX, etc. from Markdown source files
# Makefile
#
# Converts Markdown to other formats (HTML, PDF, DOCX, RTF, ODT, EPUB) using Pandoc
# <http://johnmacfarlane.net/pandoc/>
#
# Run "make" (or "make all") to convert to all other formats
#
# Run "make clean" to delete converted files
# Convert all files in this directory that have a .md suffix
@nivrith
nivrith / change-git-author
Created July 9, 2019 00:33
Change git Author details
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@nivrith
nivrith / share-instances.webpack.js
Created July 19, 2019 04:21
Share same instance of module across multiple webpack entry points
// webpack config
{
// ....
optimization: {
runtimeChunk: {
name: 'commons' // ← Added to make sure the same instance of module exports is handed over to all bundles
}
}
}
@nivrith
nivrith / erik-meijer-books.md
Created September 27, 2019 01:38
Erik Meijer’s List of Recommended Books

Erik Meijer’s List of Recommended Books

  1. Logic and Computation: Interactive Proof with Cambridge LCF (Cambridge Tracts in Theoretical Computer Science)
  2. Mathematical Theory of Programme Correctness (Prentice-Hall International series in computer science)
  3. The Haskell School of Expression: Learning Functional Programming through Multimedia
  4. LaTeX: A Document Preparation System (2nd Edition)
  5. Denotational Semantics
  6. Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory
  7. Programs and Machines
  8. The Denotational Description of Programming Languages: An Introduction
@nivrith
nivrith / fp.ts
Last active October 2, 2019 01:15
Functional utils
const range = n => n > 0 ? [...range(n-1), n] : [];
const fact = n => n > 0 ? n * factorial(n-1) : 1;
const product = (...list) => list.flat(Infinity).reduce( (result, n) => result * n , 1);
@nivrith
nivrith / slim-queue.ts
Created October 15, 2019 05:46
Ts Queue
class Queue<T> {
constructor(private length: number, private data: T[] = []) {}
add(record) {
var length = this.data.unshift(record);
if (length > this.length) {
this.remove();
}
}
@nivrith
nivrith / file-extension.ts
Created November 4, 2019 03:25
Get File extension from filename
const fileExt = filename => {
const ext = f => (/[.]/.exec(f)) ? /[^.]+$/.exec(f) : RegExp(f).exec(f);
const resultExp = ext(filename);
return resultExp ? resultExp[0] : filename;
};
@nivrith
nivrith / serve.ts
Last active October 6, 2020 02:54
TS Node Script to Pass Custom command-line Args to Angular serve process
import * as yargs from 'yargs';
import { spawn } from 'child_process';
import { DEFAULT_APP_ENV } from './app-env';
const parseNgArgs = () => process.argv.filter((arg, index) => index > 1 && Object.keys(DEFAULT_APP_ENV).every(key => !arg.includes(key)));
const ngArgs = parseNgArgs();
const argv = { ...DEFAULT_APP_ENV, ...yargs.argv};