Skip to content

Instantly share code, notes, and snippets.

@mshanak
mshanak / cli_helpers.h
Last active January 23, 2025 08:18
This C++ code provides a reusable template function parseArgument designed to simplify command-line argument parsing in applications. The function allows users to retrieve and validate parameters of various types (strings, integers, floats) by specifying a parameter name (e.g., --port). It automatically assigns a default value if the parameter i…
#include <iostream>
#include <string>
#include <stdexcept> // For exception handling
template <typename T>
void parseArgument(int argc, char *argv[], const std::string& paramName, T& var, T defaultValue) {
for (int i = 1; i < argc; ++i) {
if (std::string(argv[i]) == paramName) {
if (i + 1 < argc) {
if constexpr (std::is_same<T, std::string>::value) {
@mshanak
mshanak / AuthServiceProvider.php
Created June 24, 2017 13:55
laravel Passport CORS : AuthServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Route;
use Laravel\Passport\Passport;
@mshanak
mshanak / designer.html
Created January 26, 2015 08:20
designer
<link href="../core-icons/core-icons.html" rel="import">
<link href="../core-icons/av-icons.html" rel="import">
<link href="../paper-fab/paper-fab.html" rel="import">
<polymer-element name="my-element">
<template>
<style>
#design_host {
position: absolute;
@mshanak
mshanak / designer.html
Last active August 29, 2015 14:14
designer
<link href="../core-scaffold/core-scaffold.html" rel="import">
<link href="../core-header-panel/core-header-panel.html" rel="import">
<link href="../core-menu/core-menu.html" rel="import">
<link href="../core-item/core-item.html" rel="import">
<link href="../core-icon-button/core-icon-button.html" rel="import">
<link href="../core-toolbar/core-toolbar.html" rel="import">
<link href="../core-menu/core-submenu.html" rel="import">
<link href="../core-input/core-input.html" rel="import">
<link href="../paper-button/paper-button.html" rel="import">
<link href="../paper-input/paper-input.html" rel="import">