Skip to content

Instantly share code, notes, and snippets.

View douglasdrumond's full-sized avatar
📷
brb

Douglas Drumond Kayama douglasdrumond

📷
brb
View GitHub Profile
n, k = gets.split.map(&:to_i)
processed = (0...1<<n).to_a.sort_by { |x| [x.to_s(2).count("1"), x] }
puts processed[k-1].to_s(2).rjust(n, '0')
n,k = map(int, raw_input().split())
processed = sorted(range(1<<n), cmp=lambda a,b: cmp(bin(a).count("1"), bin(b).count("1")) if cmp(bin(a).count("1"), bin(b).count("1")) else cmp(a,b))
print bin(processed[k - 1])[2:].zfill(n)
@douglasdrumond
douglasdrumond / coursera.py
Created November 7, 2012 18:43
Download machine learning videos from Coursera
import re, urllib
htmlSource = urllib.urlopen("https://class.coursera.org/ml/lecture/preview/1").read(200000)
linksList = re.findall('data-lecture-view-link="(.*?)"', htmlSource)
allVideos = []
for link in linksList:
print 'Open', link
htmlWithVideo = urllib.urlopen(link).read(200000)
videosList = re.findall('<source.*type="video/mp4".*? src="(.*?)"',htmlWithVideo)
@douglasdrumond
douglasdrumond / about.md
Created August 20, 2011 03:59 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
aula. Ele pratica. Instrumentistas geniais nao aprendem a tocar tendo
aula. Eles praticam. Pratique. Chegue em casa depois do trabalho e da
#!/usr/bin/env ruby
#
# Put this script in your PATH and download from onemanga.com like this:
# onemanga_downloader.rb Bleach [chapter number]
#
# You will find the downloaded chapters under $HOME/Documents/OneManga/Bleach
#
# If you run this script without arguments, it will check your local manga downloads
# and check if there are any new chapters
#