Skip to content

Instantly share code, notes, and snippets.

View Freeongoo's full-sized avatar

Freeongoo

  • St. Petersburg
View GitHub Profile
@Freeongoo
Freeongoo / Upload.java
Created April 25, 2024 11:01 — forked from rbaul/Upload.java
RestTemplate upload byte[]
MultiValueMap<String, Object> data = new LinkedMultiValueMap<String, Object>();
ByteArrayResource resource = new ByteArrayResource(file.getBytes()) {
@Override
public String getFilename() {
return file.getName();
}
};
data.add("file", resource);
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
//@version=2
//Heikin Ashi Strategy V2 by breizh29
strategy("Heikin Ashi Strategy V2",shorttitle="HAS V2",overlay=true,default_qty_value=1000,initial_capital=100000,currency=currency.EUR)
res = input(title="Heikin Ashi Candle Time Frame", type=resolution, defval="60")
hshift = input(1,title="Heikin Ashi Candle Time Frame Shift")
res1 = input(title="Heikin Ashi EMA Time Frame", type=resolution, defval="180")
mhshift = input(0,title="Heikin Ashi EMA Time Frame Shift")
fama = input(1,"Heikin Ashi EMA Period")
test = input(1,"Heikin Ashi EMA Shift")
@Freeongoo
Freeongoo / Instant handler runnable execution with Mockito
Created May 24, 2022 06:35 — forked from aashreys/Instant handler runnable execution with Mockito
Use Mockito to instantly execute handler runnables in your tests.
// Creating a handler which executes runnables immediately
Mockito.when(uiHandler.post(Mockito.any(Runnable.class))).thenAnswer(
new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Runnable msg = invocation.getArgument(0);
msg.run();
return null;
}
}
@Freeongoo
Freeongoo / SpringRetry.java
Created March 25, 2021 15:30 — forked from mguilherme/SpringRetry.java
Spring Retry Examples
package com.guilherme.miguel.retry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.retry.RetryCallback;
import org.springframework.retry.RetryContext;
import org.springframework.retry.RetryListener;
@Freeongoo
Freeongoo / mysql-docker.sh
Last active October 19, 2020 11:14 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@Freeongoo
Freeongoo / Person.java
Created February 7, 2019 11:53 — forked from sai-pullabhotla/Person.java
Person Entity Using Builder Pattern
import com.jmethods.catatumbo.Entity;
import com.jmethods.catatumbo.Identifier;
import com.jmethods.catatumbo.Property;
@Entity
public class Person {
@Identifier
private final long id;
@Freeongoo
Freeongoo / example.cs
Created January 18, 2019 15:01 — forked from brandonmwest/example.cs
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));
@Freeongoo
Freeongoo / gist:f54f68aad76c447f269105dd76063c82
Created September 22, 2018 11:36 — forked from mrtns/gist:78d15e3263b2f6a231fe
Upgrade Chrome from Command Line on Ubuntu
# Install
# via http://askubuntu.com/questions/510056/how-to-install-google-chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
# Update
@Freeongoo
Freeongoo / rescue-from-git-push-force.md
Created August 6, 2018 13:00 — forked from Envek/rescue-from-git-push-force.md
Откат ошибочной команды git push --force

Откат ошибочной команды git push --force

Иногда при работе с несколькими удалёнными репозиториями в git, может произойти страшное: git push --force в не тот remote и/или не в ту ветку.

Такое может случиться, например, если вы используете [Deis], в котором деплой запускается при git push нужного коммита в сборщик, когда при отладке деплоя после очередного git commit --amend по запарке вместо git push deis master --force делается просто git push --force. Упс.

Как результат, последние коммиты коллег безвозвратно потеряны, и вы чувствуете неотвратимость их ярости…

Но это git, а значит всё можно починить!

@Freeongoo
Freeongoo / gist:e4472615a7552b093689cc01344d1cd5
Created July 21, 2018 20:07 — forked from naaman/gist:1053217
Hot Swapping With Maven, Jetty and IntelliJ

Hot Swapping With Maven, Jetty and IntelliJ

Based on Configuring Jetty, Maven, and Eclipse together with Hot Swap

I've always been a bit jealous when it comes to the Play! framework and the great dev mode they have for hot swapping classes at runtime. Jetty has a configuration setting, scanIntervalSeconds, that mimics this when working with a more traditional WAR, but does so by looking for changes to a file and restarting the server.

Fortunately, Jetty also provides the ability to rapidly test code with hot swapping. No more server restarts. The trick to getting hot swapping to work is to attach a remote debugger to your Jetty process. The following instructions outline how to do this in IntelliJ (tested with IDEA 10.5 CE).

Modify your jetty-maven-plugin to ignore the scan interval

  1. Open your pom and locate the plugins section