Skip to content

Instantly share code, notes, and snippets.

View edgabaldi's full-sized avatar
🏠
Working from home

Edgar Gabaldi edgabaldi

🏠
Working from home
View GitHub Profile
const clean_pcp = (value) => {
new_value = value.replace('%', '').replace(',','.').replace('+','');
return parseFloat(new_value);
}
const circle_icon_green = $('<span class="text-success"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-circle-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="8" cy="8" r="8"/></svg></span>');
const circle_icon_red = $('<span class="text-danger"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-circle-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="8" cy="8" r="8"/></svg></span>');
$('.pid-8839-pcp').on('DOMSubtreeModified', function(){
const $this = $(this);
.row{ margin: 10px; }
.col{ padding: 5px; }
.card{
border-radius: 4px;
background: #fff;
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.08), 0 0 6px rgba(0, 0, 0, 0.05);
transition: 0.1s transform cubic-bezier(0.155, 1.105, 0.295, 1.12), 0.1s box-shadow, 0.1s -webkit-transform cubic-bezier(0.155, 1.105, 0.295, 1.12);
padding: 10px 80px 10px 10px;
cursor: pointer;
@edgabaldi
edgabaldi / deploy-keys.md
Created April 15, 2019 14:54 — forked from holmberd/deploy-keys.md
Setup GitHub repository SSH deploy keys

Setup GitHub repository SSH deploy keys

  1. Create GitHub repository in github and save the SSH repository url

  2. Init git on server in code directory

  • git init
  1. Create SSH keys on the server
  • ssh-keygen -t rsa -b 4096 -C [email protected]
  • Rename the key that doesn't end with .pub to repo-name.deploy.pem
def almost_equal(self, checked, correct, significant_digits=1):
"""
Função Quase Igual
"""
precision = 0.1 ** significant_digits
return abs(checked - correct) < precision
class PolygonAlmostEqualTestCase(TestCase):
"""
Testa a função "quase igual"
def point_in_polygon(point, polygon):
inside=False
j=len(polygon)-1
for i in range(len(polygon)):
if ((polygon[i][1]>point[1])!=(polygon[j][1]>point[1]) and (point[0]<(polygon[j][0]-polygon[i][0])*(point[1]-polygon[i][1])/( polygon[j][1] - polygon[i][1] ) + polygon[i][0])):
inside =not inside
j=i
return inside
@edgabaldi
edgabaldi / speed.js
Last active April 3, 2019 11:44
change video speed
class VideoSpeed {
constructor(){
this.video = document.getElementsByTagName("video").video
}
speed = () => {
return this.video.playbackRate
}
#!/bin/bash
for FILE in $(ls *.bin); do
LINHA=$(cat urls_to_download.txt | grep $FILE)
NEW_NAME=$(echo "$LINHA" | cut -d ";" -f 2)
mv -v $FILE $NEW_NAME
done
@edgabaldi
edgabaldi / group_by.js
Created December 8, 2018 10:31
groupBy ES6
const groupBy = (xs, key) => {
return xs.reduce( (rv, x) => {
(rv[x[key]] = rv[x[key]] || []).push(x);
return rv;
}, {});
};
console.log(groupBy(['one', 'two', 'three'], 'length'));
// => {3: ["one", "two"], 5: ["three"]}
@edgabaldi
edgabaldi / print_permissions.py
Last active October 26, 2018 16:25
print permissions from group in django
def print_permissions_from(group):
return [p.codename for p in group.permissions.all()]
@edgabaldi
edgabaldi / fix_permissions.py
Created October 19, 2018 12:42
Cria Permissão para model proxy no django 1.6
from __future__ import unicode_literals, absolute_import, division
import sys
from django.db.models import get_models
from django.contrib.auth.management import _get_all_permissions
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentTyped
from django.utils.encoding import smart_text