Skip to content

Instantly share code, notes, and snippets.

View giansalex's full-sized avatar

Giancarlos Salas giansalex

View GitHub Profile
@giansalex
giansalex / restore-database.sql
Last active July 13, 2018 22:37
Create Database from SQL Server backup.
USE master;
SET
NOCOUNT ON;
DECLARE @pathBackup VARCHAR (500) = N'C:\User\Files\my_backup.bak'; -- Set your backup path
DECLARE @fileListTable TABLE (
[LogicalName] NVARCHAR(128),
[PhysicalName] NVARCHAR(260),
[Type] CHAR(1),
[FileGroupName] NVARCHAR(128),
[Size] NUMERIC(20, 0),
@giansalex
giansalex / only-numbers.html
Created August 4, 2018 16:31
HTML Input only Numbers - Jquery
<!DOCTYPE html>
<html>
<body>
<input type="text" sb-numeric>
<input type="text">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(function () {
$(document).on("input", "input[sb-numeric]", function() {
@giansalex
giansalex / prest.md
Created November 9, 2018 21:21
Prest Postgresql API https://postgres.rest/

Install

go get -u github.com/prest/prest

Run

PREST_PG_USER=postgres \
PREST_PG_PASS=123456 \
PREST_PG_DATABASE=postgres \
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings configSource="database.config" />
</configuration>
@giansalex
giansalex / myproject.csproj
Created January 26, 2019 05:07
ConnectionString ASP.NET MVC for Teams
<Target Name="BeforeBuild">
<Copy SourceFiles="$(ProjectDir)\database.default.config" DestinationFiles="$(ProjectDir)\database.config" Condition="!Exists('$(ProjectDir)\database.config')" />
</Target>
<?xml version="1.0" encoding="UTF-8"?>
<connectionStrings>
<add name="default" connectionString="Data Source=.;Initial Catalog=DB_A;" providerName="System.Data.SqlClient" />
</connectionStrings>
@giansalex
giansalex / php-background.php
Created January 21, 2018 23:09
Execute $cmd in the background (no cmd window) without PHP waiting for it to finish, on both Windows and Unix.
<?php
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}
@giansalex
giansalex / docker.md
Last active July 5, 2019 14:30
Docker - steps to publish

Steps

Build

Go DockerFile's directory, run:

docker build -t local/myimage .

Build

@giansalex
giansalex / create-ssl-dns.ps1
Created September 10, 2019 00:10
Create SSL Certificate LetsEncrypt with DNS Recorde Validation
docker run -t --rm -v "${pwd}":/appc certbot/certbot certonly --manual --preferred-challenges=dns --email admin@domain.com --agree-tos --config-dir /appc/config --logs-dir /appc/logs --work-dir /appc/workdir -d *.domain.com

Keybase proof

I hereby claim:

  • I am giansalex on github.
  • I am giansalex (https://keybase.io/giansalex) on keybase.
  • I have a public key ASA557wjx9Zy1Gd1nmi4v6PI3tsmhg6MSOpIuChAHC3t0wo

To claim this, I am signing this object: