Skip to content

Instantly share code, notes, and snippets.

View heliocarbex's full-sized avatar
💭
Programming a lot

Helio Junior heliocarbex

💭
Programming a lot
View GitHub Profile
@heliocarbex
heliocarbex / test_module.py
Last active August 6, 2021 17:32
Template to test project modules of python projects
'''
Suppose the following structure:
project/
main.py
module/
my_module.py
test/
test_module.py
@heliocarbex
heliocarbex / clauses.py
Last active March 31, 2020 13:21
Clauses to be used when writing selenium code
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
D_EC={
"click":EC.element_to_be_clickable,
"presence":EC.presence_of_element_located,
"visible":EC.visibility_of,
"select":EC.element_to_be_selected,
"state":EC.element_located_selection_state_to_be,
"invisible":EC.invisibility_of_element,
@heliocarbex
heliocarbex / xpath.html
Last active February 5, 2020 19:11
Using Xpaths
<!-- Select all elements with the name message in the id-->
Xpath=//*[contains(@id,'message')]
<!-- Select all elements with the text "here" in the text-->
Xpath=//*[contains(text(),'here')]
<span>
here
</span>
@heliocarbex
heliocarbex / dinamic_functions.py
Last active February 4, 2020 19:53
Creating dinamic functions in Python
# Mode 1
new_func='def next_element(x):\n return x+1'
the_code=compile(new_func,'test','exec')
exec(the_code)
next_element(1)
#Mode 2
new_func='def next_element(x):\n return x+1'
exec(new_function)
next_element(1)
@heliocarbex
heliocarbex / README.md
Created March 26, 2019 23:07 — forked from brizandrew/README.md
How to use node.js build routines and npm packages in Django.

Using Node.js With Django

When writing django apps it's easy to ignore the organization of your front end code. Often, these backend coders will just write a static js and css file, stick it in the static directory, and call it a day.

You can also build them as two completely independent parts. With a complex gulp build routine independent of the django app. But if you don't know gulp, node, or those kinds of systems it can be a daunting process to get started with.

Enter django-compressor-toolkit (the name doesn't quite roll off the tongue).

Setting Up Django-Compressor-Toolkit

Using django-compressor and django-compressor-toolkit you can write Javascript ES6 code with all its fancy import/export logic or style your pages with sass instead of css, and leave your deploy routine largely untouched.

@heliocarbex
heliocarbex / git-tips.md
Created March 14, 2019 20:27
A lot of useful git commands

Git tips

Show repositories and upstream remote branches

git branch -vv

Set a local branch track a remote

  • upstream: remote
  • foo: local branch

git branch -u upstream/foo

@heliocarbex
heliocarbex / svg2img.js
Created March 7, 2019 20:53
Convert a svg file to a img
function svg2img(){
var svg = document.querySelector('svg');
var xml = new XMLSerializer().serializeToString(svg);
var svg64 = btoa(xml); //for utf8: btoa(unescape(encodeURIComponent(xml)))
var b64start = 'data:image/svg+xml;base64,';
var image64 = b64start + svg64;
return image64;
};svg2img()
//Got from https://stackoverflow.com/questions/3975499/convert-svg-to-image-jpeg-png-etc-in-the-browser#answer-53409434
@heliocarbex
heliocarbex / sum_groupby.py
Created February 21, 2019 23:00
Sum tuples grouped by some items
import operator
import itertools
listax=[('2019-02-19', 'Customer', 'Virtual Network', 1.8568612344799997), ('2019-02-19', 'Customer', 'Virtual Network', 1.8963689203199998)]
def accumulate(lista):
it = itertools.groupby(lista, operator.itemgetter(0,1,2))
for key, subiter in it:
yield key, sum(float(item[3]) for item in subiter)
@heliocarbex
heliocarbex / README.md
Created January 30, 2019 16:31
SCRIPT-8
@heliocarbex
heliocarbex / pagseguro.en.yml
Created August 31, 2018 01:31 — forked from dtelaroli/pagseguro.en.yml
Pagseguro I18n - API Ruby de pagamento transparente
en:
pagseguro:
errors:
'bad_request': 'Bad request'
'5003': 'bank network error'
'10000': 'invalid creditcard brand'
'10001': "creditcard number with invalid length"
'10002': "invalid date format"
'10003': "invalid security field"
'10004': "cvv is mandatory"