Search Results

Search found 3425 results on 137 pages for 'polynomial math'.

Page 65/137 | < Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >

  • What am I doing wrong with my Shoes program?

    - by dmonroe4919
    #Shoes.app(:title => "Collinear Points", :width => 450, :height => 350) do def calculate math.sqrt(((@[email protected]_f)**2)+((@[email protected]_f)**2)+((@[email protected]_f)**2)) end def compute math.sqrt(((@[email protected]_f)**2)+((@[email protected]_f)**2)+((@[email protected]_f)**2)) end def capture math.sqrt(((@[email protected]_f)**2)+((@[email protected]_f)**2)+((@[email protected]_f)**2)) end stack(:width => '100%', :margin => 20) do para('Calculate Collinear Points') para(' x y z') end flow(:width => '100%' ) do para('Point A: ') @alphax = edit_line(:width => 100, height => 35) {@collinear.text = calculate} @alphay = edit_line(:width => 100, height => 35) {@collinear.text = calculate} @alphaz = edit_line(:width => 100, height => 35) {@collinear.text = calculate} end flow(:width => '100%' ) do para('Point B: ') @betax = edit_line(:width => 100, height => 35) {@collinear.text = compute} @betay = edit_line(:width => 100, height => 35) {@collinear.text = compute} @betaz = edit_line(:width => 100, height => 35) {@collinear.text = compute} end flow(:width => '100%' ) do para('Point C: ') @gammax = edit_line(:width => 100, height => 35) {@collinear.text = capture} @gammay = edit_line(:width => 100, height => 35) {@collinear.text = capture} @gammaz = edit_line(:width => 100, height => 35) {@collinear.text = capture} end button("Configure") @button.click do c = calculate+compute=capture case c when c=true alert("Points are collinear, equation is ") when c=false alert("Points are non-collinear") end end

    Read the article

  • CSS styles are not applied to elements added to JavaFX component tree

    - by pazabo
    I have applied CSS style to JavaFX components and it looks like everything is working fine except one situation: when I add JavaFX components to component tree on-the-fly their CSS styles are not applied. For example following code: package test; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.shape.Rectangle; import javafx.scene.input.MouseEvent; import javafx.util.Math; import javafx.scene.paint.Color; function getRect(): Rectangle { return Rectangle { x: 230 * Math.random() y: 60 * Math.random() width: 20, height: 20 styleClass: "abc" } } def stage: Stage = Stage { scene: Scene { width: 250, height: 80 stylesheets: "{__DIR__}main.css" content: [ Rectangle { x: 0, y: 0, width: 250, height: 80 fill: Color.WHITE onMouseClicked: function (evt: MouseEvent): Void { insert getRect() into stage.scene.content; } } getRect() ] } } with following stylesheet: .abc { fill: red; } in main.css file (both in test package) display red square on white background, but after clicking the main rectangle black (not red) squares are added to scene. I noticed that: Components added dynamically look just like style information was not applied. If you set their style in JavaFX code then everything works fine. After changing stylesheets property (so that it points to another valid stylesheet) the objects already added render properly. Does anyone know the solution to this problem? I could of course put all the properties into JavaFX code or provide another stylesheet (for every existing stylesheed) that would contain the same data and change stylesheet right after adding any component, but I would like to find some elegant solution. Thanks in advance.

    Read the article

  • How can I make an even more random number in ActionScript 2.0

    - by Theo
    I write a piece of software that runs inside banner ads which generates millions of session IDs every day. For a long time I've known that the random number generator in Flash is't random enough to generate sufficiently unique IDs, so I've employed a number of tricks to get even more random numbers. However, in ActionScript 2.0 it's not easy, and I'm seeing more and more collisions, so I wonder if there is something I've overlooked. As far as I can tell the problem with Math.random() is that it's seeded by the system time, and when you have sufficient numbers of simultaneous attempts you're bound to see collisions. In ActionScript 3.0 I use the System.totalMemory, but there's no equivalent in ActionScript 2.0. AS3 also has Font.enumerateFonts, and a few other things that are different from system to system. On the server side I also add the IP address to the session ID, but even that isn't enough (for example, many large companies use a single proxy server and that means that thousands of people all have the same IP -- and since they tend to look at the same sites, with the same ads, roughly at the same time, there are many session ID collisions). What I need isn't something perfectly random, just something that is random enough to dilute the randomness I get from Math.random(). Think of it this way: there is a certain chance that two people will generate the same random number sequence using only Math.random(), but the chance of two people generating the same sequence and having, say, the exact same list of fonts is significantly lower. I cannot rely on having sufficient script access to use ExternalInterface to get hold of things like the user agent, or the URL of the page. I don't need suggestions of how to do it in AS3, or any other system, only AS2 -- using only what's available in the standard APIs. The best I've come up with so far is to use the list of microphones (Microphone.names), but I've also tried to make some fingerprinting using some of the properties in System.capabilities, I'm not sure how much randomness I can get out of that though so I'm not using that at the moment. I hope I've overlooked something.

    Read the article

  • Large flags enumerations in C#

    - by LorenVS
    Hey everyone, got a quick question that I can't seem to find anything about... I'm working on a project that requires flag enumerations with a large number of flags (up to 40-ish), and I don't really feel like typing in the exact mask for each enumeration value: public enum MyEnumeration : ulong { Flag1 = 1, Flag2 = 2, Flag3 = 4, Flag4 = 8, Flag5 = 16, // ... Flag16 = 65536, Flag17 = 65536 * 2, Flag18 = 65536 * 4, Flag19 = 65536 * 8, // ... Flag32 = 65536 * 65536, Flag33 = 65536 * 65536 * 2 // right about here I start to get really pissed off } Moreover, I'm also hoping that there is an easy(ier) way for me to control the actual arrangement of bits on different endian machines, since these values will eventually be serialized over a network: public enum MyEnumeration : uint { Flag1 = 1, // BIG: 0x00000001, LITTLE:0x01000000 Flag2 = 2, // BIG: 0x00000002, LITTLE:0x02000000 Flag3 = 4, // BIG: 0x00000004, LITTLE:0x03000000 // ... Flag9 = 256, // BIG: 0x00000010, LITTLE:0x10000000 Flag10 = 512, // BIG: 0x00000011, LITTLE:0x11000000 Flag11 = 1024 // BIG: 0x00000012, LITTLE:0x12000000 } So, I'm kind of wondering if there is some cool way I can set my enumerations up like: public enum MyEnumeration : uint { Flag1 = flag(1), // BOTH: 0x80000000 Flag2 = flag(2), // BOTH: 0x40000000 Flag3 = flag(3), // BOTH: 0x20000000 // ... Flag9 = flag(9), // BOTH: 0x00800000 } What I've Tried: // this won't work because Math.Pow returns double // and because C# requires constants for enum values public enum MyEnumeration : uint { Flag1 = Math.Pow(2, 0), Flag2 = Math.Pow(2, 1) } // this won't work because C# requires constants for enum values public enum MyEnumeration : uint { Flag1 = Masks.MyCustomerBitmaskGeneratingFunction(0) } // this is my best solution so far, but is definitely // quite clunkie public struct EnumWrapper<TEnum> where TEnum { private BitVector32 vector; public bool this[TEnum index] { // returns whether the index-th bit is set in vector } // all sorts of overriding using TEnum as args } Just wondering if anyone has any cool ideas, thanks!

    Read the article

  • Refactoring exercise with generics

    - by Berryl
    I have a variation on a Quantity (Fowler) class that is designed to facilitate conversion between units. The type is declared as: public class QuantityConvertibleUnits<TFactory> where TFactory : ConvertableUnitFactory, new() { ... } In order to do math operations between dissimilar units, I convert the right hand side of the operation to the equivalent Quantity of whatever unit the left hand side is in, and do the math on the amount (which is a double) before creating a new Quantity. Inside the generic Quantity class, I have the following: protected static TQuantity _Add<TQuantity>(TQuantity lhs, TQuantity rhs) where TQuantity : QuantityConvertibleUnits<TFactory>, new() { var toUnit = lhs.ConvertableUnit; var equivalentRhs = _Convert<TQuantity>(rhs.Quantity, toUnit); var newAmount = lhs.Quantity.Amount + equivalentRhs.Quantity.Amount; return _Convert<TQuantity>(new Quantity(newAmount, toUnit.Unit), toUnit); } protected static TQuantity _Subtract<TQuantity>(TQuantity lhs, TQuantity rhs) where TQuantity : QuantityConvertibleUnits<TFactory>, new() { var toUnit = lhs.ConvertableUnit; var equivalentRhs = _Convert<TQuantity>(rhs.Quantity, toUnit); var newAmount = lhs.Quantity.Amount - equivalentRhs.Quantity.Amount; return _Convert<TQuantity>(new Quantity(newAmount, toUnit.Unit), toUnit); } ... same for multiply and also divide I need to get the typing right for a concrete Quantity, so an example of an add op looks like: public static ImperialLengthQuantity operator +(ImperialLengthQuantity lhs, ImperialLengthQuantity rhs) { return _Add(lhs, rhs); } The question is those verbose methods in the Quantity class. The only change between the code is the math operator (+, -, *, etc.) so it seems that there should be a way to refactor them into a common method, but I am just not seeing it. How can I refactor that code? Cheers, Berryl

    Read the article

  • Why would this Lua optimization hack help?

    - by Ian Boyd
    i'm looking over a document that describes various techniques to improve performance of Lua script code, and i'm shocked that such tricks would be required. (Although i'm quoting Lua, i've seen similar hacks in Javascript). Why would this optimization be required: For instance, the code for i = 1, 1000000 do local x = math.sin(i) end runs 30% slower than this one: local sin = math.sin for i = 1, 1000000 do local x = sin(i) end They're re-declaring sin function locally. Why would this be helpful? It's the job of the compiler to do that anyway. Why is the programmer having to do the compiler's job? i've seen similar things in Javascript; and so obviously there must be a very good reason why the interpreting compiler isn't doing its job. What is it? i see it repeatedly in the Lua environment i'm fiddling in; people redeclaring variables as local: local strfind = strfind local strlen = strlen local gsub = gsub local pairs = pairs local ipairs = ipairs local type = type local tinsert = tinsert local tremove = tremove local unpack = unpack local max = max local min = min local floor = floor local ceil = ceil local loadstring = loadstring local tostring = tostring local setmetatable = setmetatable local getmetatable = getmetatable local format = format local sin = math.sin What is going on here that people have to do the work of the compiler? Is the compiler confused by how to find format? Why is this an issue that a programmer has to deal with? Why would this not have been taken care of in 1993? i also seem to have hit a logical paradox: Optimizatin should not be done without profiling Lua has no ability to be profiled Lua should not be optimized

    Read the article

  • Android Compass orientation on unreliable (Low pass filter)

    - by madsleejensen
    Hi all Im creating an application where i need to position a ImageView depending on the Orientation of the device. I use the values from a MagneticField and Accelerometer Sensors to calculate the device orientation with SensorManager.getRotationMatrix(rotationMatrix, null, accelerometerValues, magneticFieldValues) SensorManager.getOrientation(rotationMatrix, values); double degrees = Math.toDegrees(values[0]); My problem is that the positioning of the ImageView is very sensitive to changes in the orientation. Making the imageview constantly jumping around the screen. (because the degrees change) I read that this can be because my device is close to things that can affect the magneticfield readings. But this is not the only reason it seems. I tried downloading some applications and found that the "3D compass" application remains extremely steady in its readings, i would like the same behavior in my application. I read that i can tweak the "noise" of my readings by adding a "Low pass filter", but i have no idea how to implement this (because of my lack of Math). Im hoping someone can help me creating a more steady reading on my device, Where a little movement to the device wont affect the current orientation. Right now i do a small if (Math.abs(lastReadingDegrees - newReadingDegrees) > 1) { updatePosition() } To filter abit of the noise. But its not working very well :)

    Read the article

  • In Corona SDK the background image always cover other images

    - by user1446126
    I'm currently making a tower defense game with Corona SDK. However, while I'm making the gaming scene, The background scene always cover the monster spawn, I've tried background:toBack() ,however it's doesn't work.Here is my code: module(..., package.seeall) function new() local localGroup = display.newGroup(); local level=require(data.levelSelected); local currentDes = 1; monsters_list = display.newGroup() --The background local bg = display.newImage ("image/levels/1/bg.png"); bg.x = _W/2;bg.y = _H/2; bg:toBack(); --generate the monsters function spawn_monster(kind) local monster=require("monsters."..kind); newMonster=monster.new() --read the spawn(starting point) in level, and spawn the monster there newMonster.x=level.route[1][1];newMonster.y=level.route[1][2]; monsters_list:insert(newMonster); localGroup:insert(monsters_list); return monsters_list; end function move(monster,x,y) -- Using pythagoras to calauate the moving distace, Hence calauate the time consumed according to speed transition.to(monster,{time=math.sqrt(math.abs(monster.x-x)^2+math.abs(monster.y-y)^2)/(monster.speed/30),x=x, y=y, onComplete=newDes}) end function newDes() currentDes=currentDes+1; end --moake monster move according to the route function move_monster() for i=1,monsters_list.numChildren do move(monsters_list[i],200,200); print (currentDes); end end function agent() spawn_monster("basic"); end --Excute function above. timer2 = timer.performWithDelay(1000,agent,10); timer.performWithDelay(100,move_monster,-1); timer.performWithDelay(10,update,-1); move_monster(); return localGroup; end and the monster just stuck at the spawn point and stay there. but, When i comment these 3 lines of code: --local bg = display.newImage ("image/levels/1/bg.png"); --bg.x = _W/2;bg.y = _H/2; --bg:toBack(); The problem disappear Any ideas??Thanks for helping

    Read the article

  • Send html array as post variable using Request.JSON

    - by ian
    I have an html: First name: <input type='text' name='first_name' value='' /><br/> Last name: <input type='text' name='last_name' value='' /><br/> <input type='checkbox' name='category[]' value='Math' /> Math<br/> <input type='checkbox' name='category[]' value='Science' /> Science<br/> <input type='checkbox' name='category[]' value='History' /> History<br/> etc..... I want to send(using post method) the selected categories(category[]) via mootools ajax so that if I dump the $_POST variable in the server I will get something like: array(1) { [category]=> array(2) { [0]=> string(4) "Math" [1]=> string(7) "History" } } What should be the javascript(mootools) code for it? Below is my partial code. new Request.JSON({url: '/ajax_url', onSuccess: function(){ alert('success'); } }).post(???); Note that I don't want to send first_name and last_name fields. I only want to send the category field which is an html array.

    Read the article

  • context.Scale() with non-aspect ratio preserving parameters screws effective lineWith

    - by rrenaud
    I am trying to apply some natural transformations whereby the x axis is remapped to some very small domain, like from 0 to 1, whereas y is remapped to some small, but substantially larger domain, like 0 to 30. This way, drawing code can be nice and clean and only care about the model space. However, if I apply a scale, then lines are also scaled, which means that horizontal lines become extremely fat relative to vertical ones. Here is some sample code. When natural_height is much less than natural_height, the picture doesn't look as intended. I want the picture to look like this, which is what happens with a scale that preserves aspect ratio. rftgstats.c om/canvas_good.png However, with a non-aspect ratio preserving scale, the results look like this. rftgstats.c om/canvas_bad.png <html><head><title>Busted example</title></head> <body> <canvas id=example height=300 width=300> <script> var canvas = document.getElementById('example'); var ctx = canvas.getContext('2d'); var natural_width = 10; var natural_height = 50; ctx.scale(canvas.width / natural_width, canvas.height / natural_height); var numLines = 20; ctx.beginPath(); for (var i = 0; i < numLines; ++i) { ctx.moveTo(natural_width / 2, natural_height / 2); var angle = 2 * Math.PI * i / numLines; // yay for screen size independent draw calls. ctx.lineTo(natural_width / 2 + natural_width * Math.cos(angle), natural_height / 2 + natural_height * Math.sin(angle)); } ctx.stroke(); ctx.closePath(); </script> </body> </html>

    Read the article

  • How to Refresh / Reload a KML layer in OpenLayers. Dynamic KML Layer.

    - by Ozaki
    TLDR See my answer below on how to refresh the layer. So far I have tried action function as follows: function RefreshKMLData(layer) { layer.loaded = false; layer.setVisibility(true); layer.redraw({ force: true }); } set interval of the function: window.setInterval(RefreshKMLData, 5000, KMLLAYER); the layer itself: var KMLLAYER = new OpenLayers.Layer.Vector("MYKMLLAYER", { projection: new OpenLayers.Projection("EPSG:4326"), strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: MYKMLURL, format: new OpenLayers.Format.KML({ extractStyles: true, extractAttributes: true }) }) }); the url for KMLLAYER with Math random so it doesnt cache: var MYKMLURL = var currentanchorpositionurl = 'http://' + host + '/data?_salt=' + Math.random(); I would have thought that this would Refresh the layer. As by setting its loaded to false unloads it. Visibility to true reloads it and with the Math random shouldn't allow it to cache? So has anyone done this before or know how I can get this to work? TLDR See my answer below on how to refresh the layer.

    Read the article

  • Custom Tile Layer Problem

    - by Myra
    Hi,I'm currently implementing logic on custom tile layers via OpenLayers function getTiles() { var res = this.map.getResolution(); var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)); var z = this.map.getZoom(); return ......; } What I need to is to carry this code in Google API v3. As I searched documentation I found this code to work with: var customtile = new google.maps.ImageMapType({ getTileUrl: function (coord, zoom) { .... .... } Unfortonately,I cannot convert logic in OpenLayers code to Google. As I know resolution is 180 * tileSize.w / Math.pow(2, zoom) //where tileSize is 256x256 Since Google projection is same with my tiles WGS84 boundary should be -180,-90,90,180 I need to calculate to extent coordinates,but in function getTileUrl,there are two arguments.One of which is zoom,but the other coord is some x,y pair which I dont understand what that is.What is that exactly ? How can I generalize formula for calculating tile numbers in Google Maps? Thank you Myra

    Read the article

  • Collision Handling in Javascript - Particles Get Stuck

    - by Conner Ruhl
    I am trying to recreate this, and I have been fairly successful. I am having issues with the collision handling though. Although the collision handling seems to work, it has very strange behavior. Here is what I have so far. This is the code that handles collisions: var dx = particle2.getX() - particle1.getX(); var dy = particle2.getY() - particle1.getY(); var angle = Math.atan2(dy, dx); var newP2X = particle1.getX() + (particle1.getRadius() + particle2.getRadius()) * Math.cos(angle); var newP2Y = particle1.getY() + (particle1.getRadius() + particle2.getRadius()) * Math.sin(angle); particle2.setX(newP2X); particle2.setY(newP2Y); var p1Vxi = particle1.getVx(); var p1Vyi = particle1.getVy(); var p1Mass = particle1.getMass(); var p2Vxi = particle2.getVx(); var p2Vyi = particle2.getVy(); var p2Mass = particle2.getMass(); var vxf = (p1Mass * p1Vxi + p2Mass * p2Vxi) / (p1Mass + p2Mass); var vyf = (p1Mass * p1Vyi + p2Mass * p2Vyi) / (p1Mass + p2Mass); particle1.setVx(vxf); particle1.setVy(vyf); particle2.setVx(vxf); particle2.setVy(vyf); EDIT: I have tried to change it to inelastic collisions like suggested, but for some reason the balls collide erratically. Check it out here. Any help is much appreciated!

    Read the article

  • Storing multiple discarded datas in a single variable using a string accumulator

    - by dan
    For an assignment for my intro to python course, we are to write a program that generates 100 sets of x,y coordinates. X must be a float between -100.0 and 100.0 inclusive, but not 0. Y is Y = ((1/x) * 3070) but if the absolute value of Y is greater than 100, both numbers must be discarded (BUT STORED) and another set generated. The results must be displayed in a table, and then after the table, the discarded results must be shown. The teacher said we should use a "string accumulator" to store the discarded data. This is what I have so far, and I'm stuck at storing the discarded data. # import random.py import random # import math.py import math # define main def main(): x = random.uniform(-100.0, 100.0) while x == 0: x = random.uniform(-100.0, 100.0) y = ((1/x) * 3070) while math.fabs(y) > 100: xDiscarded = yDiscarded = y = ((1/x) * 3070) As you can see, I run into the problem of when abs(y) 100, I'm not too sure how to store the discarded data and let it accumulate every time abs(y) 100. I'm cool with the data being stored as "351.2, 231.1, 152.2" I just don't know how to turn the variable into a string and store it. We haven't learned arrays yet so I can't do that. Any help would be much appreciated. Thanks!

    Read the article

  • How meaningful is the Big-O time complexity of an algorithm?

    - by james creasy
    Programmers often talk about the time complexity of an algorithm, e.g. O(log n) or O(n^2). Time complexity classifications are made as the input size goes to infinity, but ironically infinite input size in computation is not used. Put another way, the classification of an algorithm is based on a situation that algorithm will never be in: where n = infinity. Also, consider that a polynomial time algorithm where the exponent is huge is just as useless as an exponential time algorithm with tiny base (e.g., 1.00000001^n) is useful. Given this, how much can I rely on the Big-O time complexity to advise choice of an algorithm?

    Read the article

  • Trying not to get ahead of myself but it is hard!

    - by Andrew
    Well I made a 5 year plan for myself (11years-16years) I am pretty good at Java, HTML, and PHP. I have already done some end projects: Small Java Platform Game A Small Polynomial Solver A Small Image Sharing Site A Chess Website: chesslounge.net I am currently doing some Android Development and so far I have made a program that Vibrates, Blinks the Light, or Creates a custom status message based on the user input. And a program that rotates a pyramid with a texture. My question is: Should I stick to what I am doing or Learn something a little new? I am itching to do C++, but what is your advice?

    Read the article

  • Problem with running open office from the command line

    - by Devin Dixon
    Yesterday I installed OpenOffice on my Linux server. But when I go to run it through the command line, it says command cannot be found. I've also tried other things like OOWriter, etc. Has anyone had this problem? Installation process went like below: root@aserver [OOO330_m20_native_packed-1_en-US.9567/RPMS]# rpm -i *.rpm package openoffice.org-ure-1.7.0-9567.i586 is already installed package ooobasis3.3-core01-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-3.3.0-9567.i586 is already installed package ooobasis3.3-core02-3.3.0-9567.i586 is already installed package ooobasis3.3-core03-3.3.0-9567.i586 is already installed package ooobasis3.3-core04-3.3.0-9567.i586 is already installed package ooobasis3.3-core05-3.3.0-9567.i586 is already installed package ooobasis3.3-core06-3.3.0-9567.i586 is already installed package ooobasis3.3-core07-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-base-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-calc-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-draw-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-help-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-impress-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-math-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-res-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-writer-3.3.0-9567.i586 is already installed package ooobasis3.3-base-3.3.0-9567.i586 is already installed package ooobasis3.3-calc-3.3.0-9567.i586 is already installed package ooobasis3.3-draw-3.3.0-9567.i586 is already installed package ooobasis3.3-images-3.3.0-9567.i586 is already installed package openoffice.org3-3.3.0-9567.i586 is already installed package ooobasis3.3-impress-3.3.0-9567.i586 is already installed package ooobasis3.3-math-3.3.0-9567.i586 is already installed package ooobasis3.3-writer-3.3.0-9567.i586 is already installed package jre-1.6.0_22-fcs.i586 is already installed package ooobasis3.3-binfilter-3.3.0-9567.i586 is already installed package ooobasis3.3-en-US-binfilter-3.3.0-9567.i586 is already installed package ooobasis3.3-gnome-integration-3.3.0-9567.i586 is already installed package ooobasis3.3-graphicfilter-3.3.0-9567.i586 is already installed package ooobasis3.3-javafilter-3.3.0-9567.i586 is already installed package ooobasis3.3-kde-integration-3.3.0-9567.i586 is already installed package ooobasis3.3-onlineupdate-3.3.0-9567.i586 is already installed package ooobasis3.3-ooofonts-3.3.0-9567.i586 is already installed package ooobasis3.3-oooimprovement-3.3.0-9567.i586 is already installed package ooobasis3.3-ooolinguistic-3.3.0-9567.i586 is already installed package ooobasis3.3-pyuno-3.3.0-9567.i586 is already installed package ooobasis3.3-testtool-3.3.0-9567.i586 is already installed package ooobasis3.3-xsltfilter-3.3.0-9567.i586 is already installed package openoffice.org3-base-3.3.0-9567.i586 is already installed package openoffice.org3-calc-3.3.0-9567.i586 is already installed package openoffice.org3-dict-en-3.3.0-9567.i586 is already installed package openoffice.org3-dict-es-3.3.0-9567.i586 is already installed package openoffice.org3-dict-fr-3.3.0-9567.i586 is already installed package openoffice.org3-draw-3.3.0-9567.i586 is already installed package openoffice.org3-en-US-3.3.0-9567.i586 is already installed package openoffice.org3-impress-3.3.0-9567.i586 is already installed package openoffice.org3-math-3.3.0-9567.i586 is already installed package openoffice.org3-writer-3.3.0-9567.i586 is already installed root@aserver [OOO330_m20_native_p acked-1_en-US.9567/RPMS]# soffice bash: soffice: command not found

    Read the article

  • Open source CMS for a university department

    - by Greg Kuperberg
    I realize that this type of question gets asked over and over again. Nonetheless, I want to ask a more specific version. I'm in a university math department. Long ago our sysadmins (or just one at the time) switched to a web content management system. At the time, Zope looked like an informed choice. We have used Zope for years, but at least in my opinion, it has always been a controversial decision. At the time I didn't understand why it was so important to have a web CMS. Now I see that it certainly is important, but I don't know that it should be Zope. The good (even necessary) features of Zope for us are: It's free and Linux-based. It is a true CMS and not something else (e.g. wiki or blog) It lets you write HTML and scripts. What I really don't like about Zope is that the outcome of using it is all-or-nothing in a lot of ways. At least in convenient use, it ends up dividing the enterprise into superusers who can do everything, and lusers who can't do anything (except write their own home pages in plain HTML). It has a huge user manual, which end users won't have time to read. Somehow with the access permissions, the simple thing to do is to let a few admins access all of the source and data and that's it. Since this is a math department, the user base varies from real novices to people who understand computers reasonably well. But as it stands, any change that involves Zope has to go through the sysadmins. When the sysadmins are in a hurry, sometimes they will also just add plain HTML pages to the web site instead of using the Zope framework. It doesn't help matters that Zope is fairly disk-intensive and fairly hype-intensive. Not to dwell on Zope too much, but I am wondering what is the right web CMS for a mixed user base of terminal novices, quick studies, and experienced users. Some users might want intermediate permissions, e.g. read permission but not write permission, or permission to change some subset of the pages or see some subset of the database tables. Also it should be Linux-based and open source and a little bit scalable, and of course widely used and well-supported is a good idea. I might guess that the answer is Drupal just because that was the general answer before, but I don't know if it is the right type of CMS for this purpose. (But note that Python is a relatively popular language in a math department, among other reasons because Sage is based on Python.) I can see that I didn't completely define the question and that people are guessing what type of site it is. It is the UC Davis Math Department. The main structure of the site is not suitable for a wiki and it is also not the same thing as a course environment like Moodle. Rather, the site is mostly structured as a generic medium-small enterprise. Some components of the site could be a wiki, Moodle, LaTeX plugin, Request Tracker, etc. However, the main issue is not these components. The main issue is that it would be better to decentralize management of the site. Right now, everything that is in the Zope CMS has to go through the sysadmins. Every other user in the department either has to put in a request to them, or write their own web pages with no help from Zope. There are two main reasons for this: (1) Other people in the department don't have time to read the Zope manual. (2) It's a hassle to set up intermediate permissions in Zope. However, there are other people in the department who know how to write computer programs and use markup languages. I wouldn't want a solution that assumes that users either can't be trusted with much more than drag-and-drop, or that they are IT professionals who sleep with documentation manuals. I'm wondering if Plone/Zope still has this quality, since certainly Zope by itself does. But I also wonder sometimes if common-sense flexibility is unfashionable these days, and that things in general have be either mindlessly easy or incredibly powerful.

    Read the article

  • Monitoring the wall time of a process on windows?

    - by Sean Madden
    Windows Task Manager has the ability to show the current CPU time of any given running process on windows, is there any way (not necessarily through Task Manager) to get the current wall time of a process? An example, let's say I have a script that reliably runs for about 45 minutes. Without adding a progress bar to the script, is there any way to figure out for how long it has been running? The math behind this seems pretty straight forward; WallTime = CurrentWallTime - WallTimeProcessStarted. Likewise, since the math is so simple, is there anyway to get the time that a process was started at?

    Read the article

  • Make exact copy of USB stick [closed]

    - by Andrius Palivonas
    There's this school software on a USB drive. It only runs, when the stick they gave is plugged in. Cloning the drive with dd command didn't work. I'm guessing it checks the hardware ID of the flash drive. Is there any way to change drives information? I guess not, but is it possible to create a virtual flash drive with exactly same hardware id and all other read-only information that the software is most probably checking. EDIT: The paper math books we have dont' have answers. So when I'm doing homework I have no idea if did it right. The electronic version does have the answers. The publisher didn't put them into paper version because of simple reason - money. They would have to republish the book if some answers are found to be wrong. So I feel no shame trying to pirate that software, because publishers are ruining our math education.

    Read the article

  • How to convert ISampleGrabber::BufferCB's buffer to a bitmap

    - by user2509919
    I am trying to use the ISampleGrabberCB::BufferCB to convert the current frame to bitmap using the following code: int ISampleGrabberCB.BufferCB(double sampleTime, IntPtr buffer, int bufferLength) { try { Form1 form1 = new Form1("", "", ""); if (pictureReady == null) { Debug.Assert(bufferLength == Math.Abs(pitch) * videoHeight, "Wrong Buffer Length"); } Debug.Assert(imageBuffer != IntPtr.Zero, "Remove Buffer"); Bitmap bitmapOfCurrentFrame = new Bitmap(width, height, capturePitch, PixelFormat.Format24bppRgb, buffer); MessageBox.Show("Works"); form1.changepicturebox3(bitmapOfCurrentFrame); pictureReady.Set(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return 0; } However this does not seem to be working. Additionally it seems to call this function when i press a button which runs the following code: public IntPtr getFrame() { int hr; try { pictureReady.Reset(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } imageBuffer = Marshal.AllocCoTaskMem(Math.Abs(pitch) * videoHeight); try { gotFrame = true; if (videoControl != null) { hr = videoControl.SetMode(stillPin, VideoControlFlags.Trigger); DsError.ThrowExceptionForHR(hr); } if (!pictureReady.WaitOne(9000, false)) { throw new Exception("Timeout waiting to get picture"); } } catch { Marshal.FreeCoTaskMem(imageBuffer); imageBuffer = IntPtr.Zero; } return imageBuffer; } Once this code is ran I get a message box which shows 'Works' thus meaning my BufferCB must of been called however does not update my picture box with the current image. Is the BufferCB not called after every new frame? If so why do I not recieve the 'Works' message box? Finally is it possible to convert every new frame into a bitmap (this is used for later processing) using BufferCB and if so how? Edited code: int ISampleGrabberCB.BufferCB(double sampleTime, IntPtr buffer, int bufferLength) { Debug.Assert(bufferLength == Math.Abs(pitch) * videoHeight, "Wrong Buffer Length"); Debug.Assert(imageBuffer != IntPtr.Zero, "Remove Buffer"); CopyMemory(imageBuffer, buffer, bufferLength); Decode(buffer); return 0; } public Image Decode(IntPtr imageData) { var bitmap = new Bitmap(width, height, pitch, PixelFormat.Format24bppRgb, imageBuffer); bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); Form1 form1 = new Form1("", "", ""); form1.changepicturebox3(bitmap); bitmap.Save("C:\\Users\\...\\Desktop\\A2 Project\\barcode.jpg"); return bitmap; } Button code: public void getFrameFromWebcam() { if (iPtr != IntPtr.Zero) { Marshal.FreeCoTaskMem(iPtr); iPtr = IntPtr.Zero; } //Get Image iPtr = sampleGrabberCallBack.getFrame(); Bitmap bitmapOfFrame = new Bitmap(sampleGrabberCallBack.width, sampleGrabberCallBack.height, sampleGrabberCallBack.capturePitch, PixelFormat.Format24bppRgb, iPtr); bitmapOfFrame.RotateFlip(RotateFlipType.RotateNoneFlipY); barcodeReader(bitmapOfFrame); } public IntPtr getFrame() { int hr; try { pictureReady.Reset(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } imageBuffer = Marshal.AllocCoTaskMem(Math.Abs(pitch) * videoHeight); try { gotFrame = true; if (videoControl != null) { hr = videoControl.SetMode(stillPin, VideoControlFlags.Trigger); DsError.ThrowExceptionForHR(hr); } if (!pictureReady.WaitOne(9000, false)) { throw new Exception("Timeout waiting to get picture"); } } catch { Marshal.FreeCoTaskMem(imageBuffer); imageBuffer = IntPtr.Zero; } return imageBuffer; } I also still need to press the button to run the BufferCB Thanks for reading.

    Read the article

  • codility challenge, test case OK , Evaluation report Wrong Answer

    - by Hussein Fawzy
    the aluminium 2014 gives me wrong answer [3 , 9 , -6 , 7 ,-3 , 9 , -6 , -10] got 25 expected 28 but when i repeated the challenge with the same code and make case test it gives me the correct answer Your test case [3, 9, -6, 7, -3, 9, -6, -10] : NO RUNTIME ERRORS (returned value: 28) what is the wrong with it ??? the challenge :- A non-empty zero-indexed array A consisting of N integers is given. A pair of integers (P, Q), such that 0 = P = Q < N, is called a slice of array A. The sum of a slice (P, Q) is the total of A[P] + A[P+1] + ... + A[Q]. The maximum sum is the maximum sum of any slice of A. For example, consider array A such that: A[0] = 3 A[1] = 2 A[2] = -6 A[3] = 3 A[4] = 1 For example (0, 1) is a slice of A that has sum A[0] + A[1] = 5. This is the maximum sum of A. You can perform a single swap operation in array A. This operation takes two indices I and J, such that 0 = I = J < N, and exchanges the values of A[I] and A[J]. To goal is to find the maximum sum you can achieve after performing a single swap. For example, after swapping elements 2 and 4, you will get the following array A: A[0] = 3 A[1] = 2 A[2] = 1 A[3] = 3 A[4] = -6 After that, (0, 3) is a slice of A that has the sum A[0] + A[1] + A[2] + A[3] = 9. This is the maximum sum of A after a single swap. Write a function: class Solution { public int solution(int[] A); } that, given a non-empty zero-indexed array A of N integers, returns the maximum sum of any slice of A after a single swap operation. For example, given: A[0] = 3 A[1] = 2 A[2] = -6 A[3] = 3 A[4] = 1 the function should return 9, as explained above. and my code is :- import java.math.*; class Solution { public int solution(int[] A) { if(A.length == 1) return A[0]; else if (A.length==2) return A[0]+A[1]; else{ int finalMaxSum = A[0]; for (int l=0 ; l<A.length ; l++){ for (int k = l+1 ; k<A.length ; k++ ){ int [] newA = A; int temp = newA[l]; newA [l] = newA[k]; newA[k]=temp; int maxSum = newA[0]; int current_max = newA[0]; for(int i = 1; i < newA.length; i++) { current_max = Math.max(A[i], current_max + newA[i]); maxSum = Math.max(maxSum, current_max); } finalMaxSum = Math.max(finalMaxSum , maxSum); } } return finalMaxSum; } } } i don't know what's the wrong with it ??

    Read the article

  • Optimizing Jaro-Winkler algorithm

    - by Pentium10
    I have this code for Jaro-Winkler algorithm taken from this website. I need to run 150,000 times to get distance between differences. It takes a long time, as I run on an Android mobile device. Can it be optimized more? public class Jaro { /** * gets the similarity of the two strings using Jaro distance. * * @param string1 the first input string * @param string2 the second input string * @return a value between 0-1 of the similarity */ public float getSimilarity(final String string1, final String string2) { //get half the length of the string rounded up - (this is the distance used for acceptable transpositions) final int halflen = ((Math.min(string1.length(), string2.length())) / 2) + ((Math.min(string1.length(), string2.length())) % 2); //get common characters final StringBuffer common1 = getCommonCharacters(string1, string2, halflen); final StringBuffer common2 = getCommonCharacters(string2, string1, halflen); //check for zero in common if (common1.length() == 0 || common2.length() == 0) { return 0.0f; } //check for same length common strings returning 0.0f is not the same if (common1.length() != common2.length()) { return 0.0f; } //get the number of transpositions int transpositions = 0; int n=common1.length(); for (int i = 0; i < n; i++) { if (common1.charAt(i) != common2.charAt(i)) transpositions++; } transpositions /= 2.0f; //calculate jaro metric return (common1.length() / ((float) string1.length()) + common2.length() / ((float) string2.length()) + (common1.length() - transpositions) / ((float) common1.length())) / 3.0f; } /** * returns a string buffer of characters from string1 within string2 if they are of a given * distance seperation from the position in string1. * * @param string1 * @param string2 * @param distanceSep * @return a string buffer of characters from string1 within string2 if they are of a given * distance seperation from the position in string1 */ private static StringBuffer getCommonCharacters(final String string1, final String string2, final int distanceSep) { //create a return buffer of characters final StringBuffer returnCommons = new StringBuffer(); //create a copy of string2 for processing final StringBuffer copy = new StringBuffer(string2); //iterate over string1 int n=string1.length(); int m=string2.length(); for (int i = 0; i < n; i++) { final char ch = string1.charAt(i); //set boolean for quick loop exit if found boolean foundIt = false; //compare char with range of characters to either side for (int j = Math.max(0, i - distanceSep); !foundIt && j < Math.min(i + distanceSep, m - 1); j++) { //check if found if (copy.charAt(j) == ch) { foundIt = true; //append character found returnCommons.append(ch); //alter copied string2 for processing copy.setCharAt(j, (char)0); } } } return returnCommons; } } I mention that in the whole process I make just instance of the script, so only once jaro= new Jaro(); If you are going to test and need examples so not break the script, you will find it here, in another thread for python optimization.

    Read the article

  • Java script Gallery - how to show a next image with an arrow - shiftImg(1)

    - by Srikanth Naidu
    //html file Image slideshow </script>   Loading image. Please wait 1     1/12 2/12 3/12 4/12 5/12 6/12 7/12 8/12   // //JS File var displayWaitMessage=true; // Display a please wait message while images are loading? var activeImage = false; var imageGalleryLeftPos = false; var imageGalleryWidth = false; var imageGalleryObj = false; var maxGalleryXPos = false; var slideSpeed = 0; var imageGalleryCaptions = new Array(); function startSlide(e) { if(document.all)e = event; var id = this.id; this.getElementsByTagName('IMG')[0].src = 'images/' + this.id + '_over.gif'; if(this.id=='arrow_right'){ slideSpeedMultiply = Math.floor((e.clientX - this.offsetLeft) / 5); slideSpeed = -1*slideSpeedMultiply; slideSpeed = Math.max(-10,slideSpeed); }else{ slideSpeedMultiply = 10 - Math.floor((e.clientX - this.offsetLeft) / 5); slideSpeed = 1*slideSpeedMultiply; slideSpeed = Math.min(10,slideSpeed); if(slideSpeed<0)slideSpeed=10; } } function releaseSlide() { var id = this.id; this.getElementsByTagName('IMG')[0].src = 'images/' + this.id + '.gif'; slideSpeed=0; } function gallerySlide() { if(slideSpeed!=0){ var leftPos = imageGalleryObj.offsetLeft; leftPos = leftPos/1 + slideSpeed; if(leftPos>maxGalleryXPos){ leftPos = maxGalleryXPos; slideSpeed = 0; } if(leftPos<minGalleryXPos){ leftPos = minGalleryXPos; slideSpeed=0; } imageGalleryObj.style.left = leftPos + 'px'; } setTimeout('gallerySlide()',20); } function showImage() { if(activeImage){ activeImage.style.filter = 'alpha(opacity=50)'; activeImage.style.opacity = 0.5; } this.style.filter = 'alpha(opacity=100)'; this.style.opacity = 1; activeImage = this; } function initSlideShow() { document.getElementById('arrow_left').onmousemove = startSlide; document.getElementById('arrow_left').onmouseout = releaseSlide; document.getElementById('arrow_right').onmousemove = startSlide; document.getElementById('arrow_right').onmouseout = releaseSlide; imageGalleryObj = document.getElementById('theImages'); imageGalleryLeftPos = imageGalleryObj.offsetLeft; imageGalleryWidth = document.getElementById('galleryContainer').offsetWidth - 80; maxGalleryXPos = imageGalleryObj.offsetLeft; minGalleryXPos = imageGalleryWidth - document.getElementById('slideEnd').offsetLeft; var slideshowImages = imageGalleryObj.getElementsByTagName('IMG'); for(var no=0;no<slideshowImages.length;no++){ slideshowImages[no].onmouseover = showImage; } var divs = imageGalleryObj.getElementsByTagName('DIV'); for(var no=0;no<divs.length;no++){ if(divs[no].className=='imageCaption')imageGalleryCaptions[imageGalleryCaptions.length] = divs[no].innerHTML; } gallerySlide(); } function showPreview(imagePath,imageIndex){ var subImages = document.getElementById('previewPane').getElementsByTagName('IMG'); if(subImages.length==0){ var img = document.createElement('IMG'); document.getElementById('previewPane').appendChild(img); }else img = subImages[0]; if(displayWaitMessage){ document.getElementById('waitMessage').style.display='inline'; } document.getElementById('largeImageCaption').style.display='none'; img.onload = function() { hideWaitMessageAndShowCaption(imageIndex-1); }; img.src = imagePath; } function hideWaitMessageAndShowCaption(imageIndex) { document.getElementById('waitMessage').style.display='none'; document.getElementById('largeImageCaption').innerHTML = imageGalleryCaptions[imageIndex]; document.getElementById('largeImageCaption').style.display='block'; } function shiftImg(imageIndex){ } window.onload = initSlideShow;

    Read the article

  • Can't remove Enter_Frame and stop TimerEvent

    - by Hwang
    I wanted to remove an ENTER_FRAME object and stopping an TimerEvent when I click on a button, and rerun ENTER_FRAME and TimerEvent when I click on another button. I've tried removeAddEventListener and stop() for the time, but I won't work. Any idea whats the problem here? package{ import flash.display.MovieClip; import flash.display.DisplayObject; import flash.events.Event; import flash.events.TimerEvent; import flash.utils.Timer; public class clockFunction extends MovieClip { private var clock:clockMC=new clockMC(); private var countdownTimer:Timer; //seconds private var secTop1=clock.second.top1.digit; private var secTop2=clock.second.top2.digit; private var secBot1=clock.second.bot1.digit; private var secBot2=clock.second.bot2.digit; private var seconds:Number; private var minutes:Number; private var hours:Number; private var days:Number; public function clockFunction():void { decrease(); addChild(clock); } private function decrease():void { countdownTimer=new Timer(1000); //Adding an event listener to the timer object countdownTimer.addEventListener(TimerEvent.TIMER,updateTime); //Initializing timer object //countdownTimer.start(); } private function updateTime(event:TimerEvent):void { decreasTimerFunction(); clock.second.play(); if (seconds==1) { clock.minute.play(); } if ((minutes==1)&&(seconds==1)) { clock.hour.play(); } if ((hours==1)&&(minutes==1)&&(seconds==1)) { clock.day.play(); } } //Setting it back to its correct time so it won't have number changing in between of flipping issues. private function detect(event:Event):void { //seconds var sec1=seconds; var sec2=seconds-1; if (sec1<10) { sec1="0"+sec1; } if (sec2<10) { sec2="0"+sec2; } if (sec1==00) { sec2=59; } secTop1.text=sec1; secTop2.text=sec2; secBot1.text=sec1; secBot2.text=sec2; } public function startTime():void { addEventListener(Event.ENTER_FRAME,detect); countdownTimer.start(); trace("start"); } public function stopTime():void { countdownTimer.stop(); removeEventListener(Event.ENTER_FRAME,detect); trace("stop"); } private function decreasTimerFunction():void { //Create a date object for Christmas Morning var endTime:Date=new Date(2010,3,26,20,0,0); //Current date object var now:Date=new Date(); // Set the difference between the two date and times in milliseconds var timeDiff:Number=endTime.getTime()-now.getTime(); seconds=Math.floor(timeDiff/1000); minutes=Math.floor(seconds/60); hours=Math.floor(minutes/60); days=Math.floor(hours/24); // Set the remainder of the division vars above hours%=24; minutes%=60; seconds%=60; } } }

    Read the article

< Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >