Search Results

Search found 2136 results on 86 pages for 'dominik str'.

Page 24/86 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Optimizing BeautifulSoup (Python) code

    - by user283405
    I have code that uses the BeautifulSoup library for parsing, but it is very slow. The code is written in such a way that threads cannot be used. Can anyone help me with this? I am using BeautifulSoup for parsing and than save into a DB. If I comment out the save statement, it still takes a long time, so there is no problem with the database. def parse(self,text): soup = BeautifulSoup(text) arr = soup.findAll('tbody') for i in range(0,len(arr)-1): data=Data() soup2 = BeautifulSoup(str(arr[i])) arr2 = soup2.findAll('td') c=0 for j in arr2: if str(j).find("<a href=") > 0: data.sourceURL = self.getAttributeValue(str(j),'<a href="') else: if c == 2: data.Hits=j.renderContents() #and few others... c = c+1 data.save() Any suggestions? Note: I already ask this question here but that was closed due to incomplete information.

    Read the article

  • Version control for subtitle creation

    - by user3635
    We make subtitles for a TV series and I plan to use a VCS for it. The structure of project directory is like this: series/ episode1/nameofepisode1.str episode2/nameofepisode2.str episode3/nameofepisode3.str ... Question: When I finish subtitle of an episode, I want to assign release tag for this episode (episode1_v1). I wanted to use git for this, but in git tag is assigned only to the whole repository. What to do, so that I can view every episode progress separately? Maybe there are some more suitable VCS for this?

    Read the article

  • optimize python code

    - by user283405
    i have code that uses BeautifulSoup library for parsing. But it is very slow. The code is written in such a way that threads cannot be used. Can anyone help me about this? I am using beautifulsoup library for parsing and than save in DB. if i comment the save statement, than still it takes time so there is no problem with database. def parse(self,text): soup = BeautifulSoup(text) arr = soup.findAll('tbody') for i in range(0,len(arr)-1): data=Data() soup2 = BeautifulSoup(str(arr[i])) arr2 = soup2.findAll('td') c=0 for j in arr2: if str(j).find("<a href=") > 0: data.sourceURL = self.getAttributeValue(str(j),'<a href="') else: if c == 2: data.Hits=j.renderContents() #and few others... #... c = c+1 data.save() Any suggestions? Note: I already ask this question here but that was closed due to incomplete information.

    Read the article

  • Building 16 bit os - character array not working

    - by brainbarshan
    Hi. I am building a 16 bit operating system. But character array does not seem to work. Here is my example kernel code: asm(".code16gcc\n"); void putchar(char); int main() { char *str = "hello"; putchar('A'); if(str[0]== 'h') putchar('h'); return 0; } void putchar(char val) { asm("movb %0, %%al\n" "movb $0x0E, %%ah\n" "int $0x10\n" : :"m"(val) ) ; } It prints: A that means putchar function is working properly but if(str[0]== 'h') putchar('h'); is not working. I am compiling it by: gcc -fno-toplevel-reorder -nostdinc -fno-builtin -I./include -c -o ./bin/kernel.o ./source/kernel.c ld -Ttext=0x9000 -o ./bin/kernel.bin ./bin/kernel.o -e 0x0 What should I do?

    Read the article

  • A btter way to represent Same value given multiple values(C#3.0)

    - by Newbie
    I have a situation for which I am looking for a more elegant solution. Consider the below cases "BKP","bkp","book-to-price" (will represent) BOOK-TO-PRICE "aop","aspect oriented program" (will represent) ASPECT-ORIENTED-PROGRAM i.e. if the user enter BKP or bkp or book-to-price , the program should treat that as BOOK-TO-PRICE. The same holds good for the second example(ASPECT-ORIENTED-PROGRAM). I have the below solution: Solution: if (str == "BKP" || str == "bkp" || str == "book-to-price" ) return "BOOK-TO-PRICE". But I think that there can be many other better solutions . Could you people please give some suggestion.(with an example will be better) I am using C#3.0 and dotnet framework 3.5

    Read the article

  • What did I do wrong with this function?

    - by Felipe Galdino Campos
    I don't know what I did - it's wrong . Can someone help me? def insert_sequence(dna1, dna2, number): '''(str, str, int) -> str Return the DNA sequence obtained by inserting the second DNA sequence at the given index. (You can assume that the index is valid.) >>> insert_sequence('CCGG', 'AT', 2) 'CCATGG' >>> insert_sequence('TTGC', 'GG', 2) 'TTGGGC' ''' index = 0 result = ''; for string in dna1: if index == number: result = result + dna2 result = result + string index += 1 print(result)

    Read the article

  • mysql_real_escape_string and search data in mySql DB

    - by ryrysz
    I have problem with php function : mysql_real_escape_string My test string: @,&!#$%^*()_+' "\/ I add this data to mySql database, like that (in short): $str = mysql_real_escape_string($str); $sql = "INSERT INTO table(company) VALUES('".$str. "')"; In DB is stored as: @,&!#$%^*()_+\' \"\\/ But problem is with find this data by SELECT statement. I want find, company where name is like ' " My SELECT's: SELECT company FROM table WHERE company LIKE '%\' "%'; SELECT company FROM table WHERE company LIKE '%\\' \\"%'; ; not working. This works: SELECT `company` FROM `table` WHERE `company` LIKE '%\\\' \\\\"%'; and SELECT `company` FROM `table` WHERE `company` LIKE '%\\\\\\\' \\\\\\\"%' But I dont know why this work :(. My questions are: why must add so many slashes ? how I can make correct query in PHP: $query = '\' "'; '%'.mysql_real_escape_string($query).'%' result is : '%\' \"%' '%'.mysql_real_escape_string(mysql_real_escape_string($query)).'%' result is : '%\\\' \\\"%' '%'.mysql_real_escape_string(mysql_real_escape_string(mysql_real_escape_string($query))).'%' result is : '%\\\\\\\' \\\\\\\"%' Only last one works good.

    Read the article

  • JButton and next/previous object of treemap

    - by supacat
    I have this problem: 1) There are objects placed in the TreeMap through the JTextField. (Phonebook-like program). 2)There are buttons that implement view of available records in TreeMap. When you click on these buttons next / previous available objects of TreeMap displaying in JTextField. (scroll through the available records). I tried this code, but I didn't work :/ btn[4].addActionListener(new ActionListener(){ Iterator iter = tree.keySet().iterator(); public void actionPerformed(ActionEvent e) { if (iter.hasNext()){ String str = iter.next().toString(); fldFio.setText(str); fldNumber.setText(tree.get(str)); } } });

    Read the article

  • Python breaks for a certain amount

    - by Brian Cox
    All, I am not very good at explaining so i will let my comments do it! #this script is to calculate some of the times table up to 24X24 and also miss some out #Range of numbers to be calculated numbers=range(1,25) for i in numbers: for w in numbers: print(str(i)+"X"+str(w)+"="+str(i*w)) #here i want to break randomly (skip some out) e.g. i could be doing the 12X1,12X2 and then 12X5 i have no limit of skips. Update Sorry if this is not clear i want it to break from the inner loop for a random amount of times

    Read the article

  • how to convert webpage apostrophe (&#8217;) to ascii 39 in ruby 1.8.7

    - by maninwarren
    That's pretty much it. I'm using Nokogiri to scrape a web page what has ’ ; characters in it, and I can't figure out how to do the conversion. here's what I tried: str.gsub(/&#8217;/,"'") str.gsub("&#8217;","'") str.gsub("GÇÖ","'") # that's how it looks when I do a puts (In the above, there's no space between the ’ and the ";", but if I don't put the space in, SO converts it to an apostrophe -- the cruel, cruel irony!) I'm sure this is covered somewhere, but couldn't find the solution here or on the web. TIA

    Read the article

  • python processs complete list files matched

    - by thomytheyon
    Hi All, I'm trying to get a simple code working, unfortunatly im a python beginner. My script should return a list of files that doesn't match a pattern, more information here : http://stackoverflow.com/questions/2910106/python-grep-reverse-matching/2910288#2910288 My code is running but doesn't process the complete list of files found as it should : import sys,os filefilter = ['.xml','java','.jsp','lass'] path= "/home/patate/code/project" s = "helloworld" for path, subdirs, files in os.walk(path): for name in files: if name[-4:] in filefilter : f = str(os.path.join(path, name)) with open(f) as fp: if s in fp.read(): print "%s has the string" % f else: print "%s doesn't have the string" % f This code return : /home/patate/code/project/blabla/blabla/build.xml doesn't have the string None If i change f = str(os.path.join(path, name)) for print str(os.path.join(path, name)) I can see the whole list being printed. How can i process the whole list as i which to ? :( Thanks again.

    Read the article

  • How to deserialize JSON text into a date type using Windows 8 JSON.parse?

    - by canderso
    I'm building a Windows 8 Metro app (aka "Modern UI Style" or "Windows Store app") in HTML5/JavaScript consuming JSON Web Services and I'm bumping into the following issue: in which format should my JSON Web Services serialize dates for the Windows 8 Metro JSON.parse method to deserialize those in a date type? I tried: sending dates using the ISO-8601 format, (JSON.parse returns a string), sending dates such as "/Date(1198908717056)/" as explained here (same result). I'm starting to doubt that Windows 8's JSON.parse method supports dates as even when parsing the output of its own JSON.stringify method does not return a date type. Example: var d = new Date(); // => a new date var str = JSON.stringify(d); // str is a string => "\"2012-07-10T14:44:00.000Z\"" var date2 = JSON.parse(str); // date2 is a string => "2012-07-10T14:44:00.000Z"

    Read the article

  • Killing a script launched in a Process via os.system()

    - by L.J.
    I have a python script which launches several processes. Each process basically just calls a shell script: from multiprocessing import Process import os import logging def thread_method(n = 4): global logger command = "~/Scripts/run.sh " + str(n) + " >> /var/log/mylog.log" if (debug): logger.debug(command) os.system(command) I launch several of these threads, which are meant to run in the background. I want to have a timeout on these threads, such that if it exceeds the timeout, they are killed: t = [] for x in range(10): try: t.append(Process(target=thread_method, args=(x,) ) ) t[-1].start() except Exception as e: logger.error("Error: unable to start thread") logger.error("Error message: " + str(e)) logger.info("Waiting up to 60 seconds to allow threads to finish") t[0].join(60) for n in range(len(t)): if t[n].is_alive(): logger.info(str(n) + " is still alive after 60 seconds, forcibly terminating") t[n].terminate() The problem is that calling terminate() on the process threads isn't killing the launched run.sh script - it continues running in the background until I either force kill it from the command line, or it finishes internally. Is there a way to have terminate also kill the subshell created by os.system()?

    Read the article

  • Why this function overloading is not working?

    - by Jack
    class CConfFile { public: CConfFile(const std::string &FileName); ~CConfFile(); ... std::string GetString(const std::string &Section, const std::string &Key); void GetString(const std::string &Section, const std::string &Key, char *Buffer, unsigned int BufferSize); ... } string CConfFile::GetString(const string &Section, const string &Key) { return GetKeyValue(Section, Key); } void GetString(const string &Section, const string &Key, char *Buffer, unsigned int BufferSize) { string Str = GetString(Section, Key); // *** ERROR *** strncpy(Buffer, Str.c_str(), Str.size()); } Why do I get an error too few arguments to function ‘void GetString(const std::string&, const std::string&, char*, unsigned int)' at the second function ? Thanks

    Read the article

  • Error when call 'qb.query(db, projection, selection, selectionArgs, null, null, orderBy);'

    - by smalltalk1960s
    Hi all, I make a content provider named 'DictionaryProvider' (Based on NotepadProvider). When my program run to command 'qb.query(db, projection, selection, selectionArgs, null, null, orderBy);', error happen. I don't know how to fix. please help me. Below is my code // file main calling DictionnaryProvider @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dictionary); final String[] PROJECTION = new String[] { DicColumns._ID, // 0 DicColumns.KEY_WORD, // 1 DicColumns.KEY_DEFINITION // 2 }; Cursor c = managedQuery(DicColumns.CONTENT_URI, PROJECTION, null, null, DicColumns.DEFAULT_SORT_ORDER); String str = ""; if (c.moveToFirst()) { int wordColumn = c.getColumnIndex("KEY_WORD"); int defColumn = c.getColumnIndex("KEY_DEFINITION"); do { // Get the field values str = ""; str += c.getString(wordColumn); str +="\n"; str +=c.getString(defColumn); } while (c.moveToNext()); } Toast.makeText(this, str, Toast.LENGTH_SHORT).show(); } // file DictionaryProvider.java package com.example.helloandroid; import java.util.HashMap; import android.content.ContentProvider; import android.content.ContentValues; import android.content.UriMatcher; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import android.text.TextUtils; import com.example.helloandroid.Dictionary.DicColumns; public class DictionaryProvider extends ContentProvider { //private static final String TAG = "DictionaryProvider"; private DictionaryOpenHelper dbdic; static final int DATABASE_VERSION = 1; static final String DICTIONARY_DATABASE_NAME = "dictionarydb"; static final String DICTIONARY_TABLE_NAME = "dictionary"; private static final UriMatcher sUriMatcher; private static HashMap<String, String> sDicProjectionMap; @Override public int delete(Uri arg0, String arg1, String[] arg2) { // TODO Auto-generated method stub return 0; } @Override public String getType(Uri arg0) { // TODO Auto-generated method stub return null; } @Override public Uri insert(Uri arg0, ContentValues arg1) { // TODO Auto-generated method stub return null; } @Override public boolean onCreate() { // TODO Auto-generated method stub dbdic = new DictionaryOpenHelper(getContext(), DICTIONARY_DATABASE_NAME, null, DATABASE_VERSION); return true; } @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); qb.setTables(DICTIONARY_TABLE_NAME); switch (sUriMatcher.match(uri)) { case 1: qb.setProjectionMap(sDicProjectionMap); break; case 2: qb.setProjectionMap(sDicProjectionMap); qb.appendWhere(DicColumns._ID + "=" + uri.getPathSegments().get(1)); break; default: throw new IllegalArgumentException("Unknown URI " + uri); } // If no sort order is specified use the default String orderBy; if (TextUtils.isEmpty(sortOrder)) { orderBy = DicColumns.DEFAULT_SORT_ORDER; } else { orderBy = sortOrder; } // Get the database and run the query SQLiteDatabase db = dbdic.getReadableDatabase(); Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy); // Tell the cursor what uri to watch, so it knows when its source data changes c.setNotificationUri(getContext().getContentResolver(), uri); return c; } @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { // TODO Auto-generated method stub return 0; } static { sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); sUriMatcher.addURI(Dictionary.AUTHORITY, "dictionary", 1); sUriMatcher.addURI(Dictionary.AUTHORITY, "dictionary/#", 2); sDicProjectionMap = new HashMap<String, String>(); sDicProjectionMap.put(DicColumns._ID, DicColumns._ID); sDicProjectionMap.put(DicColumns.KEY_WORD, DicColumns.KEY_WORD); sDicProjectionMap.put(DicColumns.KEY_DEFINITION, DicColumns.KEY_DEFINITION); // Support for Live Folders. /*sLiveFolderProjectionMap = new HashMap<String, String>(); sLiveFolderProjectionMap.put(LiveFolders._ID, NoteColumns._ID + " AS " + LiveFolders._ID); sLiveFolderProjectionMap.put(LiveFolders.NAME, NoteColumns.TITLE + " AS " + LiveFolders.NAME);*/ // Add more columns here for more robust Live Folders. } } // file Dictionary.java package com.example.helloandroid; import android.net.Uri; import android.provider.BaseColumns; /** * Convenience definitions for DictionaryProvider */ public final class Dictionary { public static final String AUTHORITY = "com.example.helloandroid.provider.Dictionary"; // This class cannot be instantiated private Dictionary() {} /** * Dictionary table */ public static final class DicColumns implements BaseColumns { // This class cannot be instantiated private DicColumns() {} /** * The content:// style URL for this table */ public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/dictionary"); /** * The MIME type of {@link #CONTENT_URI} providing a directory of notes. */ //public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.note"; /** * The MIME type of a {@link #CONTENT_URI} sub-directory of a single note. */ //public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.google.note"; /** * The default sort order for this table */ public static final String DEFAULT_SORT_ORDER = "modified DESC"; /** * The key_word of the dictionary * <P>Type: TEXT</P> */ public static final String KEY_WORD = "KEY_WORD"; /** * The key_definition of word * <P>Type: TEXT</P> */ public static final String KEY_DEFINITION = "KEY_DEFINITION"; } } thanks so much

    Read the article

  • Which method of adding items to the ASP.NET Dictionary class is more efficient?

    - by ahmd0
    I'm converting a comma separated list of strings into a dictionary using C# in ASP.NET (by omitting any duplicates): string str = "1,2, 4, 2, 4, item 3,item2, item 3"; //Just a random string for the sake of this example and I was wondering which method is more efficient? 1 - Using try/catch block: Dictionary<string, string> dic = new Dictionary<string, string>(); string[] strs = str.Split(','); foreach (string s in strs) { if (!string.IsNullOrWhiteSpace(s)) { try { string s2 = s.Trim(); dic.Add(s2, s2); } catch { } } } 2 - Or using ContainsKey() method: string[] strs = str.Split(','); foreach (string s in strs) { if (!string.IsNullOrWhiteSpace(s)) { string s2 = s.Trim(); if (!dic.ContainsKey(s2)) dic.Add(s2, s2); } }

    Read the article

  • Java String replaceAll with conditions

    - by user1483570
    I am not good in regular expressions and I need help in replacing the string. String str = "Name_XYZ_"; str = "XYZ_NAME_"; So how can I replace "Name_" or "_NAME_" from above two strings with empty string? The conditions are "Name" can be in any case and it can be at index 0 or at any index but preceded by "_". So far I tried, String replacedString = str.replaceAll("(?i)Name_", ""); // This is not correct. This is not the homework. I am working on XML file that needs such kind of processing. Please help. Thank you.

    Read the article

  • Writing Strings to files in python

    - by Leif Andersen
    I'm getting the following error when trying to write a string to a file in pythion: Traceback (most recent call last): File "export_off.py", line 264, in execute save_off(self.properties.path, context) File "export_off.py", line 244, in save_off primary.write(file) File "export_off.py", line 181, in write variable.write(file) File "export_off.py", line 118, in write file.write(self.value) TypeError: must be bytes or buffer, not str I basically have a string class, which contains a string: class _off_str(object): __slots__ = 'value' def __init__(self, val=""): self.value=val def get_size(self): return SZ_SHORT def write(self,file): file.write(self.value) def __str__(self): return str(self.value) Furthermore, I'm calling that class like this: def write(self, file): for variable in self.variables: variable.write(file) I have no idea what is going on. I've seen other python programs writing strings to files, so why can't this one? Thank you very much for your help.

    Read the article

  • Error: Get JSON Data from Web API Using Jquery

    - by Kenneth
    I'm really new at this. And I'm really stuck. I have the jquery code, it will load data from Web API, but it does not display on my page. $.getJSON("/api/Order", function(data) { if (data != null) { var str = ''; $.each(data, function (item) { str = '<li>' + item.ItemName + '</li>'; }); $("#contents").append(str); } }); Can anyone explain what is going on? Thanks.

    Read the article

  • controling a float value with javascript

    - by kawtousse
    Hi, to control my input type and verify that its value is pretty a float in my form i deal with it in javascript like that: function verifierNombre () { var champ=document.getElementById("nperformed"); var str = champ.value; if(str.value==' '){champ.focus();} if (isNaN(str)) { alert("Invalid Valid! the field must be a number"); champ.focus(); return false; } return true; } but it still false because it doesn't accept really floats. so when entering a value like '11,2' the alert is declenched. I want to know how can I control float values with javascript. thanks.

    Read the article

  • how do I check if a c++ string is an int?

    - by user342231
    when I use getline, I would input a bunch of strings or numbers, but I only want the while loop to output the "word" if it is not a number. so is there any way to check if "word" is a number or not, I know I could use atoi() for c-strings but how about for strings of the string class int main () { stringstream ss (stringstream::in | stringstream::out); string word; string str; getline(cin,str); ss<<str; while(ss>>word) { //if( ) cout<<word<<endl; } }

    Read the article

  • Check if key exists in $_SESSION by building index string

    - by Kim
    I need to check if a key exists and return its value if it does. Key can be an array with subkeys or endkey with a value. $_SESSION['mainKey']['testkey'] = 'value'; var_dump(doesKeyExist('testkey')); function doesKeyExist($where) { $parts = explode('/',$where); $str = ''; for($i = 0,$len = count($parts);$i<$len;$i++) { $str .= '[\''. $parts[$i] .'\']'; } $keycheck = '$_SESSION[\'mainKey\']' . $str; if (isset(${$keycheck})) { return ${$keycheck}; } // isset($keycheck) = true, as its non-empty. actual content is not checked // isset(${$keycheck}) = false, but should be true. ${$var} forces a evaluate content // isset($_SESSION['mainKey']['testkey']) = true } What am I doing wrong ? Using PHP 5.3.3.

    Read the article

  • Referencing invalid memory locations with C++ Iterators

    - by themoondothshine
    I am a big fan of GCC, but recently I noticed a vague anomaly. Using __gnu_cxx::__normal_iterator (ie, the most common iterator type used in libstdc++, the C++ STL) it is possible to refer to an arbitrary memory location and even change its value without causing an exception! Is this expected behavior? If so, isn't a security loophole? Here's an example: #include <iostream> using namespace std; int main() { basic_string<char> str("Hello world!"); basic_string<char>::iterator iter = str.end(); iter += str.capacity() + 99999; *iter = 'x'; cout << "Value: " << *iter << endl; }

    Read the article

  • presentmodalviewcontroller not working properly in Application Delegate in iPhone

    - by sujyanarayan
    Hi, I'm using two UIViewController in Application Delegate and navigating to UIViewController using presentmodalviewcontroller. But Problem is that presentmodalviewcontroller works for first time UIViewController and when i want to navigate to second UIViewController using presentmodalviewcontroller then its showing first UIViewController. The following is the code:- -(void)removeTabBar:(NSString *)str { HelpViewController *hvc =[[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:[NSBundle mainBundle]]; VideoPlaylistViewController *vpvc =[[VideoPlaylistViewController alloc] initWithNibName:@"VideoPlaylistViewController" bundle:[NSBundle mainBundle]]; if ([str isEqualToString:@"Help"]) { [tabBarController.view removeFromSuperview]; [vpvc dismissModalViewControllerAnimated:YES]; [viewController presentModalViewController:hvc animated:YES]; [hvc release]; } if ([str isEqualToString:@"VideoPlaylist"]) { [hvc dismissModalViewControllerAnimated:YES]; [viewController presentModalViewController:vpvc animated:YES]; [vpvc release]; } } Can Somebody help me in solving the problem?

    Read the article

  • Modify input stream data on the fly

    - by Frizi
    I would like to implement a std::stream modifier/parser, that is doing data manipulation on the fly. Is it possible to create it in form of stream manipulator? For example, i want to strip all the line comments (from any // to the end of line) out of the stdin and pass it to stdout. string str; istream strippingCin = cin >> stripcomments; while(strippingCin.good()) { strippingCin >> str; cout << str; } There may be also a large file input instead of cin, so i don't want to load full stream data into memory at once. Is it possible without writing my own stream class? Maybe is there another route i should take instead?

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >