Skip to content

Instantly share code, notes, and snippets.

View thekindlyone's full-sized avatar

Aritra Das thekindlyone

  • @TeamAlbi
  • New Zealand
View GitHub Profile
>>> reduce(lambda x,y: x+y, xrange(int(raw_input('enter first number: ')),int(raw_input('Enter second number: '))+1) )
enter first number: 4
Enter second number: 7
22
(5:56:52 AM) Yassine Chaouche: ContagiousLaughter
(5:57:41 AM) Yassine Chaouche: todayilearned
(5:57:46 AM) Yassine Chaouche: sysadmin
(5:57:51 AM) Yassine Chaouche: happycrowds
(5:57:57 AM) Yassine Chaouche: MusicForConcentration
(5:58:01 AM) Yassine Chaouche: learnprogramming
(5:58:09 AM) Yassine Chaouche: groovesharkplaylists
(5:58:13 AM) Yassine Chaouche: Anticonsumption
(5:58:17 AM) Yassine Chaouche: learnpython
(5:58:32 AM) Yassine Chaouche: AskReddit
In [1]: import webbrowser,re
In [2]: for sub in ('http://www.reddit.com/r/'+subreddit for subreddit in (match.group(1) for match in [re.search('Chaouche: (.+)',line) for line in open('subreddits.txt').read().split('\n')])): webbrowser.open(sub)
multislice=lambda mainstring,indices: ''.join([i[1] for i in enumerate(mainstring) if i[0] in indices])
print multislice('This page contains examples and source code',[0,2,5,11,12,14,15,23,24,25,26])
print ''.join([i[1] for i in enumerate('This page contains examples and source code') if i[0] in [0,2,5,11,12,14,15,23,24,25,26]])
@thekindlyone
thekindlyone / gist:8364401
Created January 10, 2014 23:04
comparison
def testvivek():
i=0
sum=0
giveup3=0
giveup5=0
lim=1000
while True:
num3=3*i #generating multiples for processing
num5=5*i # ^
if num3>=lim: # if multiple of 3>limit then stop adding those, and set flag
@thekindlyone
thekindlyone / gist:8364163
Created January 10, 2014 22:44
for vivek
i=0
sum=0
giveup3=0
giveup5=0
lim=1000
while True:
num3=3*i #generating multiples for processing
num5=5*i # ^
if num3>=lim: # if multiple of 3>limit then stop adding those, and set flag
giveup3=1
@thekindlyone
thekindlyone / vlcwraPy.py
Created December 28, 2013 19:51
VLC player hack to load prev/next files in folder in one keystroke. once assigned to windows right click on video files via regedit, uses pyhook to bind HOME and END keys to load prev and next files in folder. stops and starts vlc processes to achieve this behavior.
import os
import sys
import pythoncom, pyHook
import win32api
import subprocess
import ctypes
import threading
from multiprocessing import *
import time
@thekindlyone
thekindlyone / thekindlybot.py
Created December 28, 2013 19:44
xmpp chat-bot that emails music among other things. Uses beets music organizer http://beets.radbox.org/
import logging
from sleekxmpp import ClientXMPP
from sleekxmpp.exceptions import IqError, IqTimeout
import subprocess
import smtplib
import mimetypes
import email
import email.mime.application
import thread
import os