Skip to content

Commit 4aefa2c

Browse files
author
Dineshkarthik
committed
ooh my commit message
1 parent 55ba879 commit 4aefa2c

8 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/local/bin/python
2+
#coding=utf-8
3+
__author__ = 'Dineshkarthik'
4+
5+
#0001 Title: As Apple Store App independent developer, you engage in limited-time promotion for your application to generate activation code (or coupon), how to use Python to generate 200 activation code (or coupon)?
6+
7+
import uuid
8+
9+
def act_code(count):
10+
f = open('code.txt', 'wb')
11+
for i in range(count):
12+
s = str(uuid.uuid4().get_hex().lower()[0:8])
13+
f.write(''.join(s) + '\n')
14+
f.close()
15+
16+
if __name__ == '__main__':
17+
act_code(200)

Dineshkarthik/0003/0003.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/local/bin/python
2+
#coding=utf-8
3+
__author__ = 'Dineshkarthik'
4+
5+
#0003 Title: The 0001 title generated 200 activation code (or coupon) to save Redis non-relational databases.
6+
7+
from walrus import *
8+
9+
def redis_store(count):
10+
db=Database(host='localhost',port=6379,db=0)
11+
h = db.List("activation_code")
12+
for i in range(count):
13+
s = str(uuid.uuid4().get_hex().lower()[0:8])
14+
h.extend([s])
15+
16+
if __name__ == '__main__':
17+
redis_store(200)

Dineshkarthik/0004/0004.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/local/bin/python
2+
#coding=utf-8
3+
__author__ = 'Dineshkarthik'
4+
5+
#0004 Title: any of a plain text file in English, statistics on the number of words appears.
6+
7+
import pandas as pd
8+
import re
9+
10+
def word_count(file_path):
11+
word_string = [line.rstrip('\n') for line in open(file_path)]
12+
words = []
13+
for word in word_string:
14+
tt = word.lower()
15+
t=re.sub(r'[^\w]', ' ', tt)
16+
for word in t.split():
17+
words.append(word)
18+
19+
p = pd.Series(words)
20+
#get the counts per word
21+
freq = p.value_counts()
22+
#how many max words do we want to give back
23+
freq = freq.ix[0:25]
24+
print freq
25+
if __name__ == '__main__':
26+
word_count("input.txt")
27+

Dineshkarthik/0004/input.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Python Workbook, a small daily program
2+
3+
Explanation:
4+
5+
Python Workbook, a small daily program. Note: Python into other languages, most of the topics also apply
6+
Do not appear, such as "print multiplication table", "Print Narcissus" like topic
7+
In this paper, the history of this paper by the @ Jiang Song ( shijiangge@gmail.com QQ: 499 065 469) according to organize data collection from the Internet, thanks to the Internet, thanks for sharing. Thanks! This article will be updated continuously.
8+
Welcome to the Pull Request a problem, paste the code (Gist, Blog can be) :-)
9+
Welcome to answer, and send pull request to the Show-Me-the-Code

