Skip to content

Instantly share code, notes, and snippets.

View Trusted97's full-sized avatar
🎯
Focusing

Gianluca Benucci Trusted97

🎯
Focusing
View GitHub Profile
# Monte Carlo method
# Goal:
# 1) Find best opening hands
# 2) Estimate combo-read hands
import random, collections, itertools, textwrap, pandas as pd
deck_list = [
"1 Abrade","1 Ad Nauseam","1 Agatha's Soul Cauldron","1 All Will Be One","1 Arcane Signet","1 Barbarian Ring","1 Beseech the Mirror","1 Birgi, God of Storytelling",
"1 Blackcleave Cliffs","1 Blazemire Verge","1 Blightstep Pathway","1 Blood Crypt","1 Bloodstained Mire","1 Cabal Ritual","1 Cavern of Souls","1 Command Tower",
@Trusted97
Trusted97 / deploy-ssh.yml
Created November 25, 2022 22:01
Deploy Symfony to Digital Ocean
name: SSH Deploy
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
environment: master
steps:
# —— Setup Github actions 🐙 —————————————————————————————————————————————
- name: Checkout
@Trusted97
Trusted97 / .php-cs-fixer.dist.php
Last active November 15, 2022 08:48
Symfony php-cs-fixer configuration
<?php
$finder = PhpCsFixer\Finder::create()
->in([__DIR__])
->exclude('config')
->exclude('var')
->exclude('vendor')
->exclude('public/bundles')
->exclude('public/build')
->notPath('bin/console')
@Trusted97
Trusted97 / video_sitemap_generator.py
Created July 30, 2022 11:10
Video sitemap generator
import re
from bs4 import BeautifulSoup
import urllib.request
from urllib.request import urlopen
import json
import requests
def get_embed_code(youtube_url):
curl -X GET "localhost:9200/_cat/indices/?v=true&s=index&pretty"
curl -X PUT "localhost:9200/avengers/hero/1?pretty" -H 'Content-Type: application/json' -d'
{
"email":"[email protected]",
"firstName":"Tony",
"lastName":"Stark",
"alias": "Iron Man",
"info":{
"bio":"Un genio, miliardario, playboy, filantropo.",
curl -X PUT "localhost:9200/avengers/hero/1?pretty" -H 'Content-Type: application/json' -d'
{
"email":"[email protected]",
"firstName":"Tony",
"lastName":"Stark",
"alias": "Iron Man",
"info":{
"bio":"Un genio, miliardario, playboy, filantropo.",
"age":42,
"isAvenger":true,
@Trusted97
Trusted97 / setupElastic.sh
Created April 13, 2022 10:57
Download and Launch Elasticsearch 5.5.0
#!/bin/bash
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.tar.gz
tar -zxvf elasticsearch-5.5.0.tar.gz
cd elasticsearch-5.5.0
./bin/elasticsearch
@Trusted97
Trusted97 / analytics-module.js
Created October 15, 2021 08:37
Analytics in module
const e = (e,t,o,i,a,c,l)=>{
navigator.sendBeacon("https://www.google-analytics.com/collect", new URLSearchParams({
v: "1",
ds: "web",
aip: 1,
tid: "UA-XXXXXXX",
cid: (localStorage.cid || (localStorage.cid = Math.random().toString(36)),
localStorage.cid),
t: e || "pageview",
sd: screen.colorDepth ? screen.colorDepth + "-bits" : void 0,
@Trusted97
Trusted97 / async-all.js
Created November 9, 2020 09:34
Cool way for loading script in async for every browser
!function(e,t,r){function n(){for(;d[0]&&"loaded"==d[0][f];)c=d.shift(),c[o]=!i.parentNode.insertBefore(c,i)}for(var s,a,c,d=[],i=e.scripts[0],o="onreadystatechange",f="readyState";s=r.shift();)a=e.createElement(t),"async"in i?(a.async=!1,e.head.appendChild(a)):i[f]?(d.push(a),a[o]=n):e.write("<"+t+' src="'+s+'" defer></'+t+">"),a.src=s}(document,"script",[
"//other-domain.com/1.js",
"2.js"
])
@Trusted97
Trusted97 / service-worker.js
Created November 2, 2020 09:23
PreFetch URL Service Worker
/*
Copyright 2014 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and