Skip to content

Instantly share code, notes, and snippets.

View FernandoBontorin's full-sized avatar

Fernando Bontorin FernandoBontorin

View GitHub Profile
from pyspark.sql.functions import col, when, lit, last_day, add_months
def retro_add_months(date, months):
"""
Adds 'months' to the given 'date', but if the resulting date is not the last day of the month,
as well the given date, it returns the last day of the resulting month of added months.
"""
return when(last_day(date) != date, add_months(date, months)).otherwise(last_day(add_months(date, months)))
// made by Costache Madalin (lllll llll)
// discord: costache madalin#8472
let url=window.location.href
var countApiKey = "support_sender";
var countNameSpace="madalinoTribalWarsScripts"
@FernandoBontorin
FernandoBontorin / send_resource.js
Created April 6, 2023 02:13
Send balanced resources to Main village
javascript: selectTarget(444, 369, ''); let reserve_of_resources = Number(document.getElementById("storage").innerHTML)/9; let max_resources_send = Number(document.getElementById("market_merchant_max_transport").innerHTML); let wood = Number(document.getElementById("wood").innerHTML); let stone = Number(document.getElementById("stone").innerHTML); let iron = Number(document.getElementById("iron").innerHTML); let total = wood + stone + iron; document.getElementsByName("wood")[0].value = Math.max(0, Math.min(wood-reserve_of_resources, (wood/total*max_resources_send))); document.getElementsByName("stone")[0].value = Math.max(0, Math.min(stone-reserve_of_resources, (stone/total*max_resources_send))); document.getElementsByName("iron")[0].value = Math.max(0, Math.min(iron-reserve_of_resources, (iron/total*max_resources_send))); document.getElementsByClassName("btn")[0].click();
@FernandoBontorin
FernandoBontorin / export_relatorio
Created March 31, 2023 23:43
Exportar o relatório de espionagem para as notas
javascript:$.getScript('https://media.innogamescdn.com/com_DS_BR/Scripts/Aprovados/AutoNotesFromReports.js');
@FernandoBontorin
FernandoBontorin / SteamNext.js
Created November 16, 2021 06:10
Steam: Favorite code to next recommended game in Steam summer list
javascript: document.getElementsByClassName("btn_next_in_queue btn_next_in_queue_trigger")[0].click()
@FernandoBontorin
FernandoBontorin / TribalWarsBFav.js
Created November 16, 2021 06:08
Tribal Wars: Favorite code to run all farm at barbarian using B preset troops
javascript: var time = 0; function exec(e){time += 250; setTimeout(()=>{e.click()}, time)}; Array.from(document.getElementsByClassName("farm_icon_b")).forEach(x=>exec(x));
@FernandoBontorin
FernandoBontorin / snip.js
Last active April 7, 2023 02:23
snipa o pessoal e pa
function snip(dateISOformat, diff=0){
var target = new Date(dateISOformat).getTime();
var duration = document.getElementById("date_arrival").firstElementChild.getAttribute("data-duration")*1000;
var send = target-duration;
var timeout = send-new Date().getTime()-18000;
setTimeout(()=>{document.getElementById("troop_confirm_submit").click()}, timeout+diff);
console.log(new Date(timeout).toUTCString().slice(-11, -4));
};snip("2023-04-08T09:26:30.100-03:00", -34219)
@FernandoBontorin
FernandoBontorin / Experiment.ipynb
Created February 27, 2020 01:21
Create a new session with spark-scala notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import org.apache.spark.sql.functions.{col, max}
import org.apache.spark.sql.{DataFrame, Row}
import scala.reflect.ClassTag
object SparkUtils {
def hasNull(df: DataFrame, cols: String*): Boolean = {
hasNull(asArrayOf[Boolean](isNull(df, cols: _*).collect))
}