Search Results

Search found 42 results on 2 pages for 'leif'.

Page 2/2 | < Previous Page | 1 2 

  • Parameters with braces in python

    - by Leif Andersen
    If you look at the following line of python code: bpy.ops.object.particle_system_add({"object":bpy.data.objects[2]}) you see that in the parameters there is something enclosed in braces. Can anyone tell me what the braces are for (generically anyway)? I haven't really seen this type of syntax in python and I can't find any documentation on it. Any help is greatly appreciated. Thank you.

    Read the article

  • vector<vector<largeObject>> vs. vector<vector<largeObject>*> in c++

    - by Leif Andersen
    Obviously it will vary depending on the compiler you use, but I'm curious as to the performance issues when doing vector<vector<largeObject>> vs. vector<vector<largeObject>*>, especially in c++. In specific: let's say that you have the outer vector full, and you want to start inserting elements into first inner vector. How will that be stored in memory if the outer vector is just storing pointers, as apposed to storing the whole inner vector. Will the whole outer vector have to be moved to gain more space, or will the inner vector be moved (assuming that space wasn't pre-allocated), causing problems with the outer vector? Thank you

    Read the article

  • Pass in the object a java class is embedded in as a parameter.

    - by Leif Andersen
    I'm building an android application, which has a list view, and in the list view, a click listener, containing an onItemClick method. So I have something like this: public class myList extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { getListView().setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { /* Do something*/ } } } Normally, this works fine. However, many times I find myself needing too preform an application using the outer class as a context. thusfar, I've used: parent.getContext(); to do this, but I would like to know, is that a bad idea? I can't really call: super because it's not really a subclass, just an embedded one. So is there any better way, or is that considered cosure? Also, if it is the right way, what should I do if the embedded method doesn't have a parameter to get the outside class? Thank you.

    Read the article

  • File mkdirs() method not working in android/java

    - by Leif Andersen
    I've been pulling out my hair on this for a while now. The following method is supposed to download a file, and save it to the location specified on the hard drive. private static void saveImage(Context context, boolean backgroundUpdate, URL url, File file) { if (!Tools.checkNetworkState(context, backgroundUpdate)) return; // Get the image try { // Make the file file.getParentFile().mkdirs(); // Set up the connection URLConnection uCon = url.openConnection(); InputStream is = uCon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); // Download the data ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } // Write the bits to the file OutputStream os = new FileOutputStream(file); os.write(baf.toByteArray()); os.close(); } catch (Exception e) { // Any exception is probably a newtork faiilure, bail return; } } Also, if the file doesn't exist, it is supposed to make the directory for the file. (And if there is another file already in that spot, it should just not do anything). However, for some reason, the mkdirs() method never makes the directory. I've tried everything from explicit parentheses, to explicitly making the parent file class, and nothing seems to work. I'm fairly certain that the drive is writable, as it's only called after that has already been determined, also that is true after running through it while debugging. So the method fails because the parent directories aren't made. Can anyone tell me if there is anything wrong with the way I'm calling it? Also, if it helps, here is the source for the file I'm calling it in: https://github.com/LeifAndersen/NetCatch/blob/master/src/net/leifandersen/mobile/android/netcatch/services/RSSService.java Thank you

    Read the article

  • C header file won't compile with C, but will with C++.

    - by Leif Andersen
    I have the following chunk of a header file BKE_mesh.h: /* Connectivity data */ typedef struct IndexNode { struct IndexNode *next, *prev; int index; } IndexNode; void create_vert_face_map(ListBase **map, IndexNode **mem, const struct MFace *mface, const int totvert, const int totface); void create_vert_edge_map(ListBase **map, IndexNode **mem, const struct MEdge *medge, const int totvert, const int totedge); Note that the header file was prepared for the possibility of being used in a C++ file, as it had: #ifdef __cplusplus extern "C" { #endif at the top of the file, and the needed finish at the bottom. But the class implementing it was written in C. Next, whenever I try to #include the header file, I get an odd error. If the file has a .cpp extension, it compiles just fine, no complaints whatsoever. However, if I do: #include "BKE_mesh.h" inside of a file with a .c extension, I get the following errors: expected ')' before '*' token for the two last functions, in specific, the variable: ListBase **map in both classes. (Note that earlier in the header file, it declared, but not defined ListBase). So, my question is: why is this valid C++ code, but not C code? Thank you.

    Read the article

  • How do I test switching compilers from MSVS 6 to MSVS 2008?

    - by Leif
    When switching from MSVS 6 to MSVS 2008, what major differences should I look for when testing the software? I'm coming from more of a QA perspective. We have two programs that work closely together that were originally compiled in Visual C++ 6. Now one of the programs has been compiled in Visual C++ 2008 in order to use a specific CD writing routine. The other program is still compiled under MSVS 6. My manager is very concerned with this change and wants me to run tests specific to this change. Since I deal more with QA and less with development, I really have no idea where to start. I've looked for differences between the two, but nothing has given me a clear direction as far as testing is concerned. Any suggestions would be helpful.

    Read the article

  • Intent filter for browsing XML (specifically rss) in android

    - by Leif Andersen
    I have an activity that I want to run every time the user goes to an xml (specifically rss) page in the browser (at least assuming the user get's it from the list of apps that can support it). I currently already have the current intent filter: <activity android:name=".activities.EpisodesListActivity" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <category android:name="android.intent.category.BROWSABLE"></category> <category android:name="android.intent.category.DEFAULT"></category> <action android:name="android.intent.action.VIEW"></action> <data android:scheme="http"></data> </intent-filter> </activity> Now as you can guess, this is an evil intent, as it wants to open whenever a page is requested via http. However, when I ad the line: <data android:mimeType="application/rss+xml"></data> to make it: <activity android:name=".activities.EpisodesListActivity" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <category android:name="android.intent.category.BROWSABLE"></category> <category android:name="android.intent.category.DEFAULT"></category> <action android:name="android.intent.action.VIEW"></action> <data android:scheme="http"></data> <data android:mimeType="application/rss+xml"></data> </intent-filter> </activity> The application no longer claims to be able to run rss files. Also, if I change the line to: <data android:mimeType="application/xml"></data> It also won't work (for generic xml file even). So what intent filter do I need to make in order to claim that the activity supports rss. (Also, bonus points if you can tell me how I know what URL it was the user opened. So far, I've always sent that information from one activity to the other using extras). Thank you for your help

    Read the article

  • Style question about existing piece of code (C/C++)

    - by Leif Ericson
    I just hope the following doesn't seem to you like redundant jabber :) Anyway, there is that: for (p = fmt; *p; p++) { if (*p != '%') { putchar(*p); continue; } switch (*++p) { /* Some cases here */ ... } } And I wondered why the writer (Kernighan / Ritchie) used the continue in the if statement. I thought it was for the mere reason that he deemed it would be more elegant than indenting the whole switch under an else statement, what do you think?

    Read the article

  • Use the keyword class as a variable name in C++

    - by Leif Andersen
    I am having trouble writing C++ code that uses a header file designed for a C file. In particular, the header file used a variable name called class: int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_class, BPY_class_attr_check* class_attrs, PyObject **py_class_attrs); This works in C as class isn't taken as a keyword, but in C++, class is. So is there anyway I can #include this header file into a c++ file, or am I out of luck? Thank you.

    Read the article

  • Preprocessor directive #ifndef for C/C++ code

    - by Leif Andersen
    In eclipse, whenever I create a new C++ class, or C header file, I get the following type of structure. Say I create header file example.h, I get this: /*Comments*/ #ifndef EXAMPLE_H_ #define EXAMPLE_H_ /* Place to put all of my definitions etc. */ #endif I think ifndef is saying that if EXAMPLE_H_ isn't defined, define it, which may be useful depending on what tool you are using to compile and link your project. However, I have two questions: Is this fairly common? I don't see it too often. And is it a good idea to use that rubric, or should you just jump right into defining your code. What is EXAMPLE_H_ exactly? Why not example.h, or just example? Is there anything special about that, or could is just be an artifact of how eclipse prefers to autobuild projects? Thank you for your help.

    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

  • : for displaying all elements in a multidimensional array in python 3.1.

    - by Leif Andersen
    I have a multidimensional array in python like: arr = [['foo', 1], ['bar',2]] Now, if I want to print out everything in the array, I could do: print(arr[:][:]) Or I could also just do print(arr). However, If I only wanted to print out the first element of each box (for arr, that would be 'foo', 'bar'), I would imagine I would do something like: print(arr[:][0]) however, that just prints out the first data blog (['foo', 1]), also, I tried reversing it (just in case): print(arr[0][:]) and I got the same thing. So, is there anyway that I can get it to print the first element in each tuple (other than: for tuple in arr: print(tuple[0]) )? Thanks.

    Read the article

  • Asterisk doesn't start properly at system startup. DNS lookup fails.

    - by leiflundgren
    When I start my Ubuntu system it attempts two DNS lookups. One to find out what my internet-routers external ip is. And one to find the IP of my PSTN-SIP-provider. Both fails. [Apr 7 22:14:54] WARNING[1675] chan_sip.c: Invalid address for externhost keyword: sip.mydomain.com ... [Apr 7 22:14:54] WARNING[1675] acl.c: Unable to lookup 'sip.myprovider.com' And since the DNS fails it cannot register properly a cannot make outgoing or incoming calls. If I later, after bootup, restart asterisk everything works excelent. Any idea how I should setup things so that either: Delay Asterisk startup so that DNS is up and healthy first. Somehow get Asterisk to re-try the DNS thing later. Regards Leif

    Read the article

  • Asterisk doesn't start properly at system startup. DNS lookup fails.

    - by leiflundgren
    When I start my Ubuntu system it attempts two DNS lookups. One to find out what my internet-routers external ip is. And one to find the IP of my PSTN-SIP-provider. Both fails. [Apr 7 22:14:54] WARNING[1675] chan_sip.c: Invalid address for externhost keyword: sip.mydomain.com ... [Apr 7 22:14:54] WARNING[1675] acl.c: Unable to lookup 'sip.myprovider.com' And since the DNS fails it cannot register properly a cannot make outgoing or incoming calls. If I later, after bootup, restart asterisk everything works excelent. Any idea how I should setup things so that either: Delay Asterisk startup so that DNS is up and healthy first. Somehow get Asterisk to re-try the DNS thing later. Regards Leif

    Read the article

  • Using wix3 SqlScript to run generated temporary sql-script files.

    - by leiflundgren
    I am starting to write an installer which will use the SqlScript-element. That takes a reference to the Binary-table what script to run. I would like to dynamically generate the script during the installation. I can see three possibilities: Somehow to get SqlScript to read it data from a file rather then a Binary entry. Inject my generated script into the Binary table Using SqlString Which will cause the need to place some rather long strings into Properties, but I guess that shouldn't really be a prolem. Any advice? Regards Leif (My reason, should anyone be interested is that the database should have a job set up, that calls on an installed exe-file. I prefer to create the job using sqlscript. And the path of that file is not known until InstallDir has been choosen.)

    Read the article

  • WiX: Extracting Binary-string in Custom Action yields string like "???good data"

    - by leiflundgren
    I just found a weird behaviour when attempting to extract a string from the Binary-table in the MSI. I have a file containing "Hello world", the data I get is "???Hello world". (Literary question mark.) Is this as intended? Will it always be exactly 3 characters in the beginning? Regards Leif Sample code: [CustomAction] public static ActionResult CustomAction2(Session session) { View v = session.Database.OpenView("SELECT `Name`,`Data` FROM `Binary`"); v.Execute(); Record r = v.Fetch(); int datalen = r.GetDataSize("Data"); System.IO.Stream strm = r.GetStream("Data"); byte[] rawData = new byte[datalen]; int res = strm.Read(rawData, 0, datalen); strm.Close(); String s = System.Text.Encoding.ASCII.GetString(rawData); // s == "???Hello World" return ActionResult.Success; }

    Read the article

  • WiX: Forcefully launch uninstall previous using CustomAction

    - by leiflundgren
    I'm writing a new major upgrade of our product. In my installer I start by finding configuration settings of the previous version, then I'd like to uninstall the previous version. I have found several guides telling me how one should make a MSI suitable for such upgrades. However, the previous was not an MSI. It was not according to best practices. It does, however, in registry HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{GUID} specify an UninstallString. Using a RegistrySearch I can easy find the command below, which I store in UNINSTALL_CMD. RunDll32 C:\PROGRA~1\COMMON~1\INSTAL~1\PROFES~1\RunTime\10\01\Intel32\Ctor.dll,LaunchSetup "C:\Program Files\InstallShield Installation Information\{GUID}\setup.exe" -l0x9 -removeonly 4: I cannot get the hang of the CustomAction needed to perform the actual uninstall. <CustomAction Id="ca.UninstPrev" Property="UNINSTALL_CMD" ExeCommand="" /> The MSI logs says: Info 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: ca.UninstallPrevious, location: RunDll32 C:\PROGRA~1\COMMON~1\INSTAL~1\PROFES~1\RunTime\10\01\Intel32\Ctor.dll,LaunchSetup "C:\Program Files\InstallShield Installation Information{GUID}\setup.exe" -l0x9 -removeonly, command: Anyone seeing what I am doing wrong here? Regards Leif

    Read the article

< Previous Page | 1 2