Skip to content

Instantly share code, notes, and snippets.

@neeravp
neeravp / laranew.sh
Last active March 15, 2021 01:05
Bash Script to configure a new Laravel application
#!/usr/bin/env bash
# Declare variables of type array to gather information regarding packages
name="$1"
with_jetstream=false
stack=''
teams=false
with_livewire=false
with_inertia=false
with_vue=false
@neeravp
neeravp / nginx.conf
Last active May 17, 2020 20:04
Ngin vhost config file
# Map the Header Accept to the webp format
map $http_accept $webp_suffix {
"~*webp" ".webp";
}
# Path to the directory to store the fastcgi cache files
fastcgi_cache_path /tmp/cache/example levels=1:2 keys_zone=pmquest:23m max_size=1g inactive=60m;
# redirect http to https
server {
listen 80;
@neeravp
neeravp / omixin.js
Last active April 8, 2019 16:31
Function to extend existing object by mixing properties and methods from other objects
function omixin(target, ...sources) {
//This function works only when the target is an object
if(typeof target === 'object') {
sources.forEach(source => {
//When merging from another object
if(typeof source === 'object') {
@neeravp
neeravp / cmixin.js
Last active April 8, 2019 16:12
Function to extend a class by mixing properties and methods from other objects or classes - composition not inheritance
function cmixin(target, ...sources) {
if(typeof target === 'function') {
sources.forEach(source => {
//When composing from an object
if(typeof source === 'object') {
Object.getOwnPropertyNames(source).forEach(prop => {
let descriptor = Object.getOwnPropertyDescriptor(source, prop);
Object.defineProperty(target, prop, descriptor);
@neeravp
neeravp / addMixin.js
Last active April 8, 2019 16:23
Function to mixin properties including getters and setters from one javascript object to another.
function mixin(target, ...sources) {
sources.forEach(source => {
let descriptors = Object.keys(source).reduce((descriptors, key) => {
descriptors[key] = Object.getOwnPropertyDescriptor(source, key);
return descriptors;
}, {});
Object.getOwnPropertySymbols(source).forEach(sym => {
@neeravp
neeravp / readme.md
Created March 14, 2017 13:04 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser