Skip to content

Instantly share code, notes, and snippets.

View LuisEGR's full-sized avatar
🏠
Working from home

Luis E. González LuisEGR

🏠
Working from home
  • Mexico
View GitHub Profile
@LuisEGR
LuisEGR / directive.js
Created January 23, 2017 15:39
Only integer numbers for inputs
var app = angular.module('app', []);
app.directive('numbersOnly', function () {
return {
require: 'ngModel',
link: function (scope, element, attr, ngModelCtrl) {
function fromUser(text) {
if (text) {
var transformedInput = text.replace(/[^0-9]/g, '');
if (transformedInput !== text) {
ngModelCtrl.$setViewValue(transformedInput);
@LuisEGR
LuisEGR / maxNumber.js
Last active January 27, 2017 17:26
Limit the number that user introduce in an input text
app.directive('maxNumber', function () {
return {
require: 'ngModel',
link: function (scope, element, attr, ngModelCtrl) {
function fromUser(text) {
var maxN = parseInt(attr.maxNumber);
if (text) {
if(parseInt(text) > maxN){
ngModelCtrl.$setViewValue(maxN);
ngModelCtrl.$render();
@LuisEGR
LuisEGR / Replication.md
Last active December 4, 2017 01:23
MongoDB Replication

Replicación en MongoDB

A continuación se describe el proceso para realizar una replicación de un servidor MongoDB, teniendo 2 equipos conectados en una red local, el maestro será Windows (192.168.1.70) y el esclavo Mac (192.168.1.68).

Cosas a tener en cuenta:

  • Debe estar instalado MongoDB en ambos equipos
  • Debe existir conexión entre el Maestro y el Esclavo (ping)
  • Si están en una red no local, debe estár abierto el puerto 27017 en ambos equipos
package main
import (
"fmt"
"time"
"github.com/google/uuid"
)
func main() {
module github.com/luisegr/go-live-reload-tutorial
go 1.17
require github.com/google/uuid v1.3.0 // indirect
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
@LuisEGR
LuisEGR / docker-compose.yml
Last active June 10, 2022 17:34
Example docker compose with air - go live-reload
version: "3.3"
services:
mongodb:
image : mongo
container_name: mongo-my-app
ports:
- 27018:27017
restart: always
volumes:
- mongo-vol:/data/db
@LuisEGR
LuisEGR / apis.txt
Last active May 13, 2024 10:58
GCP List of API Services - Updated to Feb 2023
NAME TITLE
abusiveexperiencereport.googleapis.com Abusive Experience Report API
acceleratedmobilepageurl.googleapis.com Accelerated Mobile Pages (AMP) URL API
accessapproval.googleapis.com Access Approval API
accesscontextmanager.googleapis.com Access Context Manager API
actions.googleapis.com Actions API
addressvalidation.googleapis.com Address Validation API
adexchangebuyer-json.googleapis.com Ad Exchange Buyer API
adexchangebuyer.googleapis.com Ad Exchange Buyer API II
@LuisEGR
LuisEGR / gcp-apis-dep.json
Last active February 15, 2023 18:22
GCP Dependencies between Apis
[{
"name": "anthos.googleapis.com",
"dependencies": [
"gkehub.googleapis.com",
"container.googleapis.com"]
}, {
"name": "anthosconfigmanagement.googleapis.com",
"dependencies": [
"anthospolicycontroller.googleapis.com"]
}, {
@LuisEGR
LuisEGR / install_rsync.ps1
Created May 6, 2024 06:10
Install rsync in Windows 11, easy
# Download and install Git for Windows if not already installed
if (-not (Test-Path "C:\Program Files\Git\bin\git.exe")) {
Write-Host "Git for Windows not found. Downloading installer..."
Invoke-WebRequest -Uri "https://github.com/git-for-windows/git/releases/download/v2.31.1.windows.1/Git-2.31.1-64-bit.exe" -OutFile "git-installer.exe"
Write-Host "Installing Git for Windows..."
Start-Process -FilePath ".\git-installer.exe" -ArgumentList "/VERYSILENT" -Wait
Remove-Item ".\git-installer.exe"
}
# Create a temporary directory for downloads