Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
;-)

Yurii De dejurin

💭
;-)
  • Si-ɑR
  • 127.0.0.1
View GitHub Profile
@dejurin
dejurin / mysq-mariadb-macos-start-issue.md
Created Dec 3, 2021 — forked from irazasyed/mysq-mariadb-macos-start-issue.md
Solution for MySQL / MariaDB Start Issue on MacOS
View mysq-mariadb-macos-start-issue.md

Solution for MySQL / MariaDB Start Issue on MacOS

Errors

On trying to start mysql.server start

./usr/local/bin/mysql.server: line 264: kill: (12262) - No such process ERROR!

@dejurin
dejurin / url_path_for.py
Last active Oct 17, 2021
Starlette Jinja2Templates add relative URL (url_path_for)
View url_path_for.py
#Add to class Jinja2Templates:
#https://github.com/encode/starlette/blob/6c556f6c5e4aa70173a84f6e6854390241231021/starlette/templating.py
@jinja2.contextfunction
def url_path_for(context: dict, name: str, **path_params: typing.Any) -> str:
request = context["request"]
router = request.scope["router"]
return router.url_path_for(name, **path_params)
env.globals["url_path_for"] = url_path_for
@dejurin
dejurin / jsInputFilter.html
Last active Oct 1, 2021
JavaScript input filter showcase
View jsInputFilter.html
<!-- https://jsfiddle.net/user/emkey08 -->
<!-- https://jsfiddle.net/emkey08/zgvtjc51 -->
<h2>JavaScript input filter showcase</h2>
<p>Supports Copy+Paste, Drag+Drop, keyboard shortcuts, context menu operations, non-typeable keys, the caret position, different keyboard layouts, and <a href="https://caniuse.com/#feat=input-event" target="_blank">all browsers since IE 9</a>.</p>
<p>There is also a <a href="https://jsfiddle.net/emkey08/tvx5e7q3" target="_blank">jQuery version</a> of this.</p>
<table>
<tr><td>Integer</td><td><input id="intTextBox"></td></tr>
<tr><td>Integer &gt;= 0</td><td><input id="uintTextBox"></td></tr>
<tr><td>Integer &gt;= 0 and &lt;= 500</td><td><input id="intLimitTextBox"></td></tr>
@dejurin
dejurin / meta-tags.md
Created Sep 27, 2021 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags
View meta-tags.md

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@dejurin
dejurin / isElementInViewport.js
Created Sep 7, 2021 — forked from davidtheclark/isElementInViewport.js
JavaScript: Is element in viewport?
View isElementInViewport.js
/*
No jQuery necessary.
Thanks to Dan's StackOverflow answer for this:
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
@dejurin
dejurin / IPGeoLocation.py
Last active Aug 11, 2021
IP Geolocation API - Python requests
View IPGeoLocation.py
# https://api.ipgeolocation.io/ipgeo?apiKey=API_KEY&ip=8.8.8.8
# https://ipgeolocation.io/documentation/ip-geolocation-api.html
import requests
class IPGeoLocation:
url = 'https://api.ipgeolocation.io/ipgeo'
def __init__(self, apiKey):
self.apiKey = apiKey
View Dcmal.js
class Dcmal {
constructor(prec) {
this.prec = prec;
}
_noExponents(num) {
var data = String(num).split(/[eE]/);
if (data.length == 1) return data[0];
var z = '',
sign = this < 0 ? '-' : '',
View dcmal.py
def dcmal(num: float, prec: int = 4) -> str:
if type(num) == float and num < 1:
if str(num).find("e-") >= 0:
e = int(str(num).split("e-")[1])+1
s = "{:.{}f}".format(num, e).replace(',','.').split(".")
else:
s = str(num).replace(',','.').split(".")
last = str(int(s[1]))
return "0." + s[1].replace(last, "") + str(round(float("0." + last), prec)).replace(',','.').split(".")[1]
return '{:g}'.format(round(num, prec))
@dejurin
dejurin / letsencrypt.txt
Created Jun 12, 2021
letsencrypt wildcard
View letsencrypt.txt
brew install certbot
certbot certonly --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory --manual-public-ip-logging-ok -d '*.example.com' -d example.com
@dejurin
dejurin / gist:06d979d9a04e3a283ae6b3c22d4bd650
Created May 16, 2021 — forked from supairish/gist:2951524
Nginx - how to limit requests by User Agent
View gist:06d979d9a04e3a283ae6b3c22d4bd650
http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {