Daily Archives

Articles indexed Sunday January 2 2011

Page 18/27 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Log off as local "administrator" user, get blank login screen

    - by Force Flow
    I have an imaged lab environment running Windows 7 and attached to a domain. The local Administrator account is enabled for certain maintenance and prep tasks. Every time I logoff from the local Administrator account, it brings me back to the standard Ctrl+Alt+Del login screen. When I press that combination, all the user controls vanish except for the accessibility button down in the left hand corner. The only way I can seem to escape from this is to tap the power button to initiate a shutdown. Windows is up-to-date, and logging off as any other user operates normally. The "hide last user" local security policy option is enabled. Has anyone seen this phenomenon before and how can I stop this from happening?

    Read the article

  • Internet wireless connected with limited access, windows vista

    - by Wawa wiya
    Hello I had some malware in my computer so I did a bit of manual work to remove it including resetting TCP/IP. Now the malware is gone. I can see my home wireless network and I can get connected to it but when connected I get the Internet wireless connected with limited access message. When I go to the IE I cannot browse. When I tried to ping 192.168.1.1 I got an Error Code 1231 Unconnected Network Problem. I have deactivated my Windows firewall as I thought it could be hyperactive security. Still no luck. I have Norton but it is not active, I have also Avast and AVG installed but they are not active. Any ideas?

    Read the article

  • Skype Video Calling Comes To iPhone And iPod Touch

    - by Gopinath
    Skype 3.0 app for iPhone/iPod Touch lets you make video calls right from your iOS device to another iOS device or computer running Skype application. Skype blog post says This season is very special as we are releasing a new version of Skype for iPhone and iPod Touch with video calling. Skype video calling is supported over WiFi and 3G* data connections. You can enjoy video calls with users on all Skype desktop versions and with other Skype for iPhone, iPod Touch, and iPad users. You can make video calls in both portrait and landscape mode and use both front and back cameras. Users on iPhone 4, 3GS and iPod Touch (4th Generation) can enjoy full 2-way video calling. Users with iPod Touch (3rd Generation) and iPads can receive video. Download the app straight from AppStore This article titled,Skype Video Calling Comes To iPhone And iPod Touch, was originally published at Tech Dreams. Grab our rss feed or fan us on Facebook to get updates from us.

    Read the article

  • Can't access any functions after chown command.

    - by explorex
    I am not being to access any functions in my desktop and I don't have an OS besides Ubuntu and I am new to Ubuntu. I think I rebooted my computer thinking that Google Chrome crashed. I opened Google Chrome but it showed opening message but never opened so I restarted my computer. and when my system was loading (I was playing with keyboard dont know what I typed) and when by Ubuntu loaded, I was unable to access anything some of characteristics are listed below: I cannot hear any sound I cannot access wired ethernet connection on the right corner where I usually enable to access internet and I have no internet. There is no local apache server either. when ever I try to start apacer I get setuid must be root or something. When I type sudo then I get message setuid must be root. I cannot access orther external storage devices like pendrive and portable hard drive and cannot mount my other drives with FAT32 filesystem. When I try to start my apache webserver with out typing sudo then I get message cannnot open socket or something like it. I remember also doing command chown -R www-data / earlier and got error message I cannot shutdown my computer, it only logs off

    Read the article

  • Using another browser than w3m for reading HTML helpfiles?

    - by NES
    I'm using fish as shell. The internal help is based on html files and when i type help, it opens w3m to view this help files. Since w3m is not my default browser i wonder where this configuration to start w3m for this is stored. I'd like to read the helpfiles with another browser. How can i setup another one for this purpose or perhaps where are the helpfiles located so i can open them manually in the browser.

    Read the article

  • How do I get one monitor on top of the other?

    - by Jan
    I'm using a laptop and a monitor (wall mounted) over my laptop. I would like to reflect this physical hardware setup in my software screen setup. So that I can move my mouse upward, out of my laptop screen and use the monitor on the wall. I have been searching for a solution for a while, and I hope somone can help me out. I'm using Ubuntu 10.10 "out of the box". Side by side screen setups works just fine, over/under is doesn't work.

    Read the article

  • How can you remove Unity from Ubuntu Netbook Edition

    - by Brad
    In previous versions of Netbook Remix I was able to disable the netbook-launcher and just have a blank desktop. I liked the speed of the Netbook version but not the interface, this worked well for me. However, now with 10.10 and Unity I'm having trouble doing a similar thing. I tried removing netbook-launcher from the startup and tried uninstalling unity. The best result I got was a black desktop with a panel and a non configurable blank white background. Is Unity soo integrated into this version that I will have to just go with the default ubuntu installation?? In the past the default version has been slower then the Netbook version without the interface. Thanks.

    Read the article

  • Shoes and Gems and how to get them working.

    - by Pselus
    I have seen this question asked all over the internet and answered in many different ways. None of them seem to be working for me. I am trying to get Gems to work in Shoes (specifically the gem Mechanize). Whenever I use the code: Shoes.setup do gem 'mechanize' end require 'mechanize' It gives me the popup that says it is installing native extensions and sits at that screen for 30 minutes and longer (I've only ever waited as long as 30 minutes). I have seen people say that you should be putting the .gem files in ~/.shoes/+gem/gem (on OS X) but that hasn't worked for me. Neither has putting the source code for the gem there. On another odd note, both the gems RedCloth and Nokogiri come with Shoes...but using the above code for them gets me No such file to load errors for both of them. Anyone have any expertise in this area and can help me out?

    Read the article

  • Help understanding how to make a bar chart using ggplot2

    - by celenius
    I'm trying to use the bar_geom function of ggplot2, but I can't understand how to use it. I've made a small sample of my code to show what I am trying to do: library(ggplot2) # sample data sampleData = data.frame( v1=c('a','b','c','d','e', 'f','g', 'h', 'i','j'), v2=c(1:10) ) sampleData$Names = data.frame( Names = paste(sampleData$v1, sampleData$v2, sep="") ) sampleData$Values = c(1:10) # make plot x = sampleData$Values y = sampleData$Names qplot( x, y, data = sampleData, geom="bar" ) I want sampleData$Names to be on the x-axis of my graph, labeling each bar and and sampleData$Values to scale the bar height. I want the y-axis to be specified as a range. I realize that I don't understand how ggplot2 functions as this small example does not work, yet my other example is generating a plot but I cannot specify a y-range as it considers the variables to be categorical.

    Read the article

  • TypeError while iterating through a Hash

    - by Ved
    I have the following hash: {"groups"=>[{"type"=>"Nearby", "venues"=>[{"id"=>4450132, "name"=>"Position2", "address"=>"Domlur", "city"=>"Bangalore", "state"=>"Karnataka/India", "zip"=>"560037", "verified"=>false, "geolat"=>12.9566921, "geolong"=>77.6407258, "stats"=>{"herenow"=>"0"}, "twitter"=>"position2", "hasTodo"=>"false", "distance"=>0},... I want to iterate through it and find all the 'name' attributes. My code looks like: response["groups"]["Nearby"]["venues"].each do |key| logger.debug key['name'] end But I keep on getting error: TypeError (can't convert String into Integer): I am on ruby 1.9.

    Read the article

  • $_SERVER['HTTP_HOST'] not set

    - by yes123
    Hi guys, I am getting lot of traffic to my php pages but without the variable $_SERVER['HTTP_HOST'] setted. This traffic is like 1 hit per second. I don't know what it could be, but for reducing server load i am doing this at the top of every php pages: if (!isset($_SERVER['HTTP_HOST'])) exit; Do u know what could cause this? Is it safe to exit whenever http_host is not setted? Can a normal user visit my pages without setting http_host? PHP version: 5.2.0-8, Apache: 2.2.3 Thanks

    Read the article

  • What causes Python "Interpreter not Initialized" error?

    - by ?????
    I'm now on my third full day this week of trying to get OpenCV to work with Python. (I have been trying on and off for the past 6 months). I get this error Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. dlopen("/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so", 2); import readline # dynamically loaded from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so >>> import cv dlopen("./cv.so", 2); Fatal Python error: Interpreter not initialized (version mismatch?) and then it crashes (core dumps). python -v gives nothing after the dlopen. Any ideas from anyone who actually knows about this error?

    Read the article

  • Opening Macro definitions: tdfx_span.c: lvalue required as left operand of assignment

    - by anttir
    Hi, I'm trying to compile X11R6-7.0 under Ubuntu maverick and got some weird compilation errors I'm unable to resolve myself. I needed X11R6-7.0 as ati catalyst drivers don't support newer xorg and oss drivers don't support 3d acceleration of my hardware. Anyone know what this error message means? I know some C but I got a bit confused. Does it mean GET_FB_DATA macro returned NULL or some method/property not set? Any further insight how to "debug" preprocessor definitions at this point would be great. I don't think I can print anything useful with #error. The error I get: tdfx_span.c: In function ‘tdfxDDWriteDepthPixels’: tdfx_span.c:976: error: lvalue required as left operand of assignment tdfx_span.c:1008: error: lvalue required as left operand of assignment tdfx_span.c: In function ‘write_stencil_pixels’: tdfx_span.c:1242: error: lvalue required as left operand of assignment the Code: 958- switch (depth_size) { 959- case 16: 960- GetBackBufferInfo(fxMesa, &backBufferInfo); 961- /* 962- * Note that the _LOCK macro adds a curly brace, 963- * and the UNLOCK macro removes it. 964- */ 965- WRITE_FB_SPAN_LOCK(fxMesa, info, 966- GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); 967- { 968- LFBParameters ReadParams; 969- GetFbParams(fxMesa, &info, &backBufferInfo, 970- &ReadParams, sizeof(GLushort)); 971- for (i = 0; i < n; i++) { 972- if (mask[i] && visible_pixel(fxMesa, x[i], y[i])) { 973- xpos = x[i] + fxMesa->x_offset; 974- ypos = bottom - y[i]; 975- d16 = depth[i]; 976: PUT_FB_DATA(&ReadParams, GLushort, xpos, ypos, d16); 977- } 978- } 979- } 980- WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); 981- break; 982- case 24: And relative macros: #define GET_FB_DATA(ReadParamsp, type, x, y) \ (((x) < (ReadParamsp)->firstWrappedX) \ ? (((type *)((ReadParamsp)->lfbPtr)) \ [(y) * ((ReadParamsp)->LFBStrideInElts) \ + (x)]) \ : (((type *)((ReadParamsp)->lfbWrapPtr)) \ [((y)) * ((ReadParamsp)->LFBStrideInElts) \ + ((x) - (ReadParamsp)->firstWrappedX)])) #define GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \ (((type *)((ReadParamsp)->lfbPtr)) \ [(y) * ((ReadParamsp)->LFBStrideInElts) \ + (x)]) #define GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) \ (((type *)((ReadParamsp)->lfbWrapPtr)) \ [((y)) * ((ReadParamsp)->LFBStrideInElts) \ + ((x) - (ReadParamsp)->firstWrappedX)]) #define PUT_FB_DATA(ReadParamsp, type, x, y, value) \ (GET_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) #define PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value) \ (GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) #define PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value) \ (GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) The LFBParameters Struct 483-typedef struct 484-{ 485- void *lfbPtr; 486- void *lfbWrapPtr; 487- FxU32 LFBStrideInElts; 488- GLint firstWrappedX; 489-} 490:LFBParameters; Thanks for looking.

    Read the article

  • JS and Jquery problem

    - by Sonny
    hi i got the problem the script.js gives me <div id="gracze"> <div id="10" class="char" style="z-index: 19; top: 592px; left: 608px; "></div> <div id="14" class="char" style="z-index: 25; top: 784px; left: 608px; "></div> </div> instead <div id="gracze"> <div id="4" class="char" ... ></div> <div id="10" class="char" style="z-index: 19; top: 592px; left: 608px; "></div> <div id="14" class="char" style="z-index: 25; top: 784px; left: 608px; "></div> </div> get_players.php 4/62/6 10/19/19 14/19/25 script.js function get_players() { $.ajax({ type: "POST", url: "get_players.php", dataType: "html", success: function(data) { var str = data; var chars = str.split("<br />"); var lol = chars.length; for(var i = lol; i--; ) { chars[i] = chars[i].split('/'); var o = document.getElementById(chars[i][0]); var aimt = i; if (!o) { if (aimt!=chars.length-1 && aimt != 0) { $('#gracze').html('<div id="'+chars[aimt][0]+'" class="char"></div>'+$('#gracze').html()); $('#'+chars[aimt][0]).css("top", chars[aimt][2]*32-16+"px"); $('#'+chars[aimt][0]).css("left", chars[aimt][1]*32+"px"); $('#'+chars[aimt][0]).css("z-index", chars[aimt][1]*32); } } else { $('#'+chars[aimt][0]).animate({ "top": chars[aimt][2]*32-16+"px", "left": chars[aimt][1]*32+"px" }, { duration: 275}); //$('#'+chars[aimt][0]).css("top", chars[aimt][1]*32-16+"px"); //$('#'+chars[aimt][0]).css("left", chars[aimt][2]*32+"px"); $('#'+chars[aimt][0]).css("z-index", chars[aimt][2]); } } }}); setTimeout("get_players();", 1000); } I think it's because of for(var i = lol; i--; ) {

    Read the article

  • F# Extention Methods on Lists, IEnumberable, etc

    - by flevine100
    I have searched StackOverflow (and other sources) for this answer, but can't seem to find anything. In C#, if I had a widget definition, say: class widget { public string PrettyName() { ... do stuff here } } and I wanted to allow for easy printing of a list of Widgets, I might do this: namespace ExtensionMethods { public static PrintAll( this IEnumerable<Widget> widgets, TextWriter writer ) { foreach(var w in widgets) { writer.WriteLine( w.PrettyName() ) } } } How would I accomplish something similar with a record type and a collection (List or Seq preferrably in F#). I'd love to have a list of Widgest and be able to call a function right on the collection that did something like this. Assume (since it's F#) that the function would not be changing the state of the collection that it's attached to, but returning some new value.

    Read the article

  • How to pass values from array into mysql with php

    - by moustafa
    my original code is this <tr> <th> <label for="user_level"> User Level: * <?php echo isset($valid_user_level) ? $valid_user_level : NULL; ?> </label> </th> </tr> <td> <select name="user_level" id="user_level" class="sel"> <option value="">Select one…</option> <option value="1">User</option> <option value="5">Admin</option> </select> </td> this give me the option to select one of choice from the drop down menu i.e. user and when user is selected and the submit button is pressed this will insert the value 1 into the database which will when the user logs in tell the system that they are are normal user. I want to change the code to the following <tr> <td> <select name="user_level" id="user_level" class="sel"> <option value="">Select one…</option> <?php if(!empty($level)) { foreach($level as $value) { echo "<option value='{$value}'"; echo getSticky(2,'user_level',$value); echo ">{$value}</option>"; } } ?> </select> </td> </tr> With this being my array query $level = array('User','Admin'); How can I pass the values of 1 for user level and 5 for admin in this code so when the user is selected it inouts 1 into the database?

    Read the article

  • How to get a site screenshot quickly using PHP?

    - by yuli chika
    I want to create a web directory site, and I need to get these site screenshots. How to get a site screenshot quickly using PHP? I tried IECAPT,webscreencapture, khtml2png, but they are all slowly. And they all get screenshot one url by one url. Is IECAPT depends on a ie browser? if it is, why it can not open many ie tags so that work at the same time? Is there anyone can recommend me a PHP screenshots software using online? according to my above requirements? Thank you.

    Read the article

  • Android Stream Data Over Wifi?

    - by Neb
    Im trying to make an app for android that will stream the data of the accelerometer to be used as a game controller on my pc over a local wifi connection. Is it possible to make some kind of wifi stream of the accelerometer values in the android app and then make the pc somehow 'read' this stream? Or would it just be better for the pc to make endless calls to the phone getting the newest accelerometer values from a local android server? It would also have to send commands from the phone such as 'button1 pressed', 'button1 released'.

    Read the article

  • Display attribute from XML using PHP

    - by user560411
    Hello. I need to display the id attribute of CD from the following XML file. I display correctly everything except the id. Any help would be appreciate. display code <?php $doc = new DOMDocument(); $doc->load( 'insert.xml' ); $CATEGORIES = $doc->getElementsByTagName( "CD" ); foreach( $CATEGORIES as $CD ) { $TITLES = $CD->getElementsByTagName( "TITLE" ); $TITLE = $TITLES->item(0)->nodeValue; $BANDS= $CD->getElementsByTagName( "BAND" ); $BAND= $BANDS->item(0)->nodeValue; $YEARS = $CD->getElementsByTagName( "YEAR" ); $YEAR = $YEARS->item(0)->nodeValue; echo "<b>$TITLE - $BAND - $YEAR\n</b><br>"; } ?> XML <?xml version="1.0" encoding="utf-8"?> <MY_CD> <CATEGORIES> <CD id="3231"> <TITLE>NEVER MIND THE BOLLOCKS</TITLE> <BAND>SEX PISTOLS</BAND> <YEAR>1977</YEAR> </CD> <CD id="2453"> <TITLE>NEVERMIND</TITLE> <BAND>NIRVANA</BAND> <YEAR>1991</YEAR> </CD> </CATEGORIES> </MY_CD>

    Read the article

  • C# mvc 3 using selectlist with selected value in view

    - by Rob
    I'm working on a MVC3 web application. I want a list of categories shown when editing a blo from whe applications managements system. In my viewmodel i've got the following property defined for a list of selectlistitems for categories. /// <summary> /// The List of categories /// </summary> [Display(Name = "Categorie")] public IEnumerable<SelectListItem> Categories { get; set; } The next step, my controller contains the following edit action where the list of selectlistitems is filled from the database. public ActionResult Edit(Guid id) { var blogToEdit = _blogService.First(x => x.Id.Equals(id)); var listOfCategories = _categorieService.GetAll(); var selectList = listOfCategories.Select(x =>new SelectListItem{Text = x.Name, Value = x.Id.ToString(), Selected = x.Id.Equals(blogToEdit.Category.Id)}).ToList(); selectList.Insert(0, new SelectListItem{Text = Messages.SelectAnItem, Value = Messages.SelectAnItem}); var viewModel = new BlogModel { BlogId = blogToEdit.Id, Active = blogToEdit.Actief, Content = blogToEdit.Text, Title = blogToEdit.Titel, Categories = selectList //at this point i see the expected item being selected //Categories = new IEnumerable<SelectListItem>(listOfCategories, "Id", "Naam", blogToEdit.CategorieId) }; return View(viewModel); } When i set a breakpoint just before the view is being returned, i see that the selectlist is filled as i expected. So at this point everything seems to be okay. The viewmodel is filled entirely correct. Then in my view (i'm using Razor) i've got the following two rules which are supposed to render the selectlist for me. @Html.LabelFor(m => m.Categories) @Html.DropDownListFor(model=>model.Categories, Model.Categories, Model.CategoryId) @Html.ValidationMessageFor(m => m.Categories) When I run the code and open the view to edit my blog, I can see all the correct data. Also the selectlist is rendered correctly, but the item i want to be selected lost it's selection. How can this be? Until the point the viewmodel is being returned with the view everything is okay. But when i view the webpage in the browser, the selectlist is there only with out the correct selection. What am I missing here? Or doing wrong?

    Read the article

  • what are most important things that i must know in order to jump into silverlight development

    - by Poni
    I have vast programming knowledge; C++/C#/ActionScript/ASM/PHP..... so learning the language of SilverLight itself isn't of an issue. To keep long story short, when asking this question I'm asking it as a developer who's coming from Flash world - great graphics/sounds/media support, fully cross-platform, ability to combine several SWFs within a "movie" (which also implies code reusability). A Flash developer have pretty much freedom. What are most important things that i must know in order to jump into silverlight development? Did you already make the move to SilverLight from Flash yourself? Are you a "guru" at both? Great, let's hear what you have to say - developer to developer! =)

    Read the article

  • Can someone help me with this Java Chess game please?

    - by Chris Edwards
    Hey guys, Please can someone have a look at this code and let me know whether I am on the right track with the "check_somefigure_move"s and the "check_black/white_promotion"s please? And also any other help you can give would be greatly appreciated! Thanks! P.S. I know the code is not the best implementation, but its a template I have to follow :( Code: class Moves { private final Board B; private boolean regular; public Moves(final Board b) { B = b; regular = regular_position(); } public boolean get_regular_position() { return regular; } public void set_regular_position(final boolean new_reg) { regular = new_reg; } // checking whether B represents a "normal" position or not; // if not, then only simple checks regarding move-correctness should // be performed, only checking the direct characteristics of the figure // moved; // checks whether there is exactly one king of each colour, there are // no more figures than promotions allow, and there are no pawns on the // first or last rank; public boolean regular_position() { int[] counts = new int[256]; for (char file = 'a'; file <= 'h'; ++file) for (char rank = '1'; rank <= '8'; ++rank) ++counts[(int) B.get(file,rank)]; if (counts[Board.white_king] != 1 || counts[Board.black_king] != 1) return false; if (counts[Board.white_pawn] > 8 || counts[Board.black_pawn] > 8) return false; int count_w_promotions = 0; count_w_promotions += Math.max(counts[Board.white_queen]-1,0); count_w_promotions += Math.max(counts[Board.white_rook]-2,0); count_w_promotions += Math.max(counts[Board.white_bishop]-2,0); count_w_promotions += Math.max(counts[Board.white_knight]-2,0); if (count_w_promotions > 8 - counts[Board.white_pawn]) return false; int count_b_promotions = 0; count_b_promotions += Math.max(counts[Board.black_queen]-1,0); count_b_promotions += Math.max(counts[Board.black_rook]-2,0); count_b_promotions += Math.max(counts[Board.black_bishop]-2,0); count_b_promotions += Math.max(counts[Board.black_knight]-2,0); if (count_b_promotions > 8 - counts[Board.black_pawn]) return false; for (char file = 'a'; file <= 'h'; ++file) { final char fig1 = B.get(file,'1'); if (fig1 == Board.white_pawn || fig1 == Board.black_pawn) return false; final char fig8 = B.get(file,'8'); if (fig8 == Board.white_pawn || fig8 == Board.black_pawn) return false; } return true; } public boolean check_normal_white_move(final char file0, final char rank0, final char file1, final char rank1) { if (! Board.is_valid_white_figure(B.get(file0,rank0))) return false; if (! B.is_empty(file1,rank1) && ! Board.is_valid_black_figure(B.get(file1,rank1))) return false; if (B.get_active_colour() != 'w') return false; if (! check_move_simple(file0,rank0,file1,rank1)) return false; if (! regular) return true; final Board test_board = new Board(B); test_board.normal_white_move_0(file0,rank0,file1,rank1); final Moves test_move = new Moves(test_board); final char[] king_pos = test_move.white_king_position(); assert(king_pos.length == 2); return test_move.black_not_attacking(king_pos[0],king_pos[1]); } public boolean check_normal_black_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED THE CHECK NORMAL BLACK MOVE BASED ON THE CHECK NORMAL WHITE MOVE if (! Board.is_valid_black_figure(B.get(file0,rank0))) return false; if (! B.is_empty(file1,rank1) && ! Board.is_valid_white_figure(B.get(file1,rank1))) return false; if (B.get_active_colour() != 'b') return false; if (! check_move_simple(file0,rank0,file1,rank1)) return false; if (! regular) return true; final Board test_board = new Board(B); test_board.normal_black_move_0(file0,rank0,file1,rank1); final Moves test_move = new Moves(test_board); final char[] king_pos = test_move.black_king_position(); assert(king_pos.length == 2); return test_move.white_not_attacking(king_pos[0],king_pos[1]); } // for checking a normal move by just applying the move-rules private boolean check_move_simple(final char file0, final char rank0, final char file1, final char rank1) { final char fig = B.get(file0,rank0); if (fig == Board.white_king || fig == Board.black_king) return check_king_move(file0,rank0,file1,rank1); if (fig == Board.white_queen || fig == Board.black_queen) return check_queen_move(file0,rank0,file1,rank1); if (fig == Board.white_rook || fig == Board.black_rook) return check_rook_move(file0,rank0,file1,rank1); if (fig == Board.white_bishop || fig == Board.black_bishop) return check_bishop_move(file0,rank0,file1,rank1); if (fig == Board.white_knight || fig == Board.black_knight) return check_knight_move(file0,rank0,file1,rank1); if (fig == Board.white_pawn) return check_white_pawn_move(file0,rank0,file1,rank1); else return check_black_pawn_move(file0,rank0,file1,rank1); } private boolean check_king_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED KING MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange <= 1 && fileChange >= -1 && rankChange <= 1 && rankChange >= -1; } private boolean check_queen_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED QUEEN MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange <=8 && fileChange >= -8 && rankChange <= 8 && rankChange >= -8; } private boolean check_rook_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED ROOK MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange <=8 || fileChange >= -8 || rankChange <= 8 || rankChange >= -8; } private boolean check_bishop_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED BISHOP MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange <= 8 && rankChange <= 8 || fileChange <= 8 && rankChange >= -8 || fileChange >= -8 && rankChange >= -8 || fileChange >= -8 && rankChange <= 8; } private boolean check_knight_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED KNIGHT MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; /* IS THIS THE CORRECT WAY? * return fileChange <= 1 && rankChange <= 2 || fileChange <= 1 && rankChange >= -2 || fileChange <= 2 && rankChange <= 1 || fileChange <= 2 && rankChange >= -1 || fileChange >= -1 && rankChange <= 2 || fileChange >= -1 && rankChange >= -2 || fileChange >= -2 && rankChange <= 1 || fileChange >= -2 && rankChange >= -1;*/ // OR IS THIS? return fileChange <= 1 || fileChange >= -1 || fileChange <= 2 || fileChange >= -2 && rankChange <= 1 || rankChange >= - 1 || rankChange <= 2 || rankChange >= -2; } private boolean check_white_pawn_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED PAWN MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange == 0 && rankChange <= 1; } private boolean check_black_pawn_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED PAWN MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange == 0 && rankChange >= -1; } public boolean check_white_kingside_castling() { // only demonstration code: final char c = B.get_white_castling(); if (c == '-' || c == 'q') return false; if (B.get_active_colour() == 'b') return false; if (B.get('e','1') != 'K') return false; if (! black_not_attacking('e','1')) return false; if (! free_white('f','1')) return false; // XXX return true; } public boolean check_white_queenside_castling() { // only demonstration code: final char c = B.get_white_castling(); if (c == '-' || c == 'k') return false; if (B.get_active_colour() == 'b') return false; // ADDED BASED ON KINGSIDE CASTLING if (B.get('e','1') != 'Q') return false; if (! black_not_attacking('e','1')) return false; if (! free_white('f','1')) return false; // XXX return true; } public boolean check_black_kingside_castling() { // only demonstration code: final char c = B.get_black_castling(); if (c == '-' || c == 'q') return false; if (B.get_active_colour() == 'w') return false; // ADDED BASED ON CHECK WHITE if (B.get('e','8') != 'K') return false; if (! black_not_attacking('e','8')) return false; if (! free_white('f','8')) return false; // XXX return true; } public boolean check_black_queenside_castling() { // only demonstration code: final char c = B.get_black_castling(); if (c == '-' || c == 'k') return false; if (B.get_active_colour() == 'w') return false; // ADDED BASED ON KINGSIDE CASTLING if (B.get('e','8') != 'Q') return false; if (! black_not_attacking('e','8')) return false; if (! free_white('f','8')) return false; // XXX return true; } public boolean check_white_promotion(final char pawn_file, final char figure) { // XXX // ADDED CHECKING FOR CORRECT FIGURE AND POSITION - ALTHOUGH IT SEEMS AS THOUGH // PAWN_FILE SHOULD BE PAWN_RANK, AS IT IS THE REACHING OF THE END RANK THAT // CAUSES PROMOTION OF A PAWN, NOT FILE if (figure == P && pawn_file == 8) { return true; } else return false; } public boolean check_black_promotion(final char pawn_file, final char figure) { // XXX // ADDED CHECKING FOR CORRECT FIGURE AND POSITION if (figure == p && pawn_file == 1) { return true; } else return false; } // checks whether black doesn't attack the field: public boolean black_not_attacking(final char file, final char rank) { // XXX return true; } public boolean free_white(final char file, final char rank) { // XXX return black_not_attacking(file,rank) && B.is_empty(file,rank); } // checks whether white doesn't attack the field: public boolean white_not_attacking(final char file, final char rank) { // XXX return true; } public boolean free_black(final char file, final char rank) { // XXX return white_not_attacking(file,rank) && B.is_empty(file,rank); } public char[] white_king_position() { for (char file = 'a'; file <= 'h'; ++file) for (char rank = '1'; rank <= '8'; ++rank) if (B.get(file,rank) == Board.white_king) { char[] result = new char[2]; result[0] = file; result[1] = rank; return result; } return new char[0]; } public char[] black_king_position() { for (char file = 'a'; file <= 'h'; ++file) for (char rank = '1'; rank <= '8'; ++rank) if (B.get(file,rank) == Board.black_king) { char[] result = new char[2]; result[0] = file; result[1] = rank; return result; } return new char[0]; } public static void main(final String[] args) { // checking regular_position { Moves m = new Moves(new Board()); assert(m.regular_position()); m = new Moves(new Board("8/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("KK6/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("kk6/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/8/8/8/8/8/8/8 w - - 0 1")); assert(m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/8 w - - 0 1")); assert(m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/n7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/N7 w - - 0 1")); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/b7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/B7 w - - 0 1")); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/r7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/R7 w - - 0 1")); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/q7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/Q7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kkp5/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("KkP5/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/8/8/8/8/8/8/7p w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/8/8/8/8/8/8/7P w - - 0 1")); assert(!m.regular_position()); } // checking check_white/black_king/queenside_castling { Moves m = new Moves(new Board("4k2r/8/8/8/8/8/8/4K2R w Kk - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("4k2r/8/8/8/8/8/8/4K2R b Kk - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("4k2r/4pppp/8/8/8/8/4PPPP/4K2R w KQkq - 0 1")); assert(m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("4k2r/4pppp/8/8/8/8/4PPPP/4K2R b KQkq - 0 1")); assert(!m.check_white_kingside_castling()); assert(m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/8/8/8/8/8/8/R3K3 w Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/8/8/8/8/8/8/R3K3 b Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/p7/8/8/8/8/8/R3K3 w Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/p7/8/8/8/8/8/R3K3 b Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/p7/8/8/8/n7/8/R3K3 w Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/p7/B7/8/8/8/8/R3K3 b Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); // XXX } } }

    Read the article

  • Sanitize GET query with Apache

    - by Freelancer
    Hello everyone, I see there's a lot of talk here about how to go about sanitizing data. Could it be as simple as adding this rewrite rule to .htaccess? RewriteRule ^([\w\-]+)$ index.php?page=$1 To my understanding this will allow only letters, numbers, _ and - in $1, am I right? If you add to this usage of prepared statements for SQL queries, it should be pretty proof, is that right? Somehow feels like too easy to be true, am I missing something, any ways to firm it up?

    Read the article

  • Simplyfing code with a lot of ifs

    - by user278618
    I have a method which based on the enum, and to be clear at start we have this situation: public void MyMetohd(Somestatus status) { if(status == Somestatus.Enum1) { DoA(); DoB(); DoC(); DoD(); DoE(); } if(status == Somestatus.Enum2) { DoA(); DoB(); DoC(); DoD(); } if(status == Somestatus.Enum3) { DoA(); DoB(); DoC(); } if(status == Somestatus.Enum4) { DoA(); DoB(); } if(status == Somestatus.Enum5) { DoA(); } } How would you optimize this kind of code ( it isn't mine)?

    Read the article

  • mongodb php finding a subobject and removing it, $inc other subobject

    - by Mark
    I'm trying to delete the subobject 'apples' from my documents and update the 'fruitInventory' property, decrease by the amount of apples. I'm confused on how to proceed, should I use dot notation or do a full text search for apples? I don't know if this matters but you can assume apples will always be in field 1. // Document 1 { "1": { "apples": 3, "fruitInventory": 21, "oranges": 12, "kiwis": 3, "lemons": 3 }, "2": { "bananas": 4, "fruitInventory": 12, "oranges": 8, }, "_id": "1" } // Document 2 { "1": { "apples": 5, "fruitInventory": 10, "oranges": 2, "pears": 3 }, "2": { "bananas": 4, "fruitInventory": 6, "cherries": 2, }, "_id": "2" } Result should be like this: // Document 1 { "1": { "fruitInventory": 18, "oranges": 12, "kiwis": 3, "lemons": "3" }, "2": { "bananas": 4, "fruitInventory": 12, "oranges": 8, }, "_id": "1" } // Document 2 { "1": { "fruitInventory": 5, "oranges": "2", "pears": "3" }, "2": { "bananas": 4, "fruitInventory": 6, "cherries": 2, }, "_id": "2" } Thanks in advance for your help.

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >