This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fr1 = open('check', "r") | |
| fr2=open('test',"r") | |
| _kfile=[] | |
| for a in fr1: | |
| _kfile.append(a) | |
| for b in fr2: | |
| _kfile.append(b) | |
| fo = open('main', "w") | |
| fo.write(str(_kfile)) | |
| fo.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Simple Python module to upload files to Google Drive | |
| # Needs a file 'client_secrets.json' in the directory | |
| # The file can be obtained from https://console.developers.google.com/ | |
| # under APIs&Auth/Credentials/Create Client ID for native application | |
| # To test usage: | |
| # import google_drive_util | |
| # google_drive_util.login() | |
| # google_drive_util.test() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #http://docs.python.org/2.7/library/csv.html | |
| import csv, codecs, cStringIO | |
| class UTF8Recoder: | |
| """ | |
| Iterator that reads an encoded stream and reencodes the input to UTF-8 | |
| """ | |
| def __init__(self, f, encoding): | |
| self.reader = codecs.getreader(encoding)(f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2.cv as cv | |
| import tesseract | |
| gray = cv.LoadImage('captcha.jpeg', cv.CV_LOAD_IMAGE_GRAYSCALE) | |
| cv.Threshold(gray, gray, 231, 255, cv.CV_THRESH_BINARY) | |
| api = tesseract.TessBaseAPI() | |
| api.Init(".","eng",tesseract.OEM_DEFAULT) | |
| api.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz") | |
| api.SetPageSegMode(tesseract.PSM_SINGLE_WORD) | |
| tesseract.SetCvImage(gray,api) | |
| print api.GetUTF8Text() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def convertCSVtoJSON(input): #pass the name of the input csv file | |
| f = open(input, 'r') | |
| j = open('.tempJSON', 'w') | |
| fieldnames = ("field1,field2,field3") | |
| reader = csv.DictReader(f, fieldnames) | |
| for row in reader: | |
| json.dump(row, j) | |
| j.write('\n') | |
| f.close() | |
| j.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Working with AsyncTasks on Android | |
| from category Android | |
| Introduction | |
| Developing Android applications is a lot of fun because it offers a lot of possibilities to implement one's own ideas. Frequently i have to use AsyncTasks to do heavy work aside the ui thread. In the following i give a quick overview on AsyncTasks and provide some code snippets that might be useful for everyday development with Android regarding the use of AsyncTasks. | |
| Lifecycle | |
| An AsyncTask in Android is used to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers (more information). The structure follows call onPreExecute() for preparation, doInBackground() for doing the main task and return its result finally to the onPostExecute() method. Optional you can implement the onProgressUpdate() method e.g. to show a progressbar. | |
| The following example can be used as template for an AsyncTask. | |
| private class MyTask extends AsyncTask<Object, Void, Object> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright (c) 2010 Tobias Schneider | |
| * This script is freely distributable under the terms of the MIT license. | |
| */ | |
| (function(){ | |
| var UPC_SET = { | |
| "3211": '0', | |
| "2221": '1', | |
| "2122": '2', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # USAGE | |
| # python detect_color.py --[image] ; example "python detect_color.py --123.png" | |
| # import the necessary packages | |
| import numpy as np | |
| import argparse | |
| import cv2 | |
| # construct the argument parse and parse the arguments | |
| ap = argparse.ArgumentParser() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| import sys | |
| # Get user supplied values | |
| imagePath = sys.argv[1] | |
| cascPath = "haarcascade_frontalface_default.xml" | |
| # Create the haar cascade | |
| faceCascade = cv2.CascadeClassifier(cascPath) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //var csv is the CSV file with headers | |
| function csvJSON(csv){ | |
| var lines=csv.split("\n"); | |
| var result = []; | |
| var headers=lines[0].split(","); | |
| for(var i=1;i<lines.length;i++){ |
NewerOlder