Search Results

Search found 1785 results on 72 pages for 'beauness round'.

Page 33/72 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • How do I correct the kernel version loaded by Grub2 in Ubuntu 12.04

    - by Paul D'Ambra
    I have a linux vps running Ubuntu 12.04 and when I run uname-r it replies: paul@webforms:~$ uname -r 2.6.32.33-kvm-i386-20111128-dirty paul@webforms:~$ sudo grub-install -v grub-install (GRUB) 1.99-21ubuntu3.1 if I run update-grub I get: paul@webforms:~$ sudo update-grub Generating grub.cfg ... Found linux image: /boot/vmlinuz-3.2.0-26-generic-pae Found initrd image: /boot/initrd.img-3.2.0-26-generic-pae Found linux image: /boot/vmlinuz-2.6.38-15-generic-pae Found initrd image: /boot/initrd.img-2.6.38-15-generic-pae done and then rebooting gives me the same dirty kernel I'm going round in circles and as a relative noob I'm sure I must be missing something obvious so over to the hive-mind!!

    Read the article

  • Want to SASL/TLS authentication

    - by Naval
    I want to send mail from remote client from my server(centos 5 and 64 bit) for this i need to sasl auth but i have no idea about it what changes i have to make in my server and client here I want to make things more clear my server's hostname/Ip is = test02.s80.in/176.67.172.209 now i want to authenticat remote client vps2.smail.info and vps1.smail.info to deliver mail .. so plz help me if any systematic way to do sasl/tls authentication for these clients... i am using DNS load-balancing(round-robin) mx record lookup technique for load balancing..

    Read the article

  • IRC Services with failover support?

    - by insertjokehere
    I run a single server (call it 'server A') IRC 'network', and thank to the generosity of some friends, I have been given a second server ('server B') that I can run an IRCd on in order to provide redundancy in case server A crashes. This is fine, I can set up a round-robin DNS with the servers linked. The problem I have is what to do about services? Does anyone know of a way to get the services to 'fail over' in case of a server failure? Eg, Server A starts off running the services, but suddenly crashes. Server B detects this and starts its own copy of the services (ideally with the same configuration and data as the services on Server B) One solution that comes it mind is to write a bot that each server runs, that sit in a channel periodically checking if the bot from the other server is in the channel. If it is, then all is well. If not, then failover. I would prefer not to have to code this myself though We are currently using Unreal IRCd and Anope services on Linux

    Read the article

  • Ways to do simple failover with one server and two IPs

    - by CrassHoppr
    The setup is one server (Windows 2008) at one location with two incoming connections. As the server has to interface with various on-site devices, and will have a small number of incoming connections, a data center is not an option, and instead cable/dsl connections must be used. The goal is that users visit https://service.site.com and are sent to either the primary IP address or a secondary IP if the primary is down. I've seen advice to use round robin DNS for this, but caching an IP for a downed interface is something I'd like to avoid. Is something like this possible with these constraints?

    Read the article

  • SharePoint 2010 MySites - Simple explanation needed!

    - by Chris W
    I've been playing around with the 2010 beta for a couple of weeks, experimenting with topology options etc. I think I've got myself totally confused as to how it works hence if there's any SP experts out there that can explain things in simple terms for me I'd appreciate it! I want to setup a farm with 3 servers providing the content & MySites. I presume that the way to do this is to load balance or DNS round robin traffic between the 3 servers. The bit where I'm confused is that My Site Settings page asks for a specific My Site Host hence all my site traffic will be pushed to a single server even though we have 3 in the farm. If this hosts fails I presume MySites will be unavailable. Is this right? How do I configure it so that access to MySites is load balanced across the 3 servers in the farm?

    Read the article

  • Session persistence between multiple Rails / Unicorn servers with Redis as session_store on AWS

    - by d_ethier
    I've got 2 nginx EC2 instances pointing to 2 Unicorn EC2 instances in a round robin load balanced configuration. The two nginx instances are being the Elastic Load Balancer. Both Unicorn instances have a Redis session_store configured which is in a master/slave configuration with an Elastic IP attached to the master. I've tried configuring the session stickiness on the load balancer, but sessions are lost on each page refresh. I'm using the redis-store gem for the session_store configuration and redis support. Anyone have any ideas as to why this is not working?

    Read the article

  • Reverse Engineer Formula

    - by aaronls
    Are there any free programs or web services for reverse engineering a formula given a set of inputs and outputs? Consider if had 3 columns of data. The first two numbers are inputs, and the last one is an output: 3,4,7 1,4,5 4,2,6 The outputs could be produced with simply a+b, but there could be many formulas that would give the same result of course. I am talking about data without any error or deviation, and I think the formula would only need basic operations(divide, multiply, add, sutbract) and possibly use one of floor/ceiling/round.

    Read the article

  • Windows 7 x64 Hard Freezing (again)

    - by Lanissum
    Awhile ago, my computer was randomly freezing a few minutes after booting, and I ended up replacing the CPU and mobo after testing the RAM and hard drive, I also couldn't find anything wrong with the video card. So after replacing the presumably faulty hardware, everything worked fine for about a month and a half. All of a sudden, My computer is randomly freezing a few minutes after loading up any intensive application (games, mostly). Most of the time it just freezes with the current frame until I hard reset, although once it printed a BSOD message stating that dxgmms1.sys was to blame. The only difference between these two episodes I can think of is that I can do word/internet/work without issue now, as opposed to the near uselessness my computer was rendered last time. For those of you who want to know, I tested my memory with memtest86 (for 64 bit machines). I can't figure out what could have started this latest round of issues, the event logger just states that a kernel-power event has occurred (like last time) but I think thats just a generic "this machine has rebooted after a sudden shutdown" message.

    Read the article

  • Install Windows 8 Apps to custom directory

    - by Timothy Ford
    I'm running Windows 8 Pro on a laptop. I initially installed the OS just to fiddle round with it and get to know something I'd inevitably end up having to fix for someone. The problem being I only gave the partition about 32gb and that ran out pretty quick. I'd like to install office and get used to that as well but unfortunately I'm a few gigabytes short. I'd like to know if I can change the install location of office 2013 and other apps so that I can run them from another partition because there is no space left to the right of this partition I can't extend it.

    Read the article

  • Doesn't DNS diversity negatively affect performance? Why/how?

    - by cnst
    If you look at the press releases of various orgs that run the internet, you can see them praise the fact that now they run root server X in city Y, as if that magically makes everyone in city Y get all the relevant resolutions from the local server X, instead of going 200ms across the oceans and lands to other continents for resolutions. Similarly, the zones of some geographical domain names, like .ru, are being mirrored not just within Europe, but also, for example, in Hong Kong, which is no more, no less, but is about 300ms away from central Europe, since the traffic is often crossing the two oceans on each way. Doesn't all of this negatively affect DNS performance? Isn't it more of a liability to have a diverse pool of geodispersed authoritative servers, especially if your target audience is quite geographically concentrated? Perhaps a better question is, are there any DNS resolvers that use something better than the naive round-robin for choosing which authoritative server to contact?

    Read the article

  • Use HAProxy or Nginx to Load Balance between VPS

    - by xperator
    I want to load balance + failover backup multiple vps webservers hosted on different providers. I heard that for HAProxy you need multiple server under the same subnet, plus a shared (virtual) ip address between load balancers. But it's not possible in my case cause every VPS is on different node/network. Is there a way to use HAProxy in this kind of setup ? ( Please explain how briefly, I don't want to hear your "YES" answer ) What about NginX? Is it possible to achieve same result with Nginx ? (when servers are located on different nets) I know about Round Rubin DNS, but it doesn't provide a real failover solution, neither a load balance between servers.

    Read the article

  • What is the best way to auto failover to backup WAN link for web server

    - by user66735
    Hi Iam looking for the best way to ensure my server ( application ) remains available for all my users (on web/LAN/WAN ), when my primary ISP link fails. My server is behind a firewall on which both my primary & secondary links land. I have already assigned multiple IPs (both ISP's static IP) to the 'A' record ( host.example.com ) in the DNS. However in a round robin scenario is there a way I can ensure that my web user will not see a "cannot dislay web page" error ever ?? What are the better methods to achieve this??

    Read the article

  • Everytime I ping my server, it is pinging localhost instead?

    - by esac
    I recently setup a new server for use with SQL. When I tried to connect via SSMS remotely, it failed. When I pinged it, it is pinging localhost, what is going on here? Please let me know if more details will help. It is Windows Server 2008. C:\>ping 0x7F000001 Pinging 127.0.0.1 with 32 bytes of data: Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Ping statistics for 127.0.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms

    Read the article

  • Runas command for user without password

    - by user156558
    I want to use the runas command in CMD and from Batch files to gain elevated permissions, but I don't have an admin password on my PC because it's my home computer and I'm the only user. Every time I try to use the runas command it asks me for a password, then tells me that blank passwords are not permitted, is there any way round this? I know I can just right click and select run as administrator, but I would much rather have a command that can do it as that is not always an option, and it's just a bit of a pain. I could just be making some kind of basic mistake as I'm not hugely experienced with command prompt, but I'm not completely clueless.

    Read the article

  • Nginx issue with two web nodes

    - by HTF
    I'm running Wordpress website with Nginx and Memcached. I have simple DNS round robin balancing with A records pointing to both web servers. I've noticed the following entries in both web servers access logs: 192.168.1.10 example.com - [07/Jun/2012:22:43:58 +0100] "-" 400 0 "-" "-" - 0.000 192.168.1.10 example.com - [07/Jun/2012:22:43:58 +0100] "-" 400 0 "-" "-" - 0.000 192.168.1.10 example.com - [07/Jun/2012:22:43:58 +0100] "-" 400 0 "-" "-" - 0.000 192.168.1.10 example.com - [07/Jun/2012:22:43:58 +0100] "-" 400 0 "-" "-" - 0.000 192.168.1.10 example.com - [07/Jun/2012:22:43:58 +0100] "-" 400 0 "-" "-" - 0.000 I've configured W3 Total cache plugin for Wordpress - pointing to loopback address (127.0.0.1:11211) on each Wordpress installation. Is this because the webserver is trying to access content that is cached on the other web server? Shall I add IPs to W3 plugin of both web servers on each website (192.168.1.:11211, 192.168.1.2:11211)? I'm not sure if this related to Memcached or maybe some configuration issue on the server itself? Regards

    Read the article

  • Notepad++ or other application to replace string with numeric function

    - by user38963
    Hello. I am using Notepad++ and attempting to replace all numeric strings within a specific tag (xxxxof my XML document with a new string which has been modified by a specific variable. Here's an example (please remove the space between < and start): < start501234< /start round(501234 * 0.9) = 451111 < start451111< /start Is there a way to automatically find all numeric values within the start tag and do replace it by that same value multiplied by 0.9? I don't have to use Notepad++ if there's another tool that can do this. Thanks!

    Read the article

  • Software RAID underneath ESXi datastore

    - by carlpett
    I'm building an virtual environment for a small business. It is based around a single ESXi 5.1 host, which will host half a dozen or so VMs. I'm having some doubts regarding how to implement the storage though. I naturally want the datastore to be fault tolerant, but I can't get the funds for a separate storage machine, nor expensive hardware RAID solutions, so I would like to use some software RAID (lvm/mdadm, most likely). How can this be implemented? My only idea so far would be to create a VM which has the storage adapter as passthrough, puts some software RAID on top of the disks and then presents the resulting volumes "back" to the ESXi host which then creates a datastore from which other VMs get their storage presented. This does seem kind of round-about, do I have any better options? From my research, passthrough seems to come with quite a few drawbacks, such as no suspend/resume etc.

    Read the article

  • Features of Emacs that are complementary to Vim?

    - by redacted
    I've been using Vim extensively for a while now, and I really enjoy working with it. However, I keep reading praises for Emacs. I've decided to take a look at Emacs to round out my knowledge of the Unix editors (not to mention Emacs keybindings are used extensively). But! I'm happy doing most of my daily work in Vim. So ideally what I'd like is to look at (apart from basics) are the gaps that Emacs can fill, or things that it can just do better than Vim. I suppose the canonical example is Lisp/Scheme coding in Emacs versus Vim. Where would you start tinkering with Emacs to really appreciate its power, and to get a good idea of how its approach to editing differs from Vim, and how the editors can complement each other? What would be a good introduction in the same vein?

    Read the article

  • Load balanced proxies to avoid an API request limit

    - by ClickClickClick
    There is a certain API out there which limits the number of requests per day per IP. My plan is to create a bunch of EC2 instances with elastic IPs to sidestep the limitation. I'm familiar with EC2 and am just interested in the configuration of the proxies and a software load balancer. I think I want to run a simple TCP Proxy on each instance and a software load balancer on the machine I will be requesting from. Something that allows the following to return a response from a different IP (round robin, availability, doesn't really matter..) eg. curl http://www.bbc.co.uk -x http://myproxyloadbalancer:port Could anyone recommend a combination of software or even a link to an article that details a pleasing way to pull it off? (My client won't be curl but is proxy aware.. I'll be making the requests from a Ruby script..)

    Read the article

  • Setup of Citrix-Client (xenapp) doesn't work on Windows Vista Utimate

    - by Ice
    I have a notebook with a fully patched Vista Ultimate and there was a Citrix ica-client installed for access on our citrix-server(s). Once the client couldn't access the server – it took so much time ( 5 min) and everything froze. I did an uninstall und cleaned up the registry. But now it's not possible to reinstall a xenapp-client even the newest directly from www.citrix.com. What could be the reason? How to fix this issue? PS: At the moment I start a vm with an XP and the citrix-access runs like a charm, but that only could be a work-a-round.

    Read the article

  • PHP/GD - Cropping and Resizing Images

    - by Alix Axel
    I've coded a function that crops an image to a given aspect ratio and finally then resizes it and outputs it as JPG: <?php function Image($image, $crop = null, $size = null) { $image = ImageCreateFromString(file_get_contents($image)); if (is_resource($image) === true) { $x = 0; $y = 0; $width = imagesx($image); $height = imagesy($image); /* CROP (Aspect Ratio) Section */ if (is_null($crop) === true) { $crop = array($width, $height); } else { $crop = array_filter(explode(':', $crop)); if (empty($crop) === true) { $crop = array($width, $height); } else { if ((empty($crop[0]) === true) || (is_numeric($crop[0]) === false)) { $crop[0] = $crop[1]; } else if ((empty($crop[1]) === true) || (is_numeric($crop[1]) === false)) { $crop[1] = $crop[0]; } } $ratio = array ( 0 => $width / $height, 1 => $crop[0] / $crop[1], ); if ($ratio[0] > $ratio[1]) { $width = $height * $ratio[1]; $x = (imagesx($image) - $width) / 2; } else if ($ratio[0] < $ratio[1]) { $height = $width / $ratio[1]; $y = (imagesy($image) - $height) / 2; } /* How can I skip (join) this operation with the one in the Resize Section? */ $result = ImageCreateTrueColor($width, $height); if (is_resource($result) === true) { ImageSaveAlpha($result, true); ImageAlphaBlending($result, false); ImageFill($result, 0, 0, ImageColorAllocateAlpha($result, 255, 255, 255, 127)); ImageCopyResampled($result, $image, 0, 0, $x, $y, $width, $height, $width, $height); $image = $result; } } /* Resize Section */ if (is_null($size) === true) { $size = array(imagesx($image), imagesy($image)); } else { $size = array_filter(explode('x', $size)); if (empty($size) === true) { $size = array(imagesx($image), imagesy($image)); } else { if ((empty($size[0]) === true) || (is_numeric($size[0]) === false)) { $size[0] = round($size[1] * imagesx($image) / imagesy($image)); } else if ((empty($size[1]) === true) || (is_numeric($size[1]) === false)) { $size[1] = round($size[0] * imagesy($image) / imagesx($image)); } } } $result = ImageCreateTrueColor($size[0], $size[1]); if (is_resource($result) === true) { ImageSaveAlpha($result, true); ImageAlphaBlending($result, true); ImageFill($result, 0, 0, ImageColorAllocate($result, 255, 255, 255)); ImageCopyResampled($result, $image, 0, 0, 0, 0, $size[0], $size[1], imagesx($image), imagesy($image)); header('Content-Type: image/jpeg'); ImageInterlace($result, true); ImageJPEG($result, null, 90); } } return false; } ?> The function works as expected but I'm creating a non-required GD image resource, how can I fix it? I've tried joining both calls but I must be doing some miscalculations. <?php /* Usage Examples */ Image('http://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', '1:1', '600x'); Image('http://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', '2:1', '600x'); Image('http://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', '2:', '250x300'); ?> Any help is greatly appreciated, thanks.

    Read the article

  • Blackjack game reshuffling problem

    - by Jam
    I am trying to make a blackjack game where before each new round, the program checks to make sure that the deck has 7 cards per player. And if it doesn't, the deck clears, repopulates, and reshuffles. I have most of the problem down, but for some reason at the start of every deal it reshuffles the deck more than once, and I can't figure out why. Help, please. Here's what I have so far: (P.S. the imported cards and games modules aren't part of the problem, I'm fairly sure my problem lies in the deal() function of my BJ_Deck class.) import cards, games class BJ_Card(cards.Card): """ A Blackjack Card. """ ACE_VALUE = 1 def get_value(self): if self.is_face_up: value = BJ_Card.RANKS.index(self.rank) + 1 if value > 10: value = 10 else: value = None return value value = property(get_value) class BJ_Deck(cards.Deck): """ A Blackjack Deck. """ def populate(self): for suit in BJ_Card.SUITS: for rank in BJ_Card.RANKS: self.cards.append(BJ_Card(rank, suit)) def deal(self, hands, per_hand=1): for rounds in range(per_hand): for hand in hands: if len(self.cards)>=7*(len(hands)): top_card=self.cards[0] self.give(top_card, hand) else: print "Reshuffling the deck." self.cards=[] self.populate() self.shuffle() top_card=self.cards[0] self.give(top_card, hand) class BJ_Hand(cards.Hand): """ A Blackjack Hand. """ def init(self, name): super(BJ_Hand, self).init() self.name = name def __str__(self): rep = self.name + ":\t" + super(BJ_Hand, self).__str__() if self.total: rep += "(" + str(self.total) + ")" return rep def get_total(self): # if a card in the hand has value of None, then total is None for card in self.cards: if not card.value: return None # add up card values, treat each Ace as 1 total = 0 for card in self.cards: total += card.value # determine if hand contains an Ace contains_ace = False for card in self.cards: if card.value == BJ_Card.ACE_VALUE: contains_ace = True # if hand contains Ace and total is low enough, treat Ace as 11 if contains_ace and total <= 11: # add only 10 since we've already added 1 for the Ace total += 10 return total total = property(get_total) def is_busted(self): return self.total > 21 class BJ_Player(BJ_Hand): """ A Blackjack Player. """ def is_hitting(self): response = games.ask_yes_no("\n" + self.name + ", do you want a hit? (Y/N): ") return response == "y" def bust(self): print self.name, "busts." self.lose() def lose(self): print self.name, "loses." def win(self): print self.name, "wins." def push(self): print self.name, "pushes." class BJ_Dealer(BJ_Hand): """ A Blackjack Dealer. """ def is_hitting(self): return self.total < 17 def bust(self): print self.name, "busts." def flip_first_card(self): first_card = self.cards[0] first_card.flip() class BJ_Game(object): """ A Blackjack Game. """ def init(self, names): self.players = [] for name in names: player = BJ_Player(name) self.players.append(player) self.dealer = BJ_Dealer("Dealer") self.deck = BJ_Deck() self.deck.populate() self.deck.shuffle() def get_still_playing(self): remaining = [] for player in self.players: if not player.is_busted(): remaining.append(player) return remaining # list of players still playing (not busted) this round still_playing = property(get_still_playing) def __additional_cards(self, player): while not player.is_busted() and player.is_hitting(): self.deck.deal([player]) print player if player.is_busted(): player.bust() def play(self): # deal initial 2 cards to everyone self.deck.deal(self.players + [self.dealer], per_hand = 2) self.dealer.flip_first_card() # hide dealer's first card for player in self.players: print player print self.dealer # deal additional cards to players for player in self.players: self.__additional_cards(player) self.dealer.flip_first_card() # reveal dealer's first if not self.still_playing: # since all players have busted, just show the dealer's hand print self.dealer else: # deal additional cards to dealer print self.dealer self.__additional_cards(self.dealer) if self.dealer.is_busted(): # everyone still playing wins for player in self.still_playing: player.win() else: # compare each player still playing to dealer for player in self.still_playing: if player.total > self.dealer.total: player.win() elif player.total < self.dealer.total: player.lose() else: player.push() # remove everyone's cards for player in self.players: player.clear() self.dealer.clear() def main(): print "\t\tWelcome to Blackjack!\n" names = [] number = games.ask_number("How many players? (1 - 7): ", low = 1, high = 8) for i in range(number): name = raw_input("Enter player name: ") names.append(name) print game = BJ_Game(names) again = None while again != "n": game.play() again = games.ask_yes_no("\nDo you want to play again?: ") main() raw_input("\n\nPress the enter key to exit.")

    Read the article

  • How can I get Firefox to update background-color on a:hover *before* a javascript routine is run?

    - by Rob
    I'm having a Firefox-specific issue with a script I wrote to create 3d layouts. The correct behavior is that the script pulls the background-color from an element and then uses that color to draw on the canvas. When a user mouses over a link and the background-color changes to the :hover rule, the color being drawn changes on the canvas changes as well. When the user mouses out, the color should revert back to non-hover color. This works as expected in Webkit browsers and Opera, but it seems like Firefox doesn't update the background-color in CSS immediately after a mouseout event occurs, so the current background-color doesn't get drawn if a mouseout occurs and it isn't followed up by another event that calls the draw() routine. It works just fine in Opera, Chrome, and Safari. How can I get Firefox to cooperate? I'm including the code that I believe is most relevant to my problem. Any advice on how I fix this problem and get a consistent effect would be very helpful. function drawFace(coord, mid, popColor,gs,x1,x2,side) { /*Gradients in our case run either up/down or left right. We have two algorithms depending on whether or not it's a sideways facing piece. Rather than parse the "rgb(r,g,b)" string(popColor) retrieved from elsewhere, it is simply offset with the gs variable to give the illusion that it starts at a darker color.*/ var canvas = document.getElementById('depth'); //This is for excanvas.js var G_vmlCanvasManager; if (G_vmlCanvasManager != undefined) { // ie IE G_vmlCanvasManager.initElement(canvas); } //Init canvas if (canvas.getContext) { var ctx = canvas.getContext('2d'); if (side) var lineargradient=ctx.createLinearGradient(coord[x1][0]+gs,mid[1],mid[0],mid[1]); else var lineargradient=ctx.createLinearGradient(coord[0][0],coord[2][1]+gs,coord[0][0],mid[1]); lineargradient.addColorStop(0,popColor); lineargradient.addColorStop(1,'black'); ctx.fillStyle=lineargradient; ctx.beginPath(); //Draw from one corner to the midpoint, then to the other corner, //and apply a stroke and a fill. ctx.moveTo(coord[x1][0],coord[x1][1]); ctx.lineTo(mid[0],mid[1]); ctx.lineTo(coord[x2][0],coord[x2][1]); ctx.stroke(); ctx.fill(); } } function draw(e) { var arr = new Array() var i = 0; var mid = new Array(2); $(".pop").each(function() { mid[0]=Math.round($(document).width()/2); mid[1]=Math.round($(document).height()/2); arr[arr.length++]=new getElemProperties(this,mid); i++; }); arr.sort(sortByDistance); clearCanvas(); for (a=0;a<i;a++) { /*In the following conditional statements, we're testing to see which direction faces should be drawn, based on a 1-point perspective drawn from the midpoint. In the first statement, we're testing to see if the lower-left hand corner coord[3] is higher on the screen than the midpoint. If so, we set it's gradient starting position to start at a point in space 60pixels higher(-60) than the actual side, and we also declare which corners make up our face, in this case the lower two corners, coord[3], and coord[2].*/ if (arr[a].bottomFace) drawFace(arr[a].coord,mid,arr[a].popColor,-60,3,2); if (arr[a].topFace) drawFace(arr[a].coord,mid,arr[a].popColor,60,0,1); if (arr[a].leftFace) drawFace(arr[a].coord,mid,arr[a].popColor,60,0,3,true); if (arr[a].rightFace) drawFace(arr[a].coord,mid,arr[a].popColor,-60,1,2,true); } } $("a.pop").bind("mouseenter mouseleave focusin focusout",draw); If you need to see the effect in action, or if you want the full javascript code, you can check it out here: http://www.robnixondesigns.com/strangematter/

    Read the article

  • Image Resizing: Poor jpeg quality and black PNG backgrounds

    - by azz0r
    Hello, I have two issues with my class, basically the quality of the jpeg images is quite poor, but I'm not sure if thats down to my ratio resizing. Ideally I'd like this class to be strict with image sizes and crop into them, but I cant get my head around it. My main issue is that pngs always have a black bg, does anyone have experience with this happening? <?php class OpenSource_ImageResize { function __construct($theFile, $toWhere, $mime, $extension, $newWidth, $newHeight) { if ($mime == NULL) { $mime = getimagesize($theFile); $mime = $mime['mime']; } if ($mime == 'image/jpeg') { $size = getimagesize($theFile); if ($size[0] > $newWidth || $size[1] > $newHeight) { $sourceImage = imagecreatefromjpeg($theFile); } else { return copy($theFile, $toWhere); throw new exception('Could not create jpeg'); return false; } } else if ($mime == 'image/png') { $size = getimagesize($theFile); if ($size[0] > $newWidth || $size[1] > $newHeight) { $sourceImage = imagecreatefrompng($theFile); } else { return copy($theFile, $toWhere); //throw new exception('Could not create png'); return false; } } else if ($mime == 'image/gif') { $size = getimagesize($theFile); if ($size[0] > $newWidth || $size[1] > $newHeight) { $sourceImage = imagecreatefromgif ($theFile); } else { return copy($theFile, $toWhere); //throw new exception('Could not create gif'); return false; } } else { throw new exception('Not a valid mime type'); return false; } $oldX = imageSX($sourceImage); $oldY = imageSY($sourceImage); if ($newWidth == NULL) { $thumbHeight = $newHeight; $thumbWidth = round($newHeight/($oldY/$oldX)); } else if ($oldX > $oldY) { $thumbWidth = $newWidth; $thumbHeight = $oldY * ($newHeight/$oldX); } if ($oldX < $oldY) { $thumbWidth = round($newHeight/($oldY/$oldX)); $thumbHeight = $newHeight; } if ($oldX == $oldY) { $thumbWidth = $newWidth; $thumbHeight = $newHeight; } if (!gd_info()) { $dstImage = ImageCreate($thumbWidth, $thumbHeight); imagecopyresized($dstImage, $sourceImage, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $oldX, $oldY); } else { $dstImage = ImageCreateTrueColor($thumbWidth, $thumbHeight); imagecopyresampled($dstImage, $sourceImage, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $oldX, $oldY); } if ($mime == 'image/png') { $xparent = imagecolorresolvealpha($dstImage, 255,2,240, 0) ; imagecolortransparent($dstImage,$xparent); imagealphablending($dstImage,true); imagepng($dstImage, $toWhere); } else if ($mime == 'image/jpeg') { imagejpeg($dstImage, $toWhere); } else if ($mime == 'image/gif') { imagegif ($dstImage, $toWhere); } imagedestroy($dstImage); imagedestroy($sourceImage); return true; } }

    Read the article

  • How to unit test synchronized code

    - by gillJ
    Hi, I am new to Java and junit. I have the following peice of code that I want to test. Would appreciate if you could send your ideas about what's the best way to go about testing it. Basically, the following code is about electing a leader form a Cluster. The leader holds a lock on the shared cache and services of the leader get resumed and disposed if it somehow looses the lock on the cache. How can i make sure that a leader/thread still holds the lock on the cache and that another thread cannot get its services resumed while the first is in execution? public interface ContinuousService { public void resume(); public void pause(); } public abstract class ClusterServiceManager { private volatile boolean leader = false; private volatile boolean electable = true; private List<ContinuousService> services; protected synchronized void onElected() { if (!leader) { for (ContinuousService service : services) { service.resume(); } leader = true; } } protected synchronized void onDeposed() { if (leader) { for (ContinuousService service : services) { service.pause(); } leader = false; } } public void setServices(List<ContinuousService> services) { this.services = services; } @ManagedAttribute public boolean isElectable() { return electable; } @ManagedAttribute public boolean isLeader() { return leader; } public class TangosolLeaderElector extends ClusterServiceManager implements Runnable { private static final Logger log = LoggerFactory.getLogger(TangosolLeaderElector.class); private String election; private long electionWaitTime= 5000L; private NamedCache cache; public void start() { log.info("Starting LeaderElector ({})",election); Thread t = new Thread(this, "LeaderElector ("+election+")"); t.setDaemon(true); t.start(); } public void run() { // Give the connection a chance to start itself up try { Thread.sleep(1000); } catch (InterruptedException e) {} boolean wasElectable = !isElectable(); while (true) { if (isElectable()) { if (!wasElectable) { log.info("Leadership requested on election: {}",election); wasElectable = isElectable(); } boolean elected = false; try { // Try and get the lock on the LeaderElectorCache for the current election if (!cache.lock(election, electionWaitTime)) { // We didn't get the lock. cycle round again. // This code to ensure we check the electable flag every now & then continue; } elected = true; log.info("Leadership taken on election: {}",election); onElected(); // Wait here until the services fail in some way. while (true) { try { Thread.sleep(electionWaitTime); } catch (InterruptedException e) {} if (!cache.lock(election, 0)) { log.warn("Cache lock no longer held for election: {}", election); break; } else if (!isElectable()) { log.warn("Node is no longer electable for election: {}", election); break; } // We're fine - loop round and go back to sleep. } } catch (Exception e) { if (log.isErrorEnabled()) { log.error("Leadership election " + election + " failed (try bfmq logs for details)", e); } } finally { if (elected) { cache.unlock(election); log.info("Leadership resigned on election: {}",election); onDeposed(); } // On deposition, do not try and get re-elected for at least the standard wait time. try { Thread.sleep(electionWaitTime); } catch (InterruptedException e) {} } } else { // Not electable - wait a bit and check again. if (wasElectable) { log.info("Leadership NOT requested on election ({}) - node not electable",election); wasElectable = isElectable(); } try { Thread.sleep(electionWaitTime); } catch (InterruptedException e) {} } } } public void setElection(String election) { this.election = election; } @ManagedAttribute public String getElection() { return election; } public void setNamedCache(NamedCache nc) { this.cache = nc; }

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >