-
Notifications
You must be signed in to change notification settings - Fork 211
/
socode.py
executable file
·2108 lines (1694 loc) · 61.2 KB
/
socode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# Welcome to soCode, the social coding experiment.
# Here are the rules!
# - Add a function with your github name as its name.
# - Your function can do anything and everything, as long as it
# finishes in a reasonable amount of time (no infinite loops please)
# - Once your function is written, you can call it from anywhere else in
# the already existing exectution chain.
# - Never entirely delete anyone else's function, edit it if needed.
# - lafin() should be the last executing function, always
# Lets see if we can make something meaningful out of this.
import array
import sys
import json
import requests
import random
import getpass
import re
import hashlib
import os
import string
import math
import inspect
import webbrowser
import urllib2
import platform
import time
import struct
import ctypes
import glob
import logging
# Logging Support
#################
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s : %(levelname)s : %(message)s',
filename='socode.log',
filemode='w',
)
# IF ANY OF YOU GUYS WANT THE SOURCE OF THIS FILE USE THIS VARIABLE
###################################################################
socode_source = requests.get('https://raw.github.com/'
'sricola/socode/master/socode.py').content
def bluehatbrit():
print"This is a cool project, not sure where it'll go though!"
def newsocialifecom():
"A really usefull function, it does the hard job for you and prints the whole source code"
print(open(__file__).read());
def abhirajbutala():
"""
Wait Waa!!
"""
logging.info("I just added logging support for this important project!")
return
def nerdingoff():
"""
Prints an ASCII version of the personal logo of nerdingoff
ASCII was generated using: http://picascii.com
"""
print "This is my first Git project. Wahoo!"
logo = """
,#@@@@@;
#@@@@@@@@@@@@
@@@@@@@@@@@@@@@+
@@@@@@@@@@@@@@@@@@
.@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@,
@@@@@@@@@@@@@@@@@@@@@
;@@@@@@@@@@@@@@@@@@@@@@@,
@@@@,@@@@@@'` ,@@@@@@
`@@@@' '@@@
@@@@@ @@
@@@@@ '@
@@@@@ @
@@@@, @
@@@@ @
.@@@@ @
;@@@@ @
+@@@+:@ @# @' ; @,+@@+@ .@
+@@@#@:@@@@@@@@ @. @@@@@@@@@@
.@@@@ @@@@@@@@@@. @@@@@@@@@@
@@@+@@@@@@@@@@. .@@@@@@@@@'
@@+#@@@@@@@@@ @@@@@@@@@#
`@+ @@@@@@@@@+ @@@@@@@@
+@@@@@@@@ @@@@@@@
@@@@@+@ ,@ ,@
+,
"""
new_logo = ""
# Add spaces to make the logo wider
for c in logo:
new_logo = new_logo + c + " "
#Print out the now wider logo
print new_logo
def ryannolson():
print 'this is what someone said about socode on twitter: its awesome!'
def eduardohitek():
print "I dare you, I double dare you MotherFucker!"
def rixx():
# I wish I could contribute anything funny or useful.
print "Oh, you guys!"
eternalmatt()
def vedantlfc():
print"Hello everyone how're you doing?"
def thekarangoel():
print "I don't get it"
print "What's happening here?"
umurgdk()
def drostie():
"This function prints itself."
data = ['def drostie():\n "This function prints itself."\n data = ',
'\n print data[0] + repr(data) + data[1]']
print data[0] + repr(data) + data[1]
def mattgathu():
s = 'Huey approves this social coding experiment!!'
for x in s:
sys.stdout.write('%s' % x)
sys.stdout.flush()
time.sleep(0.25)
def glmdev():
name_string = """
_ _
__ _| |_ __ ___ __| | _____ __
/ _` | | '_ ` _ \ / _` |/ _ \ \ / /
| (_| | | | | | | | (_| | __/\ V /
\__, |_|_| |_| |_|\__,_|\___| \_/
|___/
"""
print name_string
print "If you put a hundred monkeys in a room for a hundred years, one of them will eventually write a Python program."
print "...the rest will just write Perl programs..."
print ""
print "http://glmdev.tech/"
def harshavardhana(data):
n = b = 0
decode = out = ''
for c in data:
if '!' <= c and c <= 'u':
n += 1
b = b * 85 + (ord(c) - 33)
if n == 5:
decode += struct.pack('>L', b)
n = b = 0
elif c == 'z':
assert n == 0
decode += '\0\0\0\0'
elif c == '~':
if n:
for _ in range(5 - n):
b = b * 85 + 84
out += struct.pack('>L', b)[:n - 1]
break
print decode
def sorliem():
print "This is my first contribution to a github project!!"
def thisjustin(command=None, username=None):
"""
Responds to a few choice HAL 9000
commands form 2001: A Space Odyssey
"""
user = username if username else 'Dave'
if command == 'open the pod bay doors':
print "I'm sorry, %s. afraid I can't do that." % user
elif command == 'sing a song':
print "Daisy, Daisy, give me your answer do. I'm half\
crazy all for the love of you. It won't be a stylish\
marriage, I can't afford a carriage. But you'll look sweet\
upon the seat of a bicycle built for two."
elif command == 'do you read me?':
print "Affirmative, %s. I read you." % user
elif command is None:
print "Just what do you think you're doing, %s?" % user
def ray0sunshine():
print "Gibe moni pls"
print "Morde es numero uno"
for br in xrange(666):
print "HUE "
if random.randint(0, 9) == 6:
print "BR?\n"
print "i repot u too"
def hutattedonmyarm(a=0, b=0, c=0):
print "People assume that time is a strict " \
"progression of cause to effect, but " \
"*actually* from a non-linear, non-subjective viewpoint - " \
"it's more like a big ball of wibbly wobbly... " \
"time-y wimey... stuff."
print "Sorry, I've got a complex life. Things sometimes don't " \
"happen to me in the right order. Especially weddings. "\
"I'm rubbish at weddings. Especially my own."
rjwebb((1337 * a + b) * c + 42)
antonaut("Green")
print "Matrix, bitches"
return (a * a + b * b == c * c)
def _3boll():
word = []
consonants = "Socialcoding is so cool. Coffe 4 all <3"
vowels = "aeiou3"
print "3boll.com"
for i in range(random.randint(3, 15)):
if i % 5 == 0:
letter = random.choice(vowels)
else:
letter = random.choice(consonants)
word.append(letter)
return '3boll '.join(word)
def hmason():
""" introduce randomness """
exec random.choice(re.findall('def (.*):', socode_source))
def phooky():
"""
Key party!
Everybody's function goes home with a different name than it showed up with.
"""
# lafin by fiat; daniel_dressler's return value is used elsewhere;
# phooky because if it's executed after that method that wraps all
# functions we lose metadata about wrapped fns.
exclusion_list = ['lafin','daniel_dressler','phooky']
g = globals()
# Excluding functions with arguments. grumble grumble typing.
flist = [(k,v) for k,v in g.items() if
isinstance(v,type(phooky)) and
k not in exclusion_list and
v.func_code.co_argcount == 0]
# swap names around
names, bodies = map(list,zip(*flist))
random.shuffle(bodies) # oh my
for name, body in zip(names, bodies):
g[name] = body
# ... have fun, kids.
print('phooky is now {0}!'.format(phooky.func_code.co_name))
# Let's see if you can guess what it does without executing it! (Does no harm, just some list operations)
# Works on both Python 2 and Python 3 (and on PyPy I guess?).
# :param l: A list (o.0)
rubik=lambda l:(lambda n,f,u,m:m(lambda i:f(u,i,u[n-i-1],n-i-1,u[i],m),range(n//2)))(len(l),(lambda n,i,l,o,u,m:m(lambda f:n.__setitem__(f[0],f[1]),((i,l),(o,u)))),l,(lambda p,q:list(map(p,q))))
def rjwebb(n):
"""
Tries to print the username,
real name and location of the
first n users in this file. Fails silently.
"""
def get_user_page(username):
gh_url = "https://github.com/%s.json" % username
return urllib2.urlopen(gh_url).read()
def dict_get(dict, key):
try:
return dict[key]
except KeyError:
return ""
with open(os.path.realpath(__file__), 'r+') as f:
local_file = f.read()
user_name_pattern = "[a-zA-Z][a-zA-Z\-]*"
fun_start_pattern = "\ndef (%s)" % user_name_pattern
users = re.findall(fun_start_pattern, local_file)
for user in users[:n]:
try:
r = get_user_page(user)
j = json.loads(r)
if j != []:
try:
attrs = dict((k, v.encode("utf-8"))
for k, v in j[0]["actor_attributes"].items())
print user + ":\n\t" + dict_get(attrs, "name") + "\n\t" + \
dict_get(attrs, "location")
except KeyError:
pass
except Exception:
pass
def BuahApple():
print "I have no idea what to put here."
def antonaut(print_color=None):
"""
Sets the color of sys.stdout to print_color.
WHICH MEANS:
>>> antonaut()
>>> print "asdfqwerty" # GIEFS AWESUM COLORZ (in a bash shell).
If no color is given, it randomizes the color of the output. YAY!
DOUBLE RAINBOOOOOOW!"""
# Not really sure of these... Just got them from:
# http://hacktux.com/bash/colors
colors = {
"Black": "\033[30m",
"Dark Gray": "\033[1;30m",
"Blue": "\033[34m",
"Light Blue": "\033[1;34m",
"Green": "\033[32m",
"Light Green": "\033[1;32m",
"Cyan": "\033[36m",
"Light Cyan": "\033[1;36m",
"Red": "\033[31m",
"Light Red": "\033[1;31m",
"Purple": "\033[35m",
"Light Purple": "\033[1;35m",
"Brown": "\033[33m",
"Yellow": "\033[1;33m",
"Light Gray": "\033[37m",
"White": "\033[1;37m"
}
color_off = '\033[0m'
def colorify(c, color=print_color):
"""Paints a character.
Defaults to random color."""
if color:
return colors[color] + c + color_off
choice = random.randint(0, len(colors.keys()) - 1)
return colors.values()[choice] + c + color_off
plat = platform.system().lower()
if plat == 'linux' or plat == 'darwin':
### DUCK PUNCHING PRINT ###
### http://stackoverflow.com/questions/4883789/adding-a-
### datetime-stamp-to-python-print
stdout = sys.stdout
class F():
def write(self, x):
s = u""
for c in x:
if c == '\n':
s += u'\n'
else:
s += unicode(colorify(c))
stdout.write(s)
def flush(self):
stdout.flush()
# Change stdout
sys.stdout = F()
def sikado():
print "There is", len(socode_source), "characters in this file..."
thekarangoel()
def jatinpandey():
enough = False
nugget_count = random.randint(0, 80)
if nugget_count >= 40:
enough = True
if enough:
response = "Lunch, ye ask? I'll have " + nugget_count + " chicken nuggets or wateva"
else:
response = "Oh sheesh y'all, I need more McDs"
print response
def alisnic(number):
print 'fizz' * (number % 3 == 0) + 'buzz' * (number % 5 == 0)
def payomdousti():
print "There is no spoon."
def _return():
print " ,dPYb, ,dPYb, ,dPYb, "
print " IP'`Yb IP'`Yb IP'`Yb "
print " I8 8I I8 8I I8 8I "
print " I8 8' I8 8' I8 8' "
print " I8 dPgg, ,ggg, I8 dP I8 dP ,ggggg, "
print " I8P I8 I8, ,8I I8P I8P i8' ,8I "
print ",d8 I8, `YbadP' ,d8b,_ ,d8b,_ ,d8, ,d8' "
print " 88P `Y8888P`Y8888P'`Y888P'`Y88P*Y8888P' "
print " "
print "===== From @return ===== "
def starefossen():
print requests.get('http://kdd2.1337fire.com/').content
codesuela('b')
def caffeinewriter():
print "My name is Brandon Anzaldi.\nI may not be the best coder (yet), but I'm working on it.\nI'm what some people would call a hacker, and what some others would call a geek.\nBut there's one thing I'm sure of.\nI'd like to make stuff.\nThis is more or less a placeholder, until this can be the place where cool stuff is.\nMaybe you'll be able to make your own spaceship just by putting a few datapoints in, but until that day comes, this is just me.\n\n-Brandon"
def ozdemircili():
print "Probably we can do some admin staff too!."
print map(lambda x: "This project is going to Rock! " +
("Don`t you think?"), range(1))
def auxiliary_character():
def abusive_decorator(f):
return f()
@abusive_decorator
def abused_function():
return "This is how not to use decorators."
print abused_function
def jontonsoup():
print "There's always one more bug."
def monsdar():
print "Hello?..."
print " ...yes, this is dog!"
def heinzf(update=True):
"""
Compare itself with the raw code github.
If there's something new, it updates the file localy.
"""
git_file = socode_source
git_hash = hashlib.sha256(git_file).hexdigest()
with open(os.path.realpath(__file__), 'r+') as f:
local_file = f.read()
f.close()
local_hash = hashlib.sha256(local_file).hexdigest()
if local_hash != git_hash and update is True:
with open(os.path.realpath(__file__), 'w+') as f:
f.write(git_file)
print 'I update myself, when I think about you, lalalala'
f.close()
def zachlatta():
import antigravity
def doctorpangloss():
raw = socode_source
# not sure what is being achieved here - @sricola
#matches = re.sub(r'doctorpangloss\(\)\n', r'doctorpangloss()\ndoctorpangloss()\n', raw, re.M|re.I|re.G)
#print raw
def ankushsachdeva():
contents = open(__file__).read()
print re.findall('def .* :', contents)
def adelevie():
pass
def thisishugo():
time.sleep(1)
def dlad():
cursor = '/-\|'
for i in xrange(0, 4):
for c in cursor:
sys.stdout.write(c)
time.sleep(0.1)
sys.stdout.write('\b')
sys.stdout.flush()
def piperchester():
print "I love this idea. Hailing from Rochester, NY!"
def binary132():
print "Perl is better. PS everyone is lazy"
daniel_dressler()
def sricola():
print "Welcome to soCode!!"
def bencooling():
print "I don't know Python; I don't belong here"
zachlatta()
def quarterto(m, n):
pass
#if m == 0:
#return n + 1
#elif m > 0 and n == 0:
#return quarterto(m - 1, 1)
#elif m > 0 and n > 0:
#return quarterto(m - 1, quarterto(m, n - 1))
#else:
#return 0
def zgohr(city):
weather = json.loads(requests.
get('http://api.openweathermap.org'
'/data/2.1/find/name?q=%s' % city).content)
kelvin = weather['list'][0]['main']['temp']
fahrenheit = 9 / 5 * (kelvin - 273) + 32
print 'and it is too damn cold' \
if fahrenheit < 50 else 'and the temperature outside is tolerable'
def kisom():
geoip = json.loads(requests.get('http://freegeoip.net/json/').content)
print 'there once was a coder from', geoip['country_name']
zgohr(geoip['city'])
def daniel_dressler(): # really daniel-dressler
return 42
def evinugur():
print 'there is a ', (random.random() * 100), \
"% chance that something cool will come from this..."
def ncammarata():
tweets = requests.get("https://search.twitter.com/search.json?q=a").json
tweet = tweets['results'][0]['text']
print "Random Tweet:", tweet.encode('utf-8')
# Generate a random nonsense word with a vowel:consolant ratio of 1:5
def taylorlapeyre():
word = []
consonants, vowels = "socialcoding", "aeiou"
for i in range(random.randint(3, 15)):
if i % 5 == 0:
letter = random.choice(vowels)
else:
letter = random.choice(consonants)
word.append(letter)
return ''.join(word)
def thenonameguy():
print "Go is awesome!"
def kghose():
import curses
import time
def main_loop(window):
window.clear()
N = 100
primes = []
this_prime = 2
keep_finding = True
numbers = [n for n in xrange(N + 1)]
numbers[1] = None
while keep_finding:
primes.append(this_prime)
for n in xrange(2 * this_prime, N + 1, this_prime):
numbers[n] = None
paint_grid(window, numbers)
keep_finding = False
for n in xrange(this_prime + 1, N + 1):
if numbers[n] is not None:
this_prime = n
keep_finding = True
break
def paint_grid(window, numbers):
for row in xrange(10):
for col in xrange(10):
n = 10 * row + col + 1
if numbers[n] is not None:
s = str(n)
else:
s = ' '
window.addstr(row, 3 * col, s)
window.refresh()
time.sleep(.1)
curses.wrapper(main_loop)
def jessex():
os.execl("/bin/echo", "echo", "This is a long way to go for "
"'hello world' but life's about the journey.")
def mergesort():
a = "to all"
b = "spread love"
a, b = b, a
print a + " " + b
def lafin():
print "Goodbye Social World!"
print "\nStarted with <3 in Brooklyn, NY\n"
def prezjordan():
h, s = '.;*&8#', ''
for q in range(HoLyVieR(daniel_dressler() + 1, 1013)):
if q % 40 == 0:
print s
s = ''
i, k = 0, 0
while(abs(k) < 2 * (i < 15)):
k, i = k ** 2 + complex(q % 40 * .075 - 2, q / 40 * -.1 + 1), i + 1
s += h[i / 3] * 2
def JesseAldridge():
def wrap(f):
def new_f(*args, **kwargs):
start_time = time.time()
for i in range(random.randrange(1, 3)):
ret_val = f(*args, **kwargs)
if time.time() - start_time > .1:
break
return ret_val
return new_f
g = globals()
for k, v in g.iteritems():
if callable(v) and k != 'JesseAldridge':
g[k] = wrap(v)
def eternalmatt():
print "Never gonna give you up."
print "Never gonna let you down."
print "Never gonna run around."
print "And desert you."
def charliegroll():
print "Never gonna make you cry,"
print "Never gonna say goodbye,"
print "Never gonna tell a lie and hurt you."
def justinrsmith():
tablist = []
wordlist = ['look', 'at', 'my', 'tabs']
for x in range(0, 4):
tablist.append('\t')
numTabs = 1
for y in range(0, 4):
print ''.join(tablist[0:numTabs]) + wordlist[y]
numTabs = numTabs + 1
def devonbarrett():
print "We're no strangers to love"
print "You Know the rules and so do I"
print "A full commitment's what I'm thinking of"
print "You wouldn't get this from any other guy"
print "I just wanna tell you how I'm feeling"
print "Gotta make you understand"
eternalmatt()
charliegroll()
def lbalceda(value=None):
if value is None:
value = 100
print map(lambda x: x * 2, range(1, value))
def shuhaowu(): # Call me last! :D
l = locals()
for f in l.keys():
if not (f.startswith("_") or f == "shuhaowu"):
del l[f] # ^_^
print "Goodbye, cruel world"
def agoebel():
print "America!"
def MikeGrace():
print map(lambda x: "Happy Birthday to " + ("you" if x != 2 else
"dear " + getpass.getuser()), range(4))
def theabrad():
print "Baltimore Ravens"
print "Super Bowl Champions!!!"
def ZackMullaly():
f = open("temporary.txt", "w")
stdout = sys.stdout
sys.stdout = f
for stuff in globals():
if stuff.startswith("__") and stuff.endswith("__"):
continue
globals()[stuff]
f.close()
sys.stdout = stdout
output = open("temporary.txt").read().split("\n")
longest = sorted(output, lambda a, b: 1 if len(a) < len(b) else -1)[0]
print "The longest thing anyone's said seems to be " + longest
def tcr():
print "You know we love you, ", getpass.getuser(), "."
def fmazon3():
print "%d" % 0xDEADC0DE
def peterwallhead():
print '\n'.join('Fizz' * (not i % 3) +
'Buzz' * (not i % 5) or str(i) for i in range(1, 101))
def cyclo():
print "!dnalgnE morf olleH"[::-1]
def vellamike(n=10):
if n == 0:
return 0
if n == 1:
return 1
return vellamike(n - 1) + vellamike(n - 2)
def yukaritan():
"""Yay fizzbuzz!"""
n = 1
while True:
if not n % 15:
yield "FizzBuzz"
elif not n % 3:
yield "Fizz"
elif not n % 5:
yield "Buzz"
else:
yield str(n)
n += 1
def chrisgw():
print "meh"
def yuvadm():
print socode_source
def spectralshadow514():
print "Hello Social Coding World!"
def maxmackie(crypt_me):
"""Just try and crack this cipher."""
abc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
crypt = "mplnkoijbqazdsxcwerfgvhutyQASXZWDVFCERGTBHNYKMJLUPIO4567382901"
print crypt_me.translate(string.maketrans(abc, crypt))
def uiri():
with open(os.path.realpath(__file__), 'r') as f:
for line in f.readlines():
if line.strip()[:5] == "print":
print line.strip()
def jpadilla():
repo = requests.get('https://api.github.com/repos/sricola/socode').json
try:
print 'Forked {} times'.format(repo['forks_count'])
except ValueError:
pass
def wmill():
nyan = requests.get('https://raw.github.com/vtsvang/'
'nyancat-telnet-node/master/assets/animation.json')\
.json()[0]
print nyan
def rburgosnavas(name):
x = (len(name) + 4)
print "*" + "-" * x + "*"
print "|\\" + '-' * (x - 2) + "/|"
print "| *" + name + "* |"
print "|/" + '-' * (x - 2) + "\\|"
print "*" + "-" * x + "*"
def GeneralZero(): # Spin the wheel
random.choice([obj for name, obj in
inspect.getmembers(sys.modules[__name__])
if inspect.isfunction(obj)])()
def bprater():
print "social coding, the end is near."
def satshabad():
# this doesn't seem to space right...
for x in range(10000):
r = random.randint(0, 1)
if r == 0:
sys.stdout.write('/')
else:
sys.stdout.write('\\')
def henghonglee():
print "#!brain"
def jhgaylor():
print "Signing in from Starkville, Mississippi."
def hklebs():
print "000000000000000000000000000000"
print "0000 0000 000000 0000"
print "0000 0000 000000 0000"
print "0000 0000 00000000000000"
print "0000 000000 0000"
print "0000 0000 000000 0000"
print "0000 0000 000000 0000"
print "0000 0000 000000 0000"
print "000000000000000000000000000000"
def mmay():
url = "http://placekitten.com/%d/%d" % \
(random.randint(500, 1000), random.randint(500, 1000))
print "Get your daily dose of kitten at: " + url
def jeffjose():
print "Hi from India!"
def julio():
print 111111111 * 111111111
print quarterto(4, 2)
def ondrae(): # Random compliment. If anyone has a better source, add it in.
response = requests.get("http://peoplearenice.blogspot.com"
"/p/compliment-list.html")
lines = response.text.split('\n')
pattern = '\d+\.\s+(.*)</span>'
compliments = []
for line in lines:
m = re.search(pattern, line)
if m:
compliments.append(m.group(1))
print getpass.getuser() + ', ' + \
compliments[random.randint(1, len(compliments))].lower()
def djrausch():
print "DAE #HOLO? #NEXUS #HOLOYOLO"
# Checks to see if an episode of Doctor Who aired on this date,
# and if so the title.
# be gentle, I am new to python
def mikemiles86(lookup_date=False):
# 1. check for a list of air dates
if os.path.exists('doctorwho.txt'):
# 1.1 file exists, load it
f = open('doctorwho.txt', 'r')
airdates = eval(f.read())
f.close()
else:
# 1.2 file not found, generate it
airdates = {}
#1.2.1 get air dates of original series (1963 - 1996)
response = requests.get('http://epguides.com/DoctorWho/')
lines = response.text.split('<pre>')[1].split('</pre>')[0].split('\n')
for line in lines:
line = line.strip()
if re.match('\d+\.', line):
episode_title = line.split('</a>')[0].split('>')[1].strip()
elif re.match('\d+\-', line):
line = re.sub('\s{2,}', '~', line).split('~')
date = line[2].strip().split(' ')
year = date.pop().strip()
date = '/'.join(date).strip()
title = line.pop().strip()
if re.match('\d+', year):
year = '19' + year
if title[:4] == 'Part':
title = episode_title + ':' + title
if airdates.get(year, False) is False:
airdates[year] = {}
airdates[year][date] = line[0].strip() + ' ' + title
#1.2.2 get air dates of new series (2005 - 2013)
response = requests.get('http://epguides.com/DoctorWho_2005/')
lines = response.text.split('<pre>')[1].split('</pre>')[0].split('\n')
for line in lines:
line = re.sub('\s{2,}', '~', line).split('~')
if re.match('\d+', line[0]) and len(line) == 4:
date = line[2].strip().split('/')
year = date.pop().strip()
date = '/'.join(date).strip()
name = line.pop().split('</a>')[0].split('>').pop().strip()
if re.match('\d+', year):
year = '20' + year
if airdates.get(year, False) is False:
airdates[year] = {}
airdates[year][date] = line[1].strip() + ' ' + name
#1.2.3 store dictionary into file
f = open('doctorwho.txt', 'w')
f.write(str(airdates))
f.close()
# 2. get current date in same format as keys
if lookup_date:
now = lookup_date
else:
now = time.strftime("%d/%b")
episodes = ''
# 3. an episode aired on this date
for year in airdates:
if airdates[year].get(now, False):
# 3.1 Yes, print the details
episodes += 'The Doctor Who episode "' + airdates[year][now] + \
'" aired on this day in ' + year + "\n"
if len(episodes):
print episodes
else:
print 'No episodes of Doctor Who have aired on ' + now + '... yet.'
def aniketpant():
print "Moving the world off Internet Explorer 6"
print "Tell your friends to join the cause. " \
"Share this site http://bit.ly/ie6countdown and tweet " \
"#ie6countdown. Let everyone know that you're doing your " \
"part to get Internet Explorer 6 to 1%."
# Compute the modular multiplicative inverse using the extended
# Euclide algorithm
# See this for more information :
# http://en.wikipedia.org/wiki/Modular_multiplicative_inverse