Skip to content

Instantly share code, notes, and snippets.

View marlonklc's full-sized avatar
🎯
Focusing

Marlon Klagenberg marlonklc

🎯
Focusing
View GitHub Profile
@marlonklc
marlonklc / heroku api
Last active May 20, 2023 15:56
useful heroku APIs
# restart heroku dyno
curl --location --request DELETE 'https://api.heroku.com/apps/web-scrap-amazon-wishlist/dynos/web' \
--header 'Accept: application/vnd.heroku+json; version=3' \
--header 'Authorization: Bearer <token-api>'
# stop heroku dyno
curl --location --request POST 'https://api.heroku.com/apps/web-scrap-amazon-wishlist/dynos/web/actions/stop' \
--header 'Accept: application/vnd.heroku+json; version=3' \
--header 'Authorization: Bearer <token-api>'
@marlonklc
marlonklc / spring-dynamic-services.java
Last active January 19, 2023 03:54
How to instantiate dynamic implementations of a service using spring config
public interface MyService {
String print();
}
@Service("service1")
public class MyFirstService implements MyService {
@Override
public String print() {return "service ONE";}
}
@marlonklc
marlonklc / _youtube-subtitles-script.js
Last active April 30, 2023 02:41
youtube auto translate subtitles using google translator API
const SOURCE_LANGUAGE = "en";
const TARGET_LANGUAGE = "pt-br";
const button = document.createElement('button');
button.textContent = 'copy and translate';
button.addEventListener('click', () => {
const subtitleElement = document.getElementsByClassName('captions-text')[0];
const selectedTexts = Array.from(subtitleElement.children)
.map(i => i.children[0])
.map(i => i.innerHTML.replace('<br>', '').replace('&nbsp;', ''))
.join(' ');
@marlonklc
marlonklc / _netflix-subtitles-script.js
Last active April 30, 2023 02:41
netflix copy subtitles on clipboard
const SOURCE_LANGUAGE = "en";
const TARGET_LANGUAGE = "pt-br";
const button = document.createElement('button');
button.textContent = 'translate';
button.addEventListener('click', () => {
const subtitleElement1 = document.getElementsByClassName('player-timedtext-text-container')[0]?.children[0]?.children[0];
const subtitleElement2 = document.getElementsByClassName('player-timedtext-text-container')[1]?.children[0]?.children[0];
const selectedTexts = Array.from([subtitleElement1, subtitleElement2])
.filter(i => !!i)
.map(i => i.innerHTML.replaceAll('<br>', '').replaceAll('&nbsp;', ''))
@marlonklc
marlonklc / my-own-unflatten.js
Created August 3, 2021 18:51
My own unflatten
const _ = require('lodash')
const SETTINGS = {
header_background_color: value(/whitelabel\.header_background_color/g),
footer_background_color: value(/whitelabel\.footer_background_color/g),
footer_sections: array(/whitelabel\.footer_sections\../g, 2),
footer_sections_title: value(/whitelabel\.footer_sections\..\.title/g),
footer_sections_links: array(/whitelabel\.footer_sections\..\.links\../g, 4),
footer_sections_links_title: value(/whitelabel\.footer_sections\..\.links\..\.title/g),
footer_sections_links_tooltip: value(/whitelabel\.footer_sections\..\.links\..\.tooltip/g),
@marlonklc
marlonklc / README.md
Created March 17, 2020 14:28 — forked from yogendra/README.md
Personal jumpbox bootstrap script -- curl -L dwallraff.com/jumpbox | bash

Jumpbox

This gist initialized a jumpbox

@marlonklc
marlonklc / Product.java
Last active November 5, 2022 19:46
[Java 8] Generate many stubs for any class
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Product {
private final long id;
private final String description;
@marlonklc
marlonklc / StringRotationCompactCode.java
Last active January 14, 2020 13:44
[CHALLENGE]: String rotation
import org.junit.Test;
public class StringRotationCompactCode {
@Test
public void test() {
System.err.println("abcde => eabcd: " + isRotation("abcde", "eabcd"));
System.err.println("abcde => cdeab: " + isRotation("abcde", "cdeab"));
System.err.println("abcde => abced: " + isRotation("abcde", "abced"));
System.err.println("abc => a: " + isRotation("abc", "a"));
}
@marlonklc
marlonklc / Food.java
Last active January 31, 2020 13:11
[spring-webflux] best way to build a object
public class Food {
private String pizza;
private String hamburger;
public String getPizza() {
return pizza;
}
public void setPizza(String pizza) {
this.pizza = pizza;