Skip to content

Instantly share code, notes, and snippets.

Victor Carriço Santos victorcarrico

Block or report user

Report or block victorcarrico

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@victorcarrico
victorcarrico / dmap.py
Created Dec 4, 2018
Celery Canvas: It's basically the inverse chord which is like a map_reduce. This run a task and with the result run a celery group with the results.
View dmap.py
from celery import task, subtask, group
@task
def get_list(amount):
return [i for i in range(amount)]
@task
def process_item(item):
# do stuff
@victorcarrico
victorcarrico / easy_profiling.py
Last active Dec 13, 2018
Easy Line Profile Example
View easy_profiling.py
from line_profiler import LineProfiler
import random
def do_stuff(numbers):
s = sum(numbers)
l = [numbers[i]/43 for i in range(len(numbers))]
m = ['hello'+str(numbers[i]) for i in range(len(numbers))]
numbers = [random.randint(1,100) for i in range(1000)]
lp = LineProfiler()
@victorcarrico
victorcarrico / spread_instagram_message.py
Created Apr 29, 2017
Send a message to a group of Instagram users (using instagram-python)
View spread_instagram_message.py
from InstagramAPI import Instagram
def get_user_info_and_login():
try:
username = raw_input('Your Instagram username:\n')
password = raw_input('Your Instagram password:\n')
print 'Wait a second, logging in your account.\n'
api = Instagram(username, password)
api.login()
@victorcarrico
victorcarrico / password_validators.js
Created Feb 2, 2017
Django password validators in javascript
View password_validators.js
import difflib from 'difflib';
// Password Validation
export function userAttributeSimilarityValidator(password, attributes) {
const DEFAULT_USER_ATTRIBUTES = ['first_name', 'last_name', 'email'];
const max_similarity = 0.7;
for (let user_attr of DEFAULT_USER_ATTRIBUTES) {
@victorcarrico
victorcarrico / nude_detection.py
Created Aug 12, 2016
Nude detection algorithm with Python and OpenCV using Bag-of-Visual-Features.
View nude_detection.py
# coding: utf-8
import cv
import cv2
import numpy as np
from sklearn.cluster import KMeans
class BoVF(object):
@victorcarrico
victorcarrico / test_image_upload.py
Last active Jan 18, 2017
Django REST Framework - Testing image upload
View test_image_upload.py
import tempfile
from PIL import Image
class PhotoCreateAPIViewTest(TestCase):
def setUp(self):
super().setUp()
self.tmp_file = tempfile.NamedTemporaryFile(suffix='.jpg')
image = Image.new('RGB', (100, 100))
You can’t perform that action at this time.