Dineshkarthik/0006/0006.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/local/bin/python
2+
#coding=utf-8
3+
__author__ = 'Dineshkarthik'
4+
5+
#0006 title: Do you have a catalog, you put a month's diary, they are txt, word in order to avoid the problem, assuming that the content is in English, see the statistics of each diary you think the most important word.
6+
7+
import re
8+
import pandas as pd
9+
import glob
10+
import fnmatch
11+
import os
12+
13+
def word_count(file_path):
14+
data = []
15+
for root, dirnames, filenames in os.walk(file_path):
16+
for filename in fnmatch.filter(filenames, '/*.txt'):
17+
data.append([line.rstrip('\n') for line in open(os.path.join(root, filename))])
18+
word_string = ["".join(str(x) for x in data)]
19+
words = []
20+
ignore_words = ["omitted", "media","a","able","about","above","abst","accordance","according","accordingly","across","act","actually","added","adj","affected","affecting","affects","after","afterwards","again","against","ah","airport","alarm","alive","all","almost","alone","along","already","also","although","always","am","among","amongst","an","and","angry","announce","another","answer","any","anybody","anyhow","anymore","anyone","anything","anyway","anyways","anywhere","apart","app","apparently","application","approximately","are","aren","arent","arise","arm","around","as","aside","ask","asking","at","auth","available","away","awfully","b","back","bad","bag","bake","bar","be","became","because","become","becomes","becoming","been","beer","before","beforehand","begin","beginning","beginnings","begins","behind","being","believe","bell","below","bend","beside","besides","between","beyond","bike","bill","biol","bite","boose","boss","both","brief","brief","briefly","bro","buddy","busy","but","button","by","c","ca","calculate","calculated","call","called","calm","came","can","can't","cannot","cat","cause","causes","certain","certainly","chat","chair","channel","check","close","closing","clue","co","code","coffee","com","come","comes","company","complete","completed","congrats","contain","containing","contains","could","couldnt","cow","crash","cross","d","da","dai","data","database","date","daughter","day","db","delete","deleted","desk","did","didn't","diet","different","dinner","do","does","doesn't","dog","doing","don't","done","down","downwards","drive","dude","due","during","e-mail","e","each","ear","ear","ears","ease","east","easy","ed","edu","effect","eg","eh","eight","eighty","either","else","elsewhere","email","emp","empty","end","ending","enough","error","especially","et-al","et","etc","even","evening","ever","every","everybody","everyone","everything","everywhere","ex","except","exciting","eye","eyes","f","far","fault","female","few","ff","fifth","file","first","five","fix","flower","fly","followed","following","follows","food","for","former","formerly","forth","found","four","friday","friend","from","fuck","fun","funny","further","furthermore","g","garbage","gate","gave","gb","get","gets","getting","girl","git","give","given","gives","giving","glove","go","god","goes","gone","good","got","gotten","great","gross","guy","h","ha","had","hair","hall","happens","hardly","has","hasn't","hate","have","haven't","having","he","hed","hello","hence","her","here","hereafter","hereby","herein","heres","hereupon","hers","herself","hes","hi","hid","high","him","himself","his","hither","ho","holy","home","hope","how","howbeit","however","hundred","husband","i","i'll","i've","id","ie","if","im","image","immediate","immediately","importance","important","in","inc","increase","increased","indeed","index","information","instead","into","invention","inward","iron","is","isn't","it","it'll","itd","its","itself","j","junior","just","k","keep","keeps","kept","kg","kid","kids","km","know","known","knows","l","largely","last","lately","later","latter","latterly","laugh","least","leave","leg","legs","less","lest","let","lets","life","like","liked","likely","line","list","little","ll","load","lol","look","looking","looks","lost","loud","love","low","ltd","lucky","lunch","m","ma'am","maam","madam","made","mail","mainmainly","make","makes","male","mam","many","marry","matemay","maybe","mb","me","meal","meals","mean","means","meantime","meanwhile","men","menu","merely","message","mg","might","million","mineral","miss","ml","mobile","monday","monthly","more","moreover","morning","most","mostly","move","movie","mr","mrs","much","mug","must","my","myself","n","na","name","named","namely","nay","nd","near","nearly","necessarily","necessary","need","needs","neither","never","nevertheless","new","next","nine","ninety","no","nobody","noise","non","none","nonetheless","noone","nor","normally","north","nos","not","noted","nothing","now","nowhere","np","o","obtain","obtained","obviously","of","off","offer","often","oh","ok","okay","old","omitted","on","once","one","ones","only","onto","open","opening","or","ord","other","others","otherwise","ought","our","ours","ourselves","out","outside","over","overall","owing","own","p","page","pages","part","particular","particularly","past","pattern","pause","pay","pays","pencil","per","perhaps","phone","photo","picture","ping","placed","play","please","pls","plus","pong","poorly","possible","possibly","potentially","pp","predominantly","present","previously","primarily","pro","probably","promise","promptly","proof","proud","provides","pull","push","put","q","que","quickly","quiet","quit","quite","qv","r","ran","rather","ratio","rd","re","readily","really","recent","recently","ref","refs","regarding","regardless","regards","related","relatively","reload","reply","research","respectively","restraunt","resulted","resulting","results","right","rock","rofl","roll","run","s","said","same","saturday","saw","say","saying","says","script","sec","section","see","seeing","seem","seemed","seeming","seems","seen","self","selves","send","senior","sent","sent","seven","several","shall","she","she'll","shed","shes","shit","shock","should","shouldn't","show","showed","shown","showns","shows","shut","significant","significantly","similar","similarly","since","sir","sirr","six","slightly","slip","smoke","so","some","somebody","somehow","someone","somethan","something","sometime","sometimes","somewhat","somewhere","son","song","soon","sorry","sort","sound","south","specifically","specified","specify","specifying","sport","sports","still","stop","story","strongly","sub","substantially","successfully","such","sufficiently","suggest","sunday","sup","super","superb","sure","take","taken","taking","tall","tea","team","tear","tell","temporary","tends","term","test","text","th","than","thank","thanks","thanx","that","that'll","that've","thats","the","their","theirs","them","themselves","then","thence","there","there'll","there've","thereafter","thereby","thered","therefore","therein","thereof","therere","theres","thereto","thereupon","these","they","they'll","they've","theyd","theyre","thing","think","this","those","thou","though","thoughh","thousand","throat","throug","through","throughout","thru","thursday","thus","tight","til","till","time","tiny","tip","to","today","toe","together","too","took","tooth","toward","towards","tower","town","translate","tried","tries","truck","truly","trust","try","trying","ts","tuesday","twice","two","u","un","under","unfair","unfortunately","unless","unlike","unlikely","until","unto","up","update","updated","upon","upper","ups","us","use","used","useful","usefully","usefulness","user","uses","using","usually","v","value","various","ve","very","via","visible","viz","vol","vols","volume","vs","w","wake","want","wants","was","wash","wasnt","way","we","we'll","we've","web","website","wed","wednesday","weekend","weekly","welcome","went","were","werent","west","what","what'll","whatever","whats","when","whence","whenever","where","whereafter","whereas","whereby","wherein","wheres","whereupon","wherever","whether","which","while","whim","whither","who","who'll","whod","whoever","whole","whom","whomever","whos","whose","why","widely","wife","will","willing","wish","with","within","without","women","wont","words","work","works","world","would","wouldnt","wrap","wtf","www","x","y","ya","yeah","yep","yes","yesterday","yet","you","you'll","you've","youd","your","youre","yours","yourself","yourselves","youth","z","zero","things","testing","nice","working","messages","issues","issue","refresh","users","upload","download","view","free","kool","uh","duh","join","joining","original","alright","large","entire","start","month","sense","fill"]
21+
for word in word_string:
22+
tt = word.lower()
23+
t=re.sub(r'[^\w]', ' ', tt)
24+
for word in t.split():
25+
if word not in ignore_words:
26+
words.append(word)
27+
28+
p = pd.Series(words)
29+
#get the counts per word
30+
freq = p.value_counts()
31+
#how many max words do we want to give back
32+
freq = freq.ix[0:25]
33+
print freq
34+
if __name__ == '__main__':
35+
word_count("/MyDairy")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Python Workbook, a small daily program
2+
3+
Explanation:
4+
5+
Python Workbook, a small daily program. Note: Python into other languages, most of the topics also apply
6+
Do not appear, such as "print multiplication table", "Print Narcissus" like topic
7+
In this paper, the history of this paper by the @ Jiang Song ( shijiangge@gmail.com QQ: 499 065 469) according to organize data collection from the Internet, thanks to the Internet, thanks for sharing. Thanks! This article will be updated continuously.
8+
Welcome to the Pull Request a problem, paste the code (Gist, Blog can be) :-)
9+
Welcome to answer, and send pull request to the Show-Me-the-Code
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
To change the file object’s position, use f.seek(offset, from_what). The position is computed from adding offset to a reference point; the reference point is selected by the from_what argument.
2+
A from_what value of 0 measures from the beginning of the file, 1 uses the current file position, and 2 uses the end of the file as the reference point. from_what can be omitted and defaults to 0, using the beginning of the file as the reference point.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In text files (those opened without a b in the mode string), only seeks relative to the beginning of the file are allowed (the exception being seeking to the very file end with seek(0, 2)) and the only valid offset values are those returned from the f.tell(), or zero. Any other offset value produces undefined behaviour.

0 commit comments

Comments
 (0)