Skip to content

Instantly share code, notes, and snippets.

View rtorresve's full-sized avatar

Rafael Torres rtorresve

View GitHub Profile
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the minimumSwaps function below.
def minimumSwaps(arr):
@rodoufu
rodoufu / new-year-chaos.py
Created August 22, 2018 20:04
New Year Chaos
# 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
@PerroBueno
PerroBueno / linbinsearch.py
Created May 26, 2018 23:23
binary search
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
@vijayanandrp
vijayanandrp / CRUD operations using Pymongo Demo.md
Last active February 26, 2018 19:16
CRUD operations using Pymongo Demo - follow this tutorial for setup https://informationcorners.com/pymongo-wrapper

PyMongo Tutorial : Insert, Read, Update, Delete in MongoDB

# !/usr/bin/env python3.5
# -*- coding: UTF-8 -*-

import pprint
import dateutil.parser
import datetime
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 16, 2025 02:05
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@wesleybliss
wesleybliss / docker-compose-node-mongo.yml
Created September 9, 2016 21:37
Docker Compose with example App & Mongo
version: '2'
services:
myapp:
build: .
container_name: "myapp"
image: debian/latest
environment:
- NODE_ENV=development
- FOO=bar
volumes:
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
@GitRay
GitRay / serialize.py
Last active May 24, 2019 06:53 — forked from mrocklin/serialize.py
Serialization benchmark
# 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
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
@erdii
erdii / README.md
Last active November 15, 2016 14:56
Dockerizing Postgres

Dockerizing Postgres

docker run --name postgres -e POSTGRES_PASSWORD=YOURSECRETPASS -d -v /your/db/path:/var/lib/postgresql/data postgres

then link other containers with this one

using systemd: