Skip to content

Instantly share code, notes, and snippets.

View devdilson's full-sized avatar
🎯
Focusing

Dil A. devdilson

🎯
Focusing
  • Spain
View GitHub Profile
@devdilson
devdilson / ec2.sh
Last active May 31, 2021 15:56
User data script for EC2 instance which install apache and creates a html page with Hello world message
#!/bin/bash
########################################
##### USE THIS WITH AMAZON LINUX 2 #####
########################################
# get admin privileges
sudo su
# install httpd (Linux 2 version)
@devdilson
devdilson / DynamicallyCreateInstanceTest.java
Created May 17, 2021 09:39
Create object instances from class type dynamically
package com.test;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@devdilson
devdilson / nginx.conf
Created May 15, 2021 10:48
Nginx Centos Reverse Proxy
load_module '/usr/lib64/nginx/modules/ngx_stream_module.so';
events {}
stream {
server {
listen 8484; # expose port
proxy_pass 127.0.0.1:8485; # port exposed in localhost
}
}
@devdilson
devdilson / Fixboot.
Created May 6, 2021 20:48
Fix boot Windows 10
https://social.technet.microsoft.com/Forums/windows/pt-BR/6b16586e-574d-4a0b-ad68-aafcc7c599d1/bcdboot-failure-when-attempting-to-copy-boot-files?forum=w7itproinstall
Fix windows 10 boot:
Boot with Windows nstallation DVD, select repair and open a command prompt.
Type diskpart
Type select disk 0
Type list partition
@devdilson
devdilson / cloud.init.sh
Last active May 15, 2023 06:47
Provision user called "server" with ssh and install docker/docker-compose in Scaleway cloud
#!/bin/bash
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker
adduser server
usermod -aG docker server
mkdir /home/server/.ssh &
\cp -rf /root/.ssh /home/server/.ssh
@devdilson
devdilson / cloudflare-s3.ts
Created April 24, 2021 14:04
Generate a S3 pre-signed url using cloudflare worker.
import * as AWS from 'aws-sdk';
# Your S3 compatible API secrets
declare var AWS_ACCESS_KEY: string;
declare var AWS_SECRET_ACCESS_KEY: string;
# Your endpoint and bucket name.
const S3_ENDPOINT = 'example.myapp.xyz';
const S3_BUCKET = 'mybucket';
const s3 = new AWS.S3({
credentials: new AWS.Credentials(AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY),
endpoint: new AWS.Endpoint(S3_ENDPOINT),
@devdilson
devdilson / .eslintrc.json
Created April 12, 2021 14:19
Exclude specific library using o-restricted-imports
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
@devdilson
devdilson / draggleble.directive.ts
Created November 16, 2020 07:00
A very simple draggable directive.
import { Directive, ElementRef, HostListener } from '@angular/core';
/**
* Prevents the event and stop the propagation.
*/
function StopEvent(): any {
return (target: any, propqrtyKey: string, descriptor: PropertyDescriptor) => {
const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
if (args[0] instanceof Event) {
@devdilson
devdilson / StartServer.bat
Created October 25, 2020 11:26
Start server
@echo off
SET CURRENT_PATH=%~dp0\AuditionServer
SET PAUSE_TIME=1
SET CONTEXT=LoginDBAgent
SET CONTEXT_EXEC=LoginDBAgentPay.exe
CALL :run_server
SET CONTEXT=ItemDBserver
SET CONTEXT_EXEC=ItemDBServer.exe
@devdilson
devdilson / client.sh
Last active October 6, 2020 20:59
Helper for downloading Nexon files
#!/bin/bash
PATH=$PATH:"/C/dev/apps/wget/bin"
for i in {134..200}
do
wget -x -nH http://download2.nexon.net/Game/MapleStory/FullVersion/$i/MSSetupv$i.z01 & pids[2]=$!
wget -x -nH http://download2.nexon.net/Game/MapleStory/FullVersion/$i/MSSetupv$i.z02 & pids[3]=$!
wget -x -nH http://download2.nexon.net/Game/MapleStory/FullVersion/$i/MSSetupv$i.z03 & pids[4]=$!
wget -x -nH http://download2.nexon.net/Game/MapleStory/FullVersion/$i/MSSetupv$i.z04 & pids[5]=$!
wget -x -nH http://download2.nexon.net/Game/MapleStory/FullVersion/$i/MSSetupv$i.z05 & pids[6]=$!
wget -x -nH http://download2.nexon.net/Game/MapleStory/FullVersion/$i/MSSetupv$i.z06 & pids[7]=$!