Skip to content

Instantly share code, notes, and snippets.

View samonzeweb's full-sized avatar

Samuel GAY samonzeweb

View GitHub Profile
@samonzeweb
samonzeweb / Program.cs
Created May 17, 2021 12:09
ASP.NET Core : open browser on start, and stop server from browser.
// This exemple shows :
// * how to start an app with a free local port
// * how to find urls used and open a brower
// * how to stop the server
//
// Of course it's not production ready, it's a simple howto/reminder.
//
// Some part are come from :
// https://andrewlock.net/how-to-automatically-choose-a-free-port-in-asp-net-core/
@samonzeweb
samonzeweb / fix.md
Last active January 1, 2020 11:07
Node does not detect file changes (dev server)

Modification temporaire

sudo -s

cat /proc/sys/fs/inotify/max_user_watches
8192

echo 524288 > /proc/sys/fs/inotify/max_user_watches
@samonzeweb
samonzeweb / dependency.rb
Last active December 6, 2018 14:56
Extract and display nuget packages dependencies
#! /usr/bin/env ruby
# Parse all NuGet packages under the package directory and print
# all packages names followeb by its dependencies. The format
# is not pretty, but useful combined with 'grep'.
require 'zip' # rubyzip
require 'rexml/document'
Dir.glob("packages/**/*.nupkg").each do |nupkg|
@samonzeweb
samonzeweb / godb_decimal.go
Created April 19, 2018 12:09
Use of github.com/shopspring/decimal with SQL Server (through godb)
package main
import (
"fmt"
"github.com/samonzeweb/godb"
"github.com/samonzeweb/godb/adapters/mssql"
"github.com/samonzeweb/godb/dbreflect"
"github.com/shopspring/decimal"
)
@samonzeweb
samonzeweb / asp.net-core.json
Created March 27, 2018 13:55
VS Code snippets for APS.NET Core
{
"ASP.NET Core MVC Controller": {
"prefix": "controller",
"description": "A minimal ASP.NET Core MVC controller.",
"body": [
"using System;",
"using System.Collections.Generic;",
"using System.Linq;",
"using System.Threading.Tasks;",
"using Microsoft.AspNetCore.Mvc;",
@samonzeweb
samonzeweb / backup-all-databases.ps1
Created March 9, 2018 15:23
Backup all SQL Server databases with PowerShell
# SQL Server parameters
$serverInstance = 'localhost'
# Backup parameters
$backupDirectory = 'C:\path\to\backup\dir'
$retentionDays = 10
# Mail parameters
$mailFrom = '[email protected]'
$mailTo = '[email protected]'
@samonzeweb
samonzeweb / purge.ps1
Created March 9, 2018 13:41
Remove folders created more than X days in PowerShell
# Script parameters
$pathToClean = 'C:\paht\to\somewhere'
$maxDays = 5
# Computed values, don't touch below
$dateLimit = (Get-Date).AddDays(-1 * $maxDays)
Get-ChildItem $pathToClean |
Where { $_.CreationTime -lt $dateLimit } |
Remove-Item -Recurse #-WhatIf
@samonzeweb
samonzeweb / fwsql.ps1
Created March 9, 2018 10:12
Open firewall ports for SQL Server with PowerShell
# SQL Sever & firewall : https://docs.microsoft.com/en-us/sql/sql-server/install/configure-the-windows-firewall-to-allow-sql-server-access
# New-NetFirewallRule : https://docs.microsoft.com/en-us/powershell/module/netsecurity/new-netfirewallrule?view=win10-ps
New-NetFirewallRule -DisplayName "SQLServer default instance" -Direction Inbound -LocalPort 1433 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "SQLServer Browser service" -Direction Inbound -LocalPort 1434 -Protocol UDP -Action Allow
@samonzeweb
samonzeweb / goandvue.go
Last active December 17, 2022 17:35
Go and Vue.js development
package main
// ----------
// How to developp with Vue.js and golang (or other JS framework)
// (awful almost raw notes)
//
// ----------
// Create a projet ClientVue with vue-cli
//
// For developpment with webpack add a proxy to
@samonzeweb
samonzeweb / Caddyfile
Created December 27, 2017 11:54
Proxy API to avoid CORS problems during JS development
# Proxy API to avoid CORS problems during development :
# - Get Caddy from https://caddyserver.com/
# - Put the Caddyfile somewhere with the Caddy executable
# - Change posts, paths, ... as needed
# - Start the Caddy process (without args)
# - Lauch the SPA using the URL http://localhost:8081
localhost:8081
log stderr