Skip to content

Instantly share code, notes, and snippets.

View rruffer's full-sized avatar

Rodolfo Ruffer rruffer

  • VALID
  • Duque de Caxias - RJ
View GitHub Profile
@rruffer
rruffer / TimeZone.md
Created August 15, 2022 23:41 — forked from sjimenez44/TimeZone.md
Change time zone Docker container

Change TimeZone in Docker containers

With Docker Engine

The timezone of a container can be set using an environment variable in the docker container when it is created. For example:

$ docker run ubuntu:latest date
Sat Feb 27 15:58:32 UTC 2021
$ docker run -e TZ=America/Bogota ubuntu:latest date
Sat Feb 27 15:58:40 Asia 2021
@rruffer
rruffer / teste.java
Last active May 25, 2022 16:42
Inserting null in object variables with reflection
private void setNullValue(Object object) {
Arrays.asList(object.getClass().getDeclaredFields()).forEach(f -> {
f.setAccessible(true);
try {
System.out.printf("Current: [Name: %s, Type: %s, Value: %s] \n", f.getName(), f.getType().getSimpleName(), f.get(object));
if (!f.getType().isPrimitive() && !Modifier.isStatic(f.getModifiers())) {
f.set(object, null);
}
System.out.printf("New: [Name: %s, Type: %s, Value: %s] \n", f.getName(), f.getType().getSimpleName(), f.get(object));
@rruffer
rruffer / list-errors-angular.ts
Last active March 15, 2022 19:13
List Erros form react angular
for (const name in this.form.controls) {
if (this.form.controls[name].invalid) {
console.log(`Name: ${name}, Erros: ${JSON.stringify(this.form.controls[name].errors)}`)
}
}
@rruffer
rruffer / FileUtil.java
Created July 27, 2021 14:59
get all text file java 8
private static String getString(String file) {
try {
URL resource = PayloadUtil.class.getClassLoader().getResource(file);
Path path = Paths.get(resource.toURI());
return Files.lines(path).collect(Collectors.joining("\n","","\n"));
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@rruffer
rruffer / WSL 2 GNOME Desktop.md
Created April 26, 2021 15:25
Set up a GNOME desktop environment on WSL 2

WSL 2 GNOME Desktop

Think Xfce looks dated? Want a conventional Ubuntu experience? This tutorial will guide you through installing Ubuntu's default desktop environment, GNOME.

GNOME is one of the more complex — and that means more difficult to run — desktop environments, so for years people couldn't figure out how [to](https://www.reddit.

public static void fizzBuzz(int number) {
IntStream.rangeClosed(1, number).boxed().forEach(num -> {
String result = Optional.of(num).map(n -> (n % 3 == 0 ? "Fizz":"") + (n %5 == 0 ? "Buzz":"")).get();
System.out.println(result.isEmpty() ? Integer.toString(num):result);
});
}
linux: while true; do curl localhost:8080/config; done
windows: for /l %N in () do curl localhost:8080/circuit /// for /l %N in (1 2 20) do curl localhost:8080/circuit
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
public class Teste {
public static void main(String[] args) {
@rruffer
rruffer / AsynchronousSocketChannelWrapper.java
Created September 14, 2020 16:30 — forked from ochinchina/AsynchronousSocketChannelWrapper.java
AsynchronousSocketChannel wrapper to support completely asyn operations
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;
import java.util.LinkedList;
import java.util.concurrent.TimeUnit;
/**
* This class wraps the AsynchronousSocketChannel reading and writing operations. The wrapped reading and writing operations is
* completely asynchronous operation. No any exception will be thrown from the read/write operation. If any exception occurs
* during read & write, the failed() method in CompletionHandler will be called.
@rruffer
rruffer / back.ts
Last active March 24, 2020 01:37
erro ngfor
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Associado } from './../../../models/Associado';
import { DigitalCaptura } from './../../../models/digital-captura';
@Component({
selector: 'app-captura-digitais',
templateUrl: './captura-digitais.component.html',
styleUrls: ['./captura-digitais.component.scss']
})
export class CapturaDigitaisComponent implements OnInit {