Skip to content

Instantly share code, notes, and snippets.

View aipi's full-sized avatar
❤️
Falling in love

Daniel Moniz aipi

❤️
Falling in love
View GitHub Profile
import csv
import random
class Dataset:
def remove_stop_words(self, text):
return text.replace(',', '').replace('.', '')
def get_portuguese_text(self, row, dataset):
portuguese_text = self.remove_stop_words(row[2].lower()).split()
import requests
from requests.auth import HTTPBasicAuth
import json
import math
from enum import Enum
from datetime import datetime
class Mnemonic(Enum):
TORQUE = 'TORQUE_AVG'
SURF_RPM = 'SURF_RPM'
@aipi
aipi / tabela_fipe.py
Last active April 24, 2022 02:43
Consultar Tabela FIPE com Python
import requests
r = requests.post(
'http://veiculos.fipe.org.br/api/veiculos/ConsultarMarcas',
json=payload,
headers={
'Host': 'veiculos.fipe.org.br',
'Referer': 'http://veiculos.fipe.org.br/'
}
)
@aipi
aipi / joking_with_callbacks.cpp
Created January 27, 2018 14:47
Just enjoying callbacks
#include <iostream>
using namespace std;
void printall(char *xpto){
for(int i=0; i < 3; i++){
cout << *(xpto+i);
}
cout << "\n";
}
@aipi
aipi / callback.cpp
Last active January 27, 2018 03:46
An callback simple example with C++ to undertanding how it works and its aspects.
/* Callback example with c++ */
#include <iostream>
int add(int a, int b, const char *caller_name)
{
std::cout << __FUNCTION__ << " was called by " << caller_name << "\n";
return a + b;
}
int subtraction(int a, int b, const char *caller_name)
function visit_top_10_order_estimated_visits(){
var ctx = document.getElementById("visit_top_10_order_estimated_visits");
var names_top_10_order_estimated_visits = JSON.parse('{{ names_top_10_order_estimated_visits|safe }}');
var visits_top_10_order_estimated_visits = JSON.parse('{{ visits_top_10_order_estimated_visits|safe }}');
var visit_top_10_order_estimated_visits = new Chart(ctx, {
type: 'bar',
data: {
labels: names_top_10_order_estimated_visits,
datasets: [{
data: visits_top_10_order_estimated_visits,
[{
"beeg.com": {
"global_rank": "384",
"daily_time_on_site": "3:51",
"daily_pageviews_per_visitor": "2.57",
"percent_of_traffic_from_search": "13.80%",
"total_site_linking_in": "1,447",
"audience_geography": [
{
"country": " United States",
@aipi
aipi / crawler_example.py
Created November 26, 2017 01:49
example used in PI4
class GetTopSitesListAditionalInformation(LogIntoAlexa):
def __init__(self):
super().__init__()
self.top_list = json.load(open('../data/data.json'))
self.url = 'https://www.alexa.com/siteinfo/'
def get_additional_informations(self):
self.log_into_alexa()
i = 0
for key, value in self.top_list.items():
@aipi
aipi / test_type_of_context.py
Created June 28, 2017 15:25
TDD Django unittest to check the type of a context, like Queryset, List Class, so on.
from django.test import TestCase
# Is necessary import <class 'django.db.models.query.QuerySet'> to make this validation
from django.db.models.query import QuerySet
class UserTestCase(TestCase):
def setUp(self)
# (your setUp code here...)
self.create_models()
def create_models(self):
@aipi
aipi / example_ajax_view.py
Last active August 30, 2017 16:21
Django Ajax Get Request (Example code)
# It is just a example and not completed code
from django.http import JsonResponse
def ix_detail_pix(request, *args):
""" Ajax PIX info if clicked on PIX """
pix_uuid = request.GET['pix']
data = {}
pix_infos = get_pix_amounts_info(pix_uuid)