# !/usr/bin/env python3.5
# -*- coding: UTF-8 -*-
import pprint
import dateutil.parser
import datetime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import math | |
import os | |
import random | |
import re | |
import sys | |
# Complete the minimumSwaps function below. | |
def minimumSwaps(arr): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Complete the minimumBribes function below. | |
def minimumBribes(q): | |
soma = 0 | |
for i in xrange(len(q) - 1, -1, -1): | |
if q[i] - (i + 1) > 2: | |
print("Too chaotic") | |
return | |
for j in xrange(max(0, q[i] - 2), i): | |
soma += q[j] > q[i] | |
print soma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
#Linear search | |
def linseach(ordered_list, element_to_find): | |
for i in ordered_list: | |
if i == element_to_find: | |
return True | |
return False | |
#Binary search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
myapp: | |
build: . | |
container_name: "myapp" | |
image: debian/latest | |
environment: | |
- NODE_ENV=development | |
- FOO=bar | |
volumes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y | |
sudo apt-get install libfreetype6 libfreetype6-dev -y | |
sudo apt-get install libfontconfig1 libfontconfig1-dev -y | |
cd ~ | |
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" | |
wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/$PHANTOM_JS.tar.bz2 | |
sudo tar xvjf $PHANTOM_JS.tar.bz2 | |
sudo mv $PHANTOM_JS /usr/local/share | |
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This has been edited to work with python3. Some of the tested combinations will not work in python2. | |
import pandas as pd | |
df = pd.DataFrame({'text': [str(i % 1000) for i in range(1000000)], | |
'numbers': range(1000000)}) | |
import pickle | |
# Python 3 has no cPickle | |
#import cPickle | |
import json | |
from functools import partial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rmongodb) | |
#connect to mongoDB | |
mongo = mongo.create(host = "localhost") | |
mongo.is.connected(mongo) | |
# User Similarity | |
bson <- mongo.find.one(mongo, "DeliciousMR.map_reduce_BM25UserSimilarity", query ='{"_id": "8;1;"}') | |
bson | |
# Item Similarity |
NewerOlder