Search Results

Search found 158 results on 7 pages for 'bruno vieira'.

Page 5/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Imagecache, Views, file renaming, and output directories

    - by Bruno
    I have been trying to figure this one out for awhile and just seem to be getting myself deeper into a rabbit hole.. I think it would be best if I would just explain what I am trying to accomplish and go from there.. Essentially what I would like to happen is a user would upload a photograph from the filefield sources on a content type, and then using views, it would output that different image through different imagecache actions.. The problem seems to be that the actual directories it is making is really cluttered and I would like it to be a little bit more organized due to some file renaming. Here is how I would like the process to happen: Upload image.jpg Imagecache resize 100x100 square and save file to same directory and name the file image-100.jpg Imagecache desaturate 100x100 square and save file to same directory and name the file image-d-100.jpg Currently it seems that every imagecache action will save that file in its own directory.. How can I specify a more customized output? Thanks, Anthony

    Read the article

  • Supporting multiple instances of a plugin DLL with global data

    - by Bruno De Fraine
    Context: I converted a legacy standalone engine into a plugin component for a composition tool. Technically, this means that I compiled the engine code base to a C DLL which I invoke from a .NET wrapper using P/Invoke; the wrapper implements an interface defined by the composition tool. This works quite well, but now I receive the request to load multiple instances of the engine, for different projects. Since the engine keeps the project data in a set of global variables, and since the DLL with the engine code base is loaded only once, loading multiple projects means that the project data is overwritten. I can see a number of solutions, but they all have some disadvantages: You can create multiple DLLs with the same code, which are seen as different DLLs by Windows, so their code is not shared. Probably this already works if you have multiple copies of the engine DLL with different names. However, the engine is invoked from the wrapper using DllImport attributes and I think the name of the engine DLL needs to be known when compiling the wrapper. Obviously, if I have to compile different versions of the wrapper for each project, this is quite cumbersome. The engine could run as a separate process. This means that the wrapper would launch a separate process for the engine when it loads a project, and it would use some form of IPC to communicate with this process. While this is a relatively clean solution, it requires some effort to get working, I don't now which IPC technology would be best to set-up this kind of construction. There may also be a significant overhead of the communication: the engine needs to frequently exchange arrays of floating-point numbers. The engine could be adapted to support multiple projects. This means that the global variables should be put into a project structure, and every reference to the globals should be converted to a corresponding reference that is relative to a particular project. There are about 20-30 global variables, but as you can imagine, these global variables are referenced from all over the code base, so this conversion would need to be done in some automatic manner. A related problem is that you should be able to reference the "current" project structure in all places, but passing this along as an extra argument in each and every function signature is also cumbersome. Does there exist a technique (in C) to consider the current call stack and find the nearest enclosing instance of a relevant data value there? Can the stackoverflow community give some advice on these (or other) solutions?

    Read the article

  • Dynamic name of NSMutableDictionary?

    - by Bruno
    Hi everyone I load from a txt file many info, and I would like, if possible, to dynamically create NSmutable dictionary with the elements of the txt. For example, each is like that: id of element | date | text What I'm asking is the equivalent of the NSString stringWithFormat:. Can we do the same for an Mutable Dictionary? To be more practical, let's say the NSString *date is equal to "23/12/2009" (for europe). I want to create a dictionary called 23/12/2009 without declaring *23/12/2009 but just something like dictionaryWithFormat: @"%@", date]; I'm stuck on this, and I don't even know if it is possible. If not, what's the best way to approach that? Thanks everyone Regards

    Read the article

  • Classical task-scheduling assignment

    - by Bruno
    I am working on a flight scheduling app (disclaimer: it's for a college project, so no code answers, please). Please read this question w/ a quantum of attention before answering as it has a lot of peculiarities :( First, some terminology issues: You have planes and flights, and you have to pair them up. For simplicity's sake, we'll assume that a plane is free as soon as the flight using it prior lands. Flights are seen as tasks: They have a duration They have dependencies They have an expected date/time for beginning Planes can be seen as resources to be used by tasks (or flights, in our terminology). Flights have a specific type of plane needed. e.g. flight 200 needs a plane of type B. Planes obviously are of one and only one specific type, e.g., Plane Airforce One is of type C. A "project" is the set of all the flights by an airline in a given time period. The functionality required is: Finding the shortest possible duration for a said project The earliest and latest possible start for a task (flight) The critical tasks, with basis on provided data, complete with identifiers of preceding tasks. Automatically pair up flights and planes, so as to get all flights paired up with a plane. (Note: the duration of flights is fixed) Get a Gantt diagram with the projects scheduling, in which all flights begin as early as possible, showing all previously referred data graphically (dependencies, time info, etc.) So the questions is: How in the world do I achieve this? Particularly: We are required to use a graph. What do the graph's edges and nodes respectively symbolise? Are we required to discard tasks to achieve the critical tasks set? If you could also recommend some algorithms for us to look up, that'd be great.

    Read the article

  • Working with Multiple Layers - KineticJS

    - by Bruno Sampaio
    I'm using KineticJS 4.0.5 and I'm currently trying to draw the contents of several layers but only the last one added to stage is drawn... If I understood the documentation correctly this should be possible, otherwise why would we need a layer? I have three different layers: a background layer with just a Kinectic.Rect object; a elements layer with several types of shapes; and a top layer with elements I want to be always on top of everything. I populate those layers inside a draw function I have inside a object I created, this object also has a shape attribute which refers to the background and a contents attribute with the elements to add to the elements layer. My code for the draw function is the following: this.draw = function() { var stage = E.game.stage, layers = E.game.layers; stage.clear(); // Add Background this.shape.setSize(stage.getWidth(), stage.getHeight()); layers.background.add(this.shape); // Iterate over contents for(var i = 0; i < this.contents.length; i++) { layers.elements.add(this.contents[i].shape); } // Draw Everything stage.add(layers.background); stage.add(layers.elements); stage.add(layers.top); // This one is currently empty stage.draw(); } After running this function, only layers.top is drawn in the canvas, and if I comment the line where it is added only layers.elements is drawn. However the stage has 3 childrens (I checked it with inspect element on chrome) and in the documentation it says the draw function draws all layers... Am I doing something wrong here? Or it isn't possible? And if it's not possible why would I need a layer and a stage? Wouldn't one be enough? Thank you in advance. Edit: I was able to solve the problem, I was applying a white background color with css to the canvas element and since each layer creates a new canvas element above the others I could only see the contents for the top most layer (in this case just white). However, I still have a problem related with multiple layers that I didn't have before with just one layer. When I use the clear function on the stage it should clear the layers right? But instead the layers remain exactly the same, even if I try to call clear on each individual layer they won't change... I'm also using the stage draw function after clearing them but still no changes at all... The only solution I found until now was by removing the layer from the stage and adding it again :s Is there a better way to reset the layers contents? Thank you again and sorry for the confusion with the first question.

    Read the article

  • jQuery - Form input return confirm to delete

    - by bruno
    hello guys. I struggled a lot before posting here :) now, I want to replace my default javascript confirmation for deleting a file. I saw a lot of examples here, but no example with form input. Now I have his form: <form action="delete.php" method="post"> <input type="hidden" name="id" value="<{$pid}>" /> <input type="hidden" name="picture" value="<{$lang_del_pic}>" /> <input type="image" src="<{xoImgUrl}>img/del-icon.gif" width="16" height="16" align="bottom" border="0" alt="Delete media" name="pictured" value="<{$lang_del_pic}>" onclick="javascript: return confirm('<{$lang_confirm_del}>');" /> </form> Now, I did everything, I have this div: <div id="dialog-confirm" title="Empty the recycle bin?"> <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p> </div> this javascript: <script type="text/javascript"> $(document).ready(function() { $("#dialog").dialog({ autoOpen: false, modal: true }); }); $(".confirmLink").click(function(e) { e.preventDefault(); var targetUrl = $(this).attr("href"); $("#dialog").dialog({ buttons : { "Confirm" : function() { window.location.href = targetUrl; }, "Cancel" : function() { $(this).dialog("close"); } } }); $("#dialog").dialog("open"); }); </script> and this new form: <form name="dialog-confirm" id="dialog-confirm" method="post"> <input type="hidden" name="id" value="<{$pid}>" /> <input type="hidden" name="picture" value="<{$lang_del_pic}>" /> <input type="image" src="<{xoImgUrl}>img/del-icon.gif" width="16" height="16" align="bottom" border="0" alt="Delete media" name="pictured" value="" id="opener" /> </form> On press, I call successfuly the jQuery modal diolog, and everything works, but somehow, when I press 'delete all' the script tells me - "the script is called without the necessary parameters" Now I guess I am failig to send the pic ID to be deleted with the jQuery, .. but do not know how to fix it. Any ideas ?

    Read the article

  • jQuery / Loading content into div and changing url's (working but buggy)

    - by Bruno
    This is working, but I'm not being able to set an index.html file on my server root where i can specify the first page to go. It also get very buggy in some situations. Basically it's a common site (menu content) but the idea is to load the content without refreshing the page, defining the div to load the content, and make each page accessible by the url. One of the biggest problems here it's dealing with all url situations that may occur. The ideal would be to have a rel="divToLoadOn" and then pass it on my loadContent() function... so I would like or ideas/solutions for this please. Thanks in advance! //if page comes from URL if(window.location.hash != ''){ var url = window.location.hash; url = '..'+url.substr(1, url.length); loadContent(url); } //if page comes from an internal link $("a:not([target])").click(function(e){ e.preventDefault(); var url = $(this).attr("href"); if(url != '#'){ loadContent($(this).attr("href")); } }); //LOAD CONTENT function loadContent(url){ var contentContainer = $("#content"); //set load animation $(contentContainer).ajaxStart(function() { $(this).html('loading...'); }); $.ajax({ url: url, dataType: "html", success: function(data){ //store data globally so it can be used on complete window.data = data; }, complete: function(){ var content = $(data).find("#content").html(); var contentTitle = $(data).find("title").text(); //change url var parsedUrl = url.substr(2,url.length) window.location.hash = parsedUrl; //change title var titleRegex = /(.*)<\/title/.exec(data); contentTitle = titleRegex[1]; document.title = contentTitle; //renew content $(contentContainer).fadeOut(function(){ $(this).html(content).fadeIn(); }); }); }

    Read the article

  • Unsigneds in order to prevent negative numbers

    - by Bruno Brant
    let's rope I can make this non-sujective Here's the thing: Sometimes, on fixed-typed languages, I restrict input on methods and functions to positive numbers by using the unsigned types, like unsigned int or unsigned double, etc. Most libraries, however, doesn't seem to think that way. Take C# string.Length. It's a integer, even though it can never be negative. Same goes for C/C++: sqrt input is an int or a double. I know there are reasons for this ... for example your argument might be read from a file and (no idea why) you may prefer to send the value directly to the function and check for errors latter (or use a try-catch block). So, I'm assuming that libraries are way better designed than my own code. So what are the reasons against using unsigned numbers to represent positive numbers? It's because of overflow when we cast then back to signed types?

    Read the article

  • Convert long number as string in the serialization

    - by Bruno
    I have a custom made class that use a long as ID. However, when I call my action using ajax, my ID is truncated and it loses the last 2 numbers because javascript loses precision when dealing with large numbers. My solution would be to give a string to my javascript, but the ID have to stay as a long on the server side. Is there a way to serialize the property as a string? I'm looking for some kind of attribute. Controller public class CustomersController : ApiController { public IEnumerable<CustomerEntity> Get() { yield return new CustomerEntity() { ID = 1306270928525862486, Name = "Test" }; } } Model public class CustomerEntity { public long ID { get; set; } public string Name { get; set; } } JSON Result [{"Name":"Test","ID":1306270928525862400}]

    Read the article

  • textbox required equal false

    - by Donato bruno comunali F. dutra
    how do I make the textbox that required equal to false in this code $(document).ready(function () { $("#<%= chkSpecialIntegration.ClientID %>").click(function () { if (this.checked) { $("#<%= ddlTypeSpecialIntegration.ClientID %>").show(); document.getElementById('<%=txtTotalScoreDebit.ClientID %>').Required = false; } else{ $("#<%= ddlTypeSpecialIntegration.ClientID %>").hide(); document.getElementById('<%=txtTotalScoreDebit.ClientID %>').Required = true; } }); });

    Read the article

  • Pointer inside a struct / thread

    - by bruno
    Hi! I have this warning "warning: assignment from incompatible pointer type " in this line: data1->transformed_block[l] = &transformed_block[l]; - void print_message_function ( void *ptr ) { dt *data; data = (dt *) ptr; printf("Dentro da thread Numero0: %ld\n", data->L_norm_NewBlock); pthread_exit(0); } typedef struct data_thread { long L_norm_NewBlock; int Bsize_X; int Bsize_Y; int *transformed_block[MAX_LEVEL]; long L_norm_OrigBlock; } dt; void function() { int *transformed_block[MAX_LEVEL]; pthread_t thread1; dt *data1; pthread_attr_t attr; pthread_attr_init(&attr); //Fills structure data1 = (dt *) malloc(sizeof(dt)); data1->transformed_block[l] = &transformed_block[l]; data1->L_norm_NewBlock=0; data1->Bsize_Y = Bsize_Y; data1->Bsize_X = Bsize_X; pthread_create(&thread1, &attr, (void *) &print_message_function, (void *) &data1); } I want to get rid of that warning, and the values i get inside the thread are wrong. For example data1-L_norm_NewBlock=0; in the thread guives me a differente value (not 0 like it should be).

    Read the article

  • Should I worry about running out of HierarchyIDs?

    - by Bruno Martinez
    When you ask for a new HierarchyID between two others, the result gets progressively longer. For example, between 2/5.6 and 2/5.7 there's only 2/5.6.1 and other 4 component paths. The HierarchyID data type is limited to 800 some bytes, so you can't repeat this forever. Then again, integer types are also limited, but it isn't a problem in practice. Should I periodically defragment my table so that height doesn't grow unbounded?

    Read the article

  • How to refer to enum constants in c# xml docs

    - by Bruno Martinez
    I want to document the default value of an enum typed field: /// <summary> /// The default value is <see cref="Orientation.Horizontal" />. /// </summary> public Orientation BoxOrientation; The compiler warns that it couldn't resolve the reference. Prefixing F: or M: silences the compiler, but E: also does, so I'm unsure what prefix is correct.

    Read the article

  • How to get the action argument of a wp-login.php request?

    - by Bruno De Barros
    I am trying to integrate my custom user system with Wordpress, and I have recently asked a question on how to redirect requests to wp-login.php to my own login/registration page, but as I was working on the pluggable functions, I realized that requests to wp-login.php can either be for login, registration, or log out. This is set in the action argument that's made in the request. What I am trying to figure out is how to get this action argument, so I can redirect the request to my custom pages. Is there any way of doing this? Thank you in advance.

    Read the article

  • Separation of business logic

    - by bruno
    When I was optimizing my architecture of our applications in our website, I came to a problem that I don't know the best solution for. Now at the moment we have a small dll based on this structure: Database <-> DAL <-> BLL the Dal uses Business Objects to pass to the BLL that will pass it to the applications that uses this dll. Only the BLL is public so any application that includes this dll, can see the bll. In the beginning, this was a good solution for our company. But when we are adding more and more applications on that Dll, the bigger the Bll is getting. Now we dont want that some applications can see Bll-logic from other applications. Now I don't know what the best solution is for that. The first thing I thought was, move and separate the bll to other dll's which i can include in my application. But then must the Dal be public, so the other dll's can get the data... and that I seems like a good solution. My other solution, is just to separate the bll in different namespaces, and just include only the namespaces you need in the applications. But in this solution, you can get directly access to other bll's if you want. So I'm asking for your opinions.

    Read the article

  • Application stops on back button in new activity

    - by Bruno Almeida
    I have this application, that have a listView, and when I click in a item on listView, it opens a new activity. That works fine! But, if I open the new activity and than press the "back button" the application "Unfortunately, has stopped". Is there something I'm doing wrong? Here is my code: First activity: public class AndroidSQLite extends Activity { private SQLiteAdapter mySQLiteAdapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView listContent = (ListView)findViewById(R.id.contentlist); mySQLiteAdapter = new SQLiteAdapter(this); mySQLiteAdapter.openToRead(); Cursor cursor = mySQLiteAdapter.queueAll(); startManagingCursor(cursor); String[] from = new String[]{SQLiteAdapter.KEY_NOME,SQLiteAdapter.KEY_ID}; int[] to = new int[]{R.id.text,R.id.id}; SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this, R.layout.row, cursor, from, to); listContent.setAdapter(cursorAdapter); listContent.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getBaseContext(), id + "", Toast.LENGTH_LONG).show(); Intent details = new Intent(getApplicationContext(),DetailsPassword.class); startActivity(details); } }); mySQLiteAdapter.close(); } } Second Activity: public class DetailsPassword extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView text = new TextView(getApplicationContext()); text.setText("Text to show"); setContentView(text); } } // ===== EDITED ===== here is the Stack Track 10-30 08:55:05.744: E/AndroidRuntime(28046): FATAL EXCEPTION: main 10-30 08:55:05.744: E/AndroidRuntime(28046): java.lang.RuntimeException: Unable to resume activity {com.example.sqliteexemple2/com.example.sqliteexemple2.AndroidSQLite}: java.lang.IllegalStateException: trying to requery an already closed cursor android.database.sqlite.SQLiteCursor@4180a370 10-30 08:55:05.744: E/AndroidRuntime(28046): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2701) 10-30 08:55:05.744: E/AndroidRuntime(28046): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2729) 10-30 08:55:05.744: E/AndroidRuntime(28046): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1250) 10-30 08:55:05.744: E/AndroidRuntime(28046): at android.os.Handler.dispatchMessage(Handler.java:99) 10-30 08:55:05.744: E/AndroidRuntime(28046): at android.os.Looper.loop(Looper.java:137) 10-30 08:55:05.744: E/AndroidRuntime(28046): at android.app.ActivityThread.main(ActivityThread.java:4931) 10-30 08:55:05.744: E/AndroidRuntime(28046): at java.lang.reflect.Method.invokeNative(Native Method) 10-30 08:55:05.744: E/AndroidRuntime(28046): at java.lang.reflect.Method.invoke(Method.java:511) 10-30 08:55:05.744: E/AndroidRuntime(28046): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 10-30 08:55:05.744: E/AndroidRuntime(28046): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558) 10-30 08:55:05.744: E/AndroidRuntime(28046): at dalvik.system.NativeStart.main(Native Method) 10-30 08:55:05.744: E/AndroidRuntime(28046): Caused by: java.lang.IllegalStateException: trying to requery an already closed cursor android.database.sqlite.SQLiteCursor@4180a370 10-30 08:55:05.744: E/AndroidRuntime(28046): at android.app.Activity.performRestart(Activity.java:5051) 10-30 08:55:05.744: E/AndroidRuntime(28046): at android.app.Activity.performResume(Activity.java:5074) 10-30 08:55:05.744: E/AndroidRuntime(28046): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2691) 10-30 08:55:05.744: E/AndroidRuntime(28046): ... 10 more

    Read the article

  • Composing adaptors in Boost::range

    - by bruno nery
    I started playing with Boost::Range in order to have a pipeline of lazy transforms in C++]1. My problem now is how to split a pipeline in smaller parts. Suppose I have: int main(){ auto map = boost::adaptors::transformed; // shorten the name auto sink = generate(1) | map([](int x){ return 2*x; }) | map([](int x){ return x+1; }) | map([](int x){ return 3*x; }); for(auto i : sink) std::cout << i << "\n"; } And I want to replace the first two maps with a magic_transform, i.e.: int main(){ auto map = boost::adaptors::transformed; // shorten the name auto sink = generate(1) | magic_transform() | map([](int x){ return 3*x; }); for(auto i : sink) std::cout << i << "\n"; } How would one write magic_transform? I looked up Boost::Range's documentation, but I can't get a good grasp of it.

    Read the article

  • Cannot .Count() on IQueryable (NHibernate)

    - by Bruno Reis
    Hello, I'm with an irritating problem. It might be something stupid, but I couldn't find out. I'm using Linq to NHibernate, and I would like to count how many items are there in a repository. Here is a very simplified definition of my repository, with the code that matters: public class Repository { private ISession session; /* ... */ public virtual IQueryable<Product> GetAll() { return session.Linq<Product>(); } } All the relevant code in the end of the question. Then, to count the items on my repository, I do something like: var total = productRepository.GetAll().Count(); The problem is that total is 0. Always. However there are items in the repository. Furthermore, I can .Get(id) any of them. My NHibernate log shows that the following query was executed: SELECT count(*) as y0_ FROM [Product] this_ WHERE not (1=1) That must be that "WHERE not (1=1)" clause the cause of this problem. What can I do to be able .Count() the items in my repository? Thanks! EDIT: Actually the repository.GetAll() code is a little bit different... and that might change something! It is actually a generic repository for Entities. Some of the entities implement also the ILogicalDeletable interface (it contains a single bool property "IsDeleted"). Just before the "return" inside the GetAll() method I check if if the Entity I'm querying implements ILogicalDeletable. public interface IRepository<TEntity, TId> where TEntity : Entity<TEntity, TId> { IQueryable<TEntity> GetAll(); ... } public abstract class Repository<TEntity, TId> : IRepository<TEntity, TId> where TEntity : Entity<TEntity, TId> { public virtual IQueryable<TEntity> GetAll() { if (typeof (ILogicalDeletable).IsAssignableFrom(typeof (TEntity))) { return session.Linq<TEntity>() .Where(x => (x as ILogicalDeletable).IsDeleted == false); } else { return session.Linq<TEntity>(); } } } public interface ILogicalDeletable { bool IsDeleted {get; set;} } public Product : Entity<Product, int>, ILogicalDeletable { ... } public IProductRepository : IRepository<Product, int> {} public ProductRepository : Repository<Product, int>, IProductRepository {} Edit 2: actually the .GetAll() is always returning an empty result-set for entities that implement the ILogicalDeletable interface (ie, it ALWAYS add a WHERE NOT (1=1) clause. I think Linq to NHibernate does not like the typecast.

    Read the article

  • Chrome back button issue for cross browser login

    - by Bruno
    I am logging in to the site using Janrain facebook login. On successful authentication from facebook i ll taken to the home page. From the home page i m navigating to other page. From that page when i click chrome browser back button, i am not taken to the home page. Instead i m taken to janrain page. Its working fine in chrome version 20. Problem in other version of chrome. Please help me in fixing this. Thanks.

    Read the article

  • How to get a nicely formatted PHP Web Service response?

    - by Bruno
    I called an API like this: $service = new Class_Service(); $parameters = new GetClasses(); $parameters->Request = new GetClassesRequest(); $parameters->Request->SourceCredentials = new SourceCredentials(); $parameters->Request->SourceCredentials->SourceName = "Name"; $parameters->Request->SourceCredentials->Password = "Pass"; $parameters->Request->SourceCredentials->SiteIDs = array( 12 ); $classes = $service->GetClasses($parameters); var_dump($classes); And received a response like this: object(GetClassesResponse)#7 (1) { ["GetClassesResult"]=> object(GetClassesResult)#8 (6 { ["Classes"]=> object(stdClass)#9 (1) { ["Class"]=> array(25) { [0]=> object(Mi_Class)#10 (21) { ["ClassScheduleID"]=> int(15) ["Visits"]=> NULL ["Clients"]=> NULL ["Location"]=> object(Location)#11 (30) { ["BusinessID"]=> NULL ["SiteID"]=> int(12) ["BusinessDescription"]=> NULL ["AdditionalImageURLs"]=> object(stdClass)#12 (0) { } ["FacilitySquareFeet"]=> NULL Does a response normally look like this? How do I go about getting the data in a formatted manner?

    Read the article

  • Abstract over X

    - by Bruno Bieth
    Sorry for this english related question but I only came across that expression in the context of IT. What does abstracting over something mean ? For example abstracting over objects or abstracting over classes. Thanks

    Read the article

  • Override `drop` for a custom sequence

    - by Bruno Reis
    In short: in Clojure, is there a way to redefine a function from the standard sequence API (which is not defined on any interface like ISeq, IndexedSeq, etc) on a custom sequence type I wrote? 1. Huge data files I have big files in the following format: A long (8 bytes) containing the number n of entries n entries, each one being composed of 3 longs (ie, 24 bytes) 2. Custom sequence I want to have a sequence on these entries. Since I cannot usually hold all the data in memory at once, and I want fast sequential access on it, I wrote a class similar to the following: (deftype DataSeq [id ^long cnt ^long i cached-seq] clojure.lang.IndexedSeq (index [_] i) (count [_] (- cnt i)) (seq [this] this) (first [_] (first cached-seq)) (more [this] (if-let [s (next this)] s '())) (next [_] (if (not= (inc i) cnt) (if (next cached-seq) (DataSeq. id cnt (inc i) (next cached-seq)) (DataSeq. id cnt (inc i) (with-open [f (open-data-file id)] ; open a memory mapped byte array on the file ; seek to the exact position to begin reading ; decide on an optimal amount of data to read ; eagerly read and return that amount of data )))))) The main idea is to read ahead a bunch of entries in a list and then consume from that list. Whenever the cache is completely consumed, if there are remaining entries, they are read from the file in a new cache list. Simple as that. To create an instance of such a sequence, I use a very simple function like: (defn ^DataSeq load-data [id] (next (DataSeq. id (count-entries id) -1 []))) ; count-entries is a trivial "open file and read a long" memoized As you can see, the format of the data allowed me to implement count in very simply and efficiently. 3. drop could be O(1) In the same spirit, I'd like to reimplement drop. The format of these data files allows me to reimplement drop in O(1) (instead of the standard O(n)), as follows: if dropping less then the remaining cached items, just drop the same amount from the cache and done; if dropping more than cnt, then just return the empty list. otherwise, just figure out the position in the data file, jump right into that position, and read data from there. My difficulty is that drop is not implemented in the same way as count, first, seq, etc. The latter functions call a similarly named static method in RT which, in turn, calls my implementation above, while the former, drop, does not check if the instance of the sequence it is being called on provides a custom implementation. Obviously, I could provide a function named anything but drop that does exactly what I want, but that would force other people (including my future self) to remember to use it instead of drop every single time, which sucks. So, the question is: is it possible to override the default behaviour of drop? 4. A workaround (I dislike) While writing this question, I've just figured out a possible workaround: make the reading even lazier. The custom sequence would just keep an index and postpone the reading operation, that would happen only when first was called. The problem is that I'd need some mutable state: the first call to first would cause some data to be read into a cache, all the subsequent calls would return data from this cache. There would be a similar logic on next: if there's a cache, just next it; otherwise, don't bother populating it -- it will be done when first is called again. This would avoid unnecessary disk reads. However, this is still less than optimal -- it is still O(n), and it could easily be O(1). Anyways, I don't like this workaround, and my question is still open. Any thoughts? Thanks.

    Read the article

  • SOA &amp; BPM Partner Community Forum XI &ndash; thanks for the great event!

    - by Jürgen Kress
    Thanks to our team in Portugal we are running a great SOA & BPM Partner Community Forum in Lisbon this week. Yes we made our way to Lisbon – thanks to Lufthansa!   Program Wednesday April 21st 2010 Time Plenary agenda 10:00 – 10:15 Welcome & Introduction Paulo Folgado, Oracle 10:15 – 11:15 SOA & Cloud Computing Alexandre Vieira, Oracle 11:15 - 12:30 SOA Reference Case Filipe Carvalho, Wide Scope 12:30 – 13:15 Lunch Break 13:30 – 14:15 BPMN 2.0 Torsten Winterberg, Opitz Consulting 14:15 – 15:00 SOA Partner Sales Campaign Jürgen Kress, Oracle 15:00 – 15:15 Closing notes Jürgen Kress, Oracle 15:15 – 16:00 Cocktail reception You want to attend a SOA Partner Community event in the future? Make sure that you do register for the SOA Partner Community www.oracle.com/goto/emea/soa Program Thursday and Friday April 22nd & 23rd 2010 9:00 BPM hands-on workshop by Clemens Utschig-Utschig 18:30 End of part 1 8:30 BPM hands-on workshop part II 15:30 End of BPM 11g workshop Dear Lufthansa Team, Special thanks for making the magic happen! We all arrived just in time in Lisbon. Here the picture from Munich airport Wednesday morning. cancelled, cancelled, cancelled – Lisbon is boarding!    

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >