Skip to content

Instantly share code, notes, and snippets.

package main
import "fmt"
type person struct {
name string
age int
}
func (p person) print() {
from sympy import *
from sympy.abc import k
B=Matrix([[1, .5], [.5, 1]])
print(B.eigenvals())
A=Matrix([[1+k, .5], [.5, 1+k]])
print(A.eigenvals())
A=Matrix([[1+k, .5, 1], [.5, 1+k, 1],[.5, 1, 1+k]])
print(A.eigenvals())
import numpy as np
import matplotlib.pyplot as plt
n_dimensions = 2
A = np.random.rand(n_dimensions) # source
B = np.random.rand(n_dimensions) # target
# linear function
n_steps = 50
delta = (A-B)/n_steps
@silgon
silgon / thread_lock.py
Created December 2, 2020 10:36
Example with lock thread
""" Worker will wail to another to finish a task in order to do some procedure
"""
import threading
import logging
import time
logging.basicConfig(level=logging.DEBUG,
format='(%(threadName)-10s) %(message)s',)
def worker(lock, seconds=2):
wb=openpyxl.load_workbook("doc.xlsx")
sheet, inrange=list(wb.defined_names["MYDEFINEDNAME"].destinations)[0]
[xy.value for xy in x] for x in wb[sheet][inrange]]
# newest version for Mozilla Firefox 81.0.2
javascript:/*PDF - toggle filter invert*/(function(){var L='style_PDFI',S='#viewerContainer>#viewer.pdfViewer>.page{filter: invert(100%)}',SS,E=document.querySelector('style[id="'+L+'"]');if(E){SS=E.disabled;E.disabled=(SS==true)?false:true}else{SS=document.createElement('style');SS.setAttribute('type','text/css');SS.id=L;SS.innerHTML=S;document.querySelector('head').appendChild(SS); document.querySelectorAll("#viewerContainer>#viewer.pdfViewer>.page").forEach(e=>e.style.border="10px solid rgba(0, 0, 0, 0)"); document.querySelector("#viewerContainer>#viewer.pdfViewer").style.background="#666"; document.querySelector("#toolbarViewer").style.background="#999"; document.querySelector("#toolbarViewer").style.borderBottom="#999 solid 1px"; document.querySelector("#toolbarSidebar").style.background="#999";document.querySelector("#outlineView").style.background="#bbb"}})()
# my bookmarklet
javascript:/*PDF - toggle filter invert*/(function(){var L='style_PDFI',S='#viewerC
#extracted from: https://www.scrapehero.com/how-to-rotate-proxies-and-ip-addresses-using-python-3/
import requests
from lxml.html import fromstring
def get_proxies():
url = 'https://free-proxy-list.net/'
response = requests.get(url)
parser = fromstring(response.text)
proxies = set()
for i in parser.xpath('//tbody/tr'):
if i.xpath('.//td[7][contains(text(),"yes")]'):
# based on:
# https://stackoverflow.com/a/882770/2237916
# https://stackoverflow.com/a/53970596/2237916
import smtplib
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from os.path import basename
@silgon
silgon / peak_indicator.py
Last active April 20, 2022 18:46
peak_indicator
import pandas_datareader as pdr
import matplotlib.pyplot as plt
from statsmodels.tsa.arima_model import ARIMA
from scipy.signal import find_peaks
data = pdr.get_data_yahoo("FR.PA")
data_ = data[data.index>"2017"]
# find_peaks(data_["Volume"])
@silgon
silgon / xvfb.md
Created April 2, 2019 13:04
display