Search Results

Search found 4088 results on 164 pages for 'params keyword'.

Page 46/164 | < Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >

  • Why do almost all Java jobs (postings and from recruiters) say J2EE rather than the newer JEE versions?

    - by Rick
    I'm still fairly new to Java but have definite comfort now working within the framework I am used to which would mainly be focused on Spring, Hibernate and JEE 6. It seems like every time I talk to a recruiter all they do is throw around the keyword "J2EE", they need someone with J2EE experience, etc. I am aware that legacy systems would still be using J2EE but it seems like at least some jobs would be advertising JEE now. Just curious if they are just stuck with some keyword that they can't seem to wrap their heads around it having a newer version or what. Having not done Java all that long, I haven't used J2EE specifically but wouldn't it be fairly easy to adapt having used the newer enterprise edition? Just curious to hear anything about this from someone with more experience.

    Read the article

  • Is it possible to track an outsourced adwords campaign?

    - by Addsy
    We have a site that is paying a 3rd party to run adwords campaigns on our behalf. They do this using their own Adwords account and so we are unable to link it to our Google Analytics account. We do have our own Adwords account for the site which is linked but the majority of campaigns are being run by this 3rd party. At the moment, in our Adwords reports (ie the Adwords section within Google Analytics) we are seeing that for the majority of visits the campaign and keyword data is not set. I am assuming that this is because even though the visit is being recognised as coming from an Adwords account, because it is not the Adwords account linked to our Analytics account, we don't get sent the campaign and keyword information. Is this correct and if so is there a way that we can start tracking this information so that we can see for ourselves how the campaigns are performing? Many thanks

    Read the article

  • AdSense link units targeting better keywords?

    - by Unavailable
    I have one link unit above my navigation which targets exact keywords on what my site is about, on contrary my AdSense for content Leaderboard and Wide Skyscraper show ads that are totally opposite from my keyword, while my ctr increased for about 10 times with link unit I noticed CPC is lower also (but that was just based on one day, today is higher). Is it so bad to completely get rid of standard content ads and put link units, because this way I earn so little for that site but I think that is because smart pricing (accidental clicks on ads that my users are not interested)? I earn in whole day with about 25-35 clicks as much as keyword tool shows for only one click, my site is first for the topic? I really don't know what to do. Has anyone had similar situation or can give some advice?

    Read the article

  • Difference in stats on the same domain - seo related

    - by Duoweb
    Recently i started to optimize my company's website. With a little help of market samurai. One of the adjustments was a www redirect to the prefered domain. We currently rank on #8 for our desired keyword with the domain without the www. If I add a custom url (our domain with www), we see a difference in stats BLP (backlinks to the page) {it's the website on top} Can anyone tell me how i could merge this so we might even rank better for our keyword? What I did so far: 3 weeks ago set the www.duo.be as prefered domain in GWT and put a 301 redirect in place so the duo.be gets redirected to www.duo.be Both domains are in GWT and both with www.duo.be as preferred domain. Tho I see no change. Can anyone help me out, because i'm clueless. Marketsamurai screenshot: http://i.stack.imgur.com/CYkb8.png

    Read the article

  • Is is OK to use a non-primary key as the id in a rails resource?

    - by nPn
    I am getting ready to set up a resource for some new api calls to my rails application. I am planning on calling the resource devices ie resources :devices This is going to represent a android mobile devices I know this will get me routes such as GET devices/:id In most cases :id would be an integer representing the primary key, and in the controller we would use :id as such: GET devices/1 @device = Device.find(params[:id]) In this case I would like to use :id as the google_cloud_messaging_reg_id So I would like to have requests like this: GET devices/some_long_gcm_id and then in the controller , just us params[:id] to look up the device by the gcm registration id. This seem more natural, since the device will know it's gcm id rather than it's rails integer id. Are there any reasons I should avoid doing this?

    Read the article

  • Multiple parameters vs single parameter(object with multiple properties)

    - by Shwetanka
    I have an Entity Student with following properties - (name, joinedOn, birthday, age, batch, etc.) and a function fetchStudents(<params>). I want to fetch students based on multiple filters. In my method I have two ways to pass filters. Pass all filters as params to the method Make a class StudentCriteria with filters as fields and then pass the object of this class While working in java I always go with the second option but recently I'm working in php and I was advised to go with the first way. I am unable to figure out which way is better in maintaining the code, reusability and performance wise. Thanks.

    Read the article

  • delayed job problem in rails.

    - by krunal shah
    My controller data_files_controller.rb def upload_balances DataFile.load_balances(params) end My model data_file.rb def self.load_balances(params) # Pull the file out of the http request, write it to file system name = params['Filename'] directory = "public/uploads" errors_table_name = "snapshot_errors" upload_file = File.join(directory, name) File.open(upload_file, "wb") { |f| f.write(params['Filedata'].read) } # Remove the old data from the table Balance.destroy_all ------ more code----- end It's working fine. Now i want to use delayed job with my controller to call my model action like .. My controller data_files_controller.rb def upload_balances DataFile.send_later(:load_balances,params) end Is it possible?? What's the other way to do it? Is it create any problem? With this send_later i am getting this error in column last_error in delayed_job table. uninitialized stream C:/cyncabc/app/models/data_file.rb:12:in read' C:/cyncabc/app/models/data_file.rb:12:inload_balances' C:/cyncabc/app/models/data_file.rb:12:in open' C:/cyncabc/app/models/data_file.rb:12:inload_balances' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/performable_method.rb:35:in send' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/performable_method.rb:35:inperform' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/backend/base.rb:66:in invoke_job' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:120:inrun' c:/ruby/lib/ruby/1.8/timeout.rb:62:in timeout' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:120:inrun' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:10:in realtime' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:119:inrun' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:180:in reserve_and_run_one_job' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:104:inwork_off' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:103:in times' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:103:inwork_off' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:78:in start' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:10:inrealtime' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:77:in start' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:74:inloop' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/worker.rb:74:in start' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/command.rb:93:inrun' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/command.rb:72:in run_process' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons/application.rb:215:incall' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons/application.rb:215:in start_proc' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons/application.rb:225:incall' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons/application.rb:225:in start_proc' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons/application.rb:255:instart' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons/controller.rb:72:in run' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons.rb:188:inrun_proc' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:in call' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:incatch_exceptions' c:/ruby/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons.rb:187:in run_proc' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/command.rb:71:inrun_process' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/command.rb:65:in daemonize' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/command.rb:63:intimes' c:/ruby/lib/ruby/gems/1.8/gems/delayed_job-2.0.3/lib/delayed/command.rb:63:in `daemonize' script/delayed_job:5 Without send_later it's working fine... Is there any solution?

    Read the article

  • Uploading images from Flex to Rails using Paperclip

    - by 23tux
    Hi everyone, I'm looking for a way to upload images that were created in my flex app to rails. I've tried to use paperclip, but it don't seem to work. I've got this tutorial here: http://blog.alexonrails.net/?p=218 The problem is, that they are using a FileReference to browse for files on the clients computer. They call the .upload(...) function and send the data to the upload controller. But I'm using a URLLoader to upload a image, that is modified in my Flex-App. First, here is the code from the tutorial: private function selectHandler(event:Event):void { var vars:URLVariables = new URLVariables(); var request:URLRequest = new URLRequest(uri); request.method = URLRequestMethod.POST; vars.description = "My Description"; request.data = vars; var uploadDataFieldName:String = 'filemanager[file]'; fileReference.upload(request, uploadDataFieldName); } I don't know how to set that var uploadDataFieldName:String = 'filemanager[file]'; in a URLLoader. I've got the image data compressed as a JPEG in a ByteArray. It looks like this: public function savePicture():void { var filename:String = "blubblub.jpg"; var vars:URLVariables = new URLVariables(); vars.position = layoutView.currentPicPosition; vars.url = filename; vars.user_id = 1; vars.comic_id = 1; vars.file_content_type = "image/jpeg"; vars.file_file_name = filename; var rawBytes:ByteArray = new JPGEncoder(75).encode(bitmapdata); vars.picture = rawBytes; var request:URLRequest = new URLRequest(Data.SERVER_ADDR + "pictures/upload"); request.method = URLRequestMethod.POST; request.data = vars; var loader:URLLoader = new URLLoader(request); loader.addEventListener(Event.COMPLETE, savePictureHandler); loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandlerUpload); loader.load(request); } If I set the var.picture URLVariable to the bytearray, then I get the error, that the upload is nil. Here is the Rails part: Picture-Model: require 'paperclip' class Picture < ActiveRecord::Base # relations from picture belongs_to :comic belongs_to :user has_many :picture_bubbles has_many :bubbles, :through => :picture_bubbles # attached file for picture upload -> with paperclip plugin has_attached_file :file, :path => "public/system/pictures/:basename.:extension" end and the picture controller with the upload function: class PicturesController < ApplicationController protect_from_forgery :except => :upload def upload @picture = Picture.new(params[:picture]) @picture.position = params[:position] @picture.comic_id = params[:comic_id] @picture.url = params[:url] @picture.user_id = params[:user_id] if @picture.save render(:nothing => true, :status => 200) else render(:nothing => true, :status => 500) end end end Does anyone know how to solve this problem? thx, tux

    Read the article

  • Using Bundle and Intent with TabHost

    - by apesa
    I am using TabHost with 3 tabs. I need to pass the params selected from one screen using Bundle and / or Intent to the next and then set the correct tab in TabHost and pass those params to the correct tab. I hope that makes sense. I have a config screen that has several radio buttons that are grouped and 1 checkbox and a button. in my onClick() I have the following code. public class Distribute extends Activity implements OnClickListener { DistributionMap gixnav; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView textview = new TextView(this); textview.setText("Distribution"); setContentView(R.drawable.configup); Button button = (Button)findViewById(R.id.btn_configup1); button.setOnClickListener(this); } public void onClick(View v) { Intent intent; Bundle extras = new Bundle(); intent = new Intent().setClass(getApplicationContext(), Clevel.class); intent.putExtras(extras); startActivity(intent); } } I need to pass the selection params (which radio button is selected and is the checkbox clicked to Clevel. In Clevel I have to parse the bundle and operate on those params. Basiclaly I will be pulling data froma DB and using that data to call google maps ItemizedOverlay. onClick calls Clevel.class using Intent. This works and I understand how Intent works. What I need to understand is how to grab or reference the selected radio button and whatever else may be clicked or checked and pass it through TabHost to the correct Tab. This is what I have in Clevel for TabHost. From TabHost the onCLick will need to pass everything to Distribute.class public class Clevel extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gixout1); Resources res = getResources(); TabHost tabHost = getTabHost(); TabHost.TabSpec spec; Intent intent; String mData; Bundle extras = getIntent().getExtras(); if (extras != null) { mData = extras.getString("key"); } intent = new Intent().setClass(this, ClevelMain.class); spec = tabHost.newTabSpec("Main").setIndicator("C-Level", res.getDrawable(R.drawable.gixmain)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, Distribute.class); spec = tabHost.newTabSpec("Config").setIndicator("Distribute", res.getDrawable(R.drawable.gixconfig)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, DistributionMap.class); spec = tabHost.newTabSpec("Nav").setIndicator("Map", res.getDrawable(R.drawable.gixnav)) .setContent(intent); tabHost.addTab(spec); tabHost.setCurrentTab(3); tabHost.getOnFocusChangeListener(); } I am really looking for some pointers on how to pass and use params in Bundle and whether in should use Bundle and Intent or can I just use Intent? Thanks in advance, Pat

    Read the article

  • (PHP) User is being forced to RE-LOGIN after trying to do something on an admin page

    - by hatorade
    I have created an admin panel for a client in PHP, which requires a login. Here is the code at the top of the admin page requiring the user to be logged in: admin.php <?php session_start(); require("_lib/session_functions.php"); require("_lib/db.php"); db_connect(); //if the user has not logged in if(!isLoggedIn()) { header('Location: login_form.php'); die(); } ?> Obviously, the if statement is what catches them and forces them to log in. Here is the code on the resulting login page: login_form.php <form name="login" action="login.php" method="post"> Username: <input type="text" name="username" /> Password: <input type="password" name="password" /> <input type="submit" value="Login" /> </form> Which posts info to this controller page: login.php <?php session_start(); //must call session_start before using any $_SESSION variables include '_lib/session_functions.php'; $username = $_POST['username']; $password = $_POST['password']; include '_lib/db.php'; db_connect(); // Connect to the DB $username = mysql_real_escape_string($username); $query = "SELECT password, salt FROM users WHERE username = '$username';"; $result = mysql_query($query); if(mysql_num_rows($result) < 1) //no such user exists { header('Location: login_form.php?login=fail'); die(); } $userData = mysql_fetch_array($result, MYSQL_ASSOC); db_disconnect(); $hash = hash('sha256', $password . $userData['salt']); if($hash != $userData['password']) //incorrect password { header('Location: login_form.php?login=fail'); die(); } else { validateUser(); //sets the session data for this user } header('Location: admin.php'); ?> and the session functions page that provides login functions contains this: session_functions.php <?php function validateUser() { session_regenerate_id (); //this is a security measure $_SESSION['valid'] = 1; $_SESSION['userid'] = $username; } function isLoggedIn() { if($_SESSION['valid']) return true; return false; } function logout() { $_SESSION = array(); //destroy all of the session variables if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"] ); } session_destroy(); } ?> I grabbed the sessions_functions.php code of an online tutorial, so it could be suspicious. Any ideas why the user logs in to the admin panel, tries to do something, is forced to re-login, and THEN is allowed to do stuff like normal in the admin panel?

    Read the article

  • How to access Hibernate session from src folder?

    - by firnnauriel
    I would like to know how to access the Service and Domains properly in this sample class placed in src/java folder public class NewsIngestion implements Runnable { private String str; private int num; private Logger log = Logger.getLogger("grails.app"); private static boolean isRunning; private Thread t; private WorkerJobService jobService; private NewsService newsService; public NewsIngestion(String s, int n) { jobService = new WorkerJobService(); newsService = new NewsService(); str = s; num = n; isRunning = false; t = new Thread (this, "NewsIngestion"); } public void run () { while(isRunning){ try{ if(jobService.isJobEnabled("ConsumeFeedsJob") && jobService.lockJob("ConsumeFeedsJob")){ log.info("${this.class.name}: ConsumeFeedsJob started"); try{ // get all sources List sources = (List) InvokerHelper.invokeMethod(RSSFeed.class, "list", null); for(int i = 0; i < sources.size(); i++) { RSSFeed s = (RSSFeed) sources.get(i); // check if it's time to read the source int diff = DateTimeUtil.getSecondsDateDiff(s.getLastChecked(), new Date()); if(s.getLastChecked() == null || diff >= s.getCheckInterval()){ List keyword_list = (List) InvokerHelper.invokeMethod(Keyword.class, "list", null); for(int j = 0; j < keyword_list.size(); j++) { String keyword = (String) keyword_list.get(j); try{ newsService.ingestNewsFromSources(keyword, s); }catch(Exception e){ log.error("${this.class.name}: ${e}"); } log.debug("Completed reading feeds for ${keyword}."); log.info("${this.class.name}: Reading feeds for '${keyword}' (${s.feedName}) took ${Float.toString(st2.getDuration())} second(s)."); } s.setLastChecked(new Date()); InvokerHelper.invokeMethod(RSSFeed.class, "save", null); } log.info("${this.class.name}: Reading feeds for '${s.feedName}' for all keywords took ${Float.toString(st.getDuration())} second(s)."); } }catch(Exception e){ log.error("${this.class.name}: Exception: ${e}"); } log.info("${this.class.name}: ConsumeFeedsJob ended."); // unlock job jobService.unlockJob("ConsumeFeedsJob"); } log.info("alfred: success"); } catch (Exception e){ log.info("alfred exception: " + e.getMessage()); } try { Thread.sleep(5000); } catch (InterruptedException e) { log.info(e.getMessage()); } } } public void start() { if(t == null){ t = new Thread (this, "NewsIngestion"); } if(!isRunning){ isRunning = true; t.start(); } } public void stop() { isRunning = false; } public boolean isRunning() { return isRunning; } } I'm encountering this error message: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here Thanks.

    Read the article

  • PHP script causes segmentation fault then the browser asks me to download the .php file with nothing in it?

    - by John
    I've noticed an unusual problem with some of my php programs. Sometimes when visiting a page like profile.edit.php, the browser throws a dialogue box asking to download profile.edit.php page. When I download it, there's nothing in the file. profile.edit.php is supposed to be a web form that edits user information. I've noticed this on some of my other php pages as well. I look in my apache error logs, and I see a segmentation fault message: [Mon Mar 08 15:40:10 2010] [notice] child pid 480 exit signal Segmentation fault (11) And also, the issue may or may not appear depending on which server I deploy my application too. Additonal Details This doesn't happen all the time though. It only happens sometimes. For example, profile.edit.php will load properly. But as soon as I hit the save button (form action="profile.edit.php?save=true"), then the page asks me to download profile.edit.php. Could it be that sometimes my php scripts consume too much resources? Sample code Upon save action, my profile.edit.php includes a data_access_object.php file. I traced the code in data_access_object.php to this line here if($params[$this->primaryKey]) { $q = "UPDATE $this->tableName SET ".implode(', ', $fields)." WHERE ".$this->primaryKey." = ?$this->primaryKey"; $this->bind($this->primaryKey, $params[$this->primaryKey], $this->tblFields[$this->primaryKey]['mysqlitype']); } else { $q = "INSERT $this->tableName SET ".implode(', ', $fields); } // Code executes perfectly up to this point // echo 'print this'; exit; // if i uncomment this line, profile.edit.php will actually show 'print this'. If I leave it commented, the browser will ask me to download profile.edit.php if(!$this->execute($q)){ $this->errorSave = -3; return false;} // When I jumped into the function execute(), every line executed as expected, right up to the return statement. And if it helps, here's the function execute($sql) in data_access_object.php function execute($sql) { // find all list types and explode them // eg. turn ?listId into ?listId0,?listId1,?listId2 $arrListParam = array_bubble_up('arrayName', $this->arrBind); foreach($arrListParam as $listName) if($listName) { $explodeParam = array(); $arrList = $this->arrBind[$listName]['value']; foreach($arrList as $key=>$val) { $newParamName = $listName.$key; $this->bind($newParamName,$val,$this->arrBind[$listName]['type']); $explodeParam[] = '?'.$newParamName; } $sql = str_replace("?$listName", implode(',',$explodeParam), $sql); } // replace all ?varName with ? for syntax compliance $sqlParsed = preg_replace('/\?[\w\d_\.]+/', '?', $sql); $this->stmt->prepare($sqlParsed); // grab all the parameters from the sql to create bind conditions preg_match_all('/\?[\w\d_\.]+/', $sql, $matches); $matches = $matches[0]; // store bind conditions $types = ''; $params = array(); foreach($matches as $paramName) { $types .= $this->arrBind[str_replace('?', '', $paramName)]['type']; $params[] = $this->arrBind[str_replace('?', '', $paramName)]['value']; } $input = array('types'=>$types) + $params; // bind it if(!empty($types)) call_user_func_array(array($this->stmt, 'bind_param'), $input); $stat = $this->stmt->execute(); if($GLOBALS['DEBUG_SQL']) echo '<p style="font-weight:bold;">SQL error after execution:</p> ' . $this->stmt->error.'<p>&nbsp;</p>'; $this->arrBind = array(); return $stat; }

    Read the article

  • Fill container with template parameters

    - by phlipsy
    I want to fill the template parameters passed to a variadic template into an array with fixed length. For that purpose I wrote the following helper function templates template<typename ForwardIterator, typename T> void fill(ForwardIterator i) { } template<typename ForwardIterator, typename T, T head, T... tail> void fill(ForwardIterator i) { *i = head; fill<ForwardIterator, T, tail...>(++i); } the following class template template<typename T, T... args> struct params_to_array; template<typename T, T last> struct params_to_array<T, last> { static const std::size_t SIZE = 1; typedef std::array<T, SIZE> array_type; static const array_type params; private: void init_params() { array_type result; fill<typename array_type::iterator, T, head, tail...>(result.begin()); return result; } }; template<typename T, T head, T... tail> struct params_to_array<T, head, tail...> { static const std::size_t SIZE = params_to_array<T, tail...>::SIZE + 1; typedef std::array<T, SIZE> array_type; static const array_type params; private: void init_params() { array_type result; fill<typename array_type::iterator, T, last>(result.begin()); return result; } }; and initialized the static constants via template<typename T, T last> const typename param_to_array<T, last>::array_type param_to_array<T, last>::params = param_to_array<T, last>::init_params(); and template<typename T, T head, T... tail> const typename param_to_array<T, head, tail...>::array_type param_to_array<T, head, tail...>::params = param_to_array<T, head, tail...>::init_params(); Now the array param_to_array<int, 1, 3, 4>::params is a std::array<int, 3> and contains the values 1, 3 and 4. I think there must be a simpler way to achieve this behavior. Any suggestions? Edit: As Noah Roberts suggested in his answer I modified my program like the following: I wrote a new struct counting the elements in a parameter list: template<typename T, T... args> struct count; template<typename T, T head, T... tail> struct count<T, head, tail...> { static const std::size_t value = count<T, tail...>::value + 1; }; template<typename T, T last> stuct count<T, last> { static const std::size_t value = 1; }; and wrote the following function template<typename T, T... args> std::array<T, count<T, args...>::value> params_to_array() { std::array<T, count<T, args...>::value> result; fill<typename std::array<T, count<T, args...>::value>::iterator, T, args...>(result.begin()); return result; } Now I get with params_to_array<int, 10, 20, 30>() a std::array<int, 3> with the content 10, 20 and 30. Any further suggestions?

    Read the article

  • How to Correct & Improve the Design of this Code?

    - by DaveDev
    HI Guys, I've been working on a little experiement to see if I could create a helper method to serialize any of my types to any type of HTML tag I specify. I'm getting a NullReferenceException when _writer = _viewContext.Writer; is called in protected virtual void Dispose(bool disposing) {/*...*/} I think I'm at a point where it almost works (I've gotten other implementations to work) and I was wondering if somebody could point out what I'm doing wrong? Also, I'd be interested in hearing suggestions on how I could improve the design? So basically, I have this code that will generate a Select box with a number of options: // the idea is I can use one method to create any complete tag of any type // and put whatever I want in the content area <% using (Html.GenerateTag<SelectTag>(Model, new { href = Url.Action("ActionName") })) { %> <%foreach (var fund in Model.Funds) {%> <% using (Html.GenerateTag<OptionTag>(fund)) { %> <%= fund.Name %> <% } %> <% } %> <% } %> This Html.GenerateTag helper is defined as: public static MMTag GenerateTag<T>(this HtmlHelper htmlHelper, object elementData, object attributes) where T : MMTag { return (T)Activator.CreateInstance(typeof(T), htmlHelper.ViewContext, elementData, attributes); } Depending on the type of T it'll create one of the types defined below, public class HtmlTypeBase : MMTag { public HtmlTypeBase() { } public HtmlTypeBase(ViewContext viewContext, params object[] elementData) { base._viewContext = viewContext; base.MergeDataToTag(viewContext, elementData); } } public class SelectTag : HtmlTypeBase { public SelectTag(ViewContext viewContext, params object[] elementData) { base._tag = new TagBuilder("select"); //base.MergeDataToTag(viewContext, elementData); } } public class OptionTag : HtmlTypeBase { public OptionTag(ViewContext viewContext, params object[] elementData) { base._tag = new TagBuilder("option"); //base.MergeDataToTag(viewContext, _elementData); } } public class AnchorTag : HtmlTypeBase { public AnchorTag(ViewContext viewContext, params object[] elementData) { base._tag = new TagBuilder("a"); //base.MergeDataToTag(viewContext, elementData); } } all of these types (anchor, select, option) inherit from HtmlTypeBase, which is intended to perform base.MergeDataToTag(viewContext, elementData);. This doesn't happen though. It works if I uncomment the MergeDataToTag methods in the derived classes, but I don't want to repeat that same code for every derived class I create. This is the definition for MMTag: public class MMTag : IDisposable { internal bool _disposed; internal ViewContext _viewContext; internal TextWriter _writer; internal TagBuilder _tag; internal object[] _elementData; public MMTag() {} public MMTag(ViewContext viewContext, params object[] elementData) { } public void Dispose() { Dispose(true /* disposing */); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (!_disposed) { _disposed = true; _writer = _viewContext.Writer; _writer.Write(_tag.ToString(TagRenderMode.EndTag)); } } protected void MergeDataToTag(ViewContext viewContext, object[] elementData) { Type elementDataType = elementData[0].GetType(); foreach (PropertyInfo prop in elementDataType.GetProperties()) { if (prop.PropertyType.IsPrimitive || prop.PropertyType == typeof(Decimal) || prop.PropertyType == typeof(String)) { object propValue = prop.GetValue(elementData[0], null); string stringValue = propValue != null ? propValue.ToString() : String.Empty; _tag.Attributes.Add(prop.Name, stringValue); } } var dic = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); var attributes = elementData[1]; if (attributes != null) { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(attributes)) { object value = descriptor.GetValue(attributes); dic.Add(descriptor.Name, value); } } _tag.MergeAttributes<string, object>(dic); _viewContext = viewContext; _viewContext.Writer.Write(_tag.ToString(TagRenderMode.StartTag)); } } Thanks Dave

    Read the article

  • pass arraylist bean from android to webservice php

    - by user1547432
    i'm newbie in android with web service i'm trying to pass arraylist from android to webservice php server here's my bean code: public class ExpressionBean { public static final String EXPRESSION_ID = "expressionID"; public static final String EXPRESSION_TEXT = "expressionText"; public static final String ANS_TEXT1 = "ansText1"; public static final String ANS_TEXT2 = "ansText2"; public static final String ASSESSEE_ANSWER = "assesseeAnswer"; private String expressionID; private String expressionText; private String ansText1; private String ansText2; private String assesseeAnswer; public String getExpressionID() { return expressionID; } public void setExpressionID(String expressionID) { this.expressionID = expressionID; } public String getExpressionText() { return expressionText; } public void setExpressionText(String expressionText) { this.expressionText = expressionText; } public String getAnsText1() { return ansText1; } public void setAnsText1(String ansText1) { this.ansText1 = ansText1; } public String getAnsText2() { return ansText2; } public void setAnsText2(String ansText2) { this.ansText2 = ansText2; } public String getAssesseeAnswer() { return assesseeAnswer; } public void setAssesseeAnswer(String assesseeAnswer) { this.assesseeAnswer = assesseeAnswer; } } and here's my doInBackround on async task : protected Boolean doInBackground(Void... params) { // TODO: attempt authentication against a network service. boolean result = false; // test = new TestBean(); // int resultTest = 0; UserFunctions userFunction = new UserFunctions(); Log.d(TAG, "UID : " + mEmail); // Log.d(TAG, "resultTest : " + resultTest); JSONObject jsonTest = userFunction.storeTest(mEmail); Log.d(TAG, "After JSON TEST "); try { if (jsonTest.getString(KEY_SUCCESS) != null) { String res = jsonTest.getString(KEY_SUCCESS); JSONObject testData = jsonTest.getJSONObject(TAG_TEST); test = new TestBean(); test.setTestid(testData.getInt(TAG_TEST_ID)); test.setUid(testData.getInt(TAG_UID)); JSONArray list = new JSONArray(); String list2; for (int position = 0; position < expressionList.size(); position++) { Gson gson = new Gson(); list.put(gson.toJson(expressionList.get(position))); } Log.d(TAG, "JSONArray list coy : " + list); UserFunctions uf = new UserFunctions(); JSONObject jsonHistoryList = new JSONObject(); jsonHistoryList = uf.storeHistoryList(list.toString()); if (Integer.parseInt(res) == 1) { result = true; finish(); } else { result = false; } } } catch (JSONException e) { e.printStackTrace(); return false; } // TODO: register the new account here. return result; } and here's storeHistoryList Method : public JSONObject storeHistoryList(String list) { // Building Parameters List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("tag", storeHistory_tag)); params.add(new BasicNameValuePair("list", list)); JSONObject json = jsonParser.getJSONFromUrl(URL, params); return json; } i want to pass list to web service list is an arraylist ExpressionBean i used gson for convert bean to json but when i execute, the log said "error parsing data... jsonarray cannot be converted to jsonobject what i must to do? thanks

    Read the article

  • DisplayObject not being displayed in AS3

    - by MarkSteve
    I have this class: public class IskwabolText extends Sprite { private var _tf:TextField; private var _tfmt:TextFormat; private var _size:Number; private var _text:String; public function IskwabolText(params:Object) { var defaultParams:Object = { color: 0x000000, background: false, backgroundColor: 0xFFFFFF, width: 0, height: 0, multiline: false, wordWrap: false }; // textfield _tf = new TextField(); _tf.antiAliasType = 'advanced'; _tf.embedFonts = true; _tf.type = 'dynamic'; _tf.selectable = false; // textformat _tfmt = new TextFormat(); set(defaultParams); set(params); } public function get(param:String):Object { switch (param) { case 'size': return _tfmt.size; case 'text': return _tf.text; case 'font': return _tfmt.font; case 'color': return _tfmt.color; case 'background': return _tf.background; case 'backgroundColor': return _tf.backgroundColor; case 'width': return _tf.width; case 'height': return _tf.height; case 'multiline': return _tf.multiline; case 'wordWrap': return _tf.multiline; default: return this[param]; } return null; } public function set(params:Object):Object { for (var i:String in params) { setParam(i, params[i]); } redraw(); return this; } private function setParam(param:String, value:Object):Object { switch (param) { case 'size': _tfmt.size = new String(value); break; case 'text': _tf.text = new String(value); break; case 'font': _tfmt.font = new String(value); break; case 'color': _tfmt.color = new uint(value); break; case 'background': _tf.background = new Boolean(value); break; case 'backgroundColor': _tf.backgroundColor = new uint(value); break; case 'width': _tf.width = new Number(value); break; case 'height': _tf.height = new Number(value); break; case 'multiline': _tf.multiline = new Boolean(value); break; case 'wordWrap': _tf.multiline = new Boolean(value); break; default: this[param] = value; break; } return this; } private function redraw():void { _tf.setTextFormat(_tfmt); if (contains(_tf)) removeChild(_tf); if (_tf.width == 0) _tf.width= _tf.textWidth+5; _tf.height = _tf.textHeight; addChild(_tf); } } But when I do this: public class Main extends Sprite { public function Main() { addChild(new IskwabolText({ size: 100, text: 'iskwabol', font: 'Default', // this is properly embedded color: 0x000000, x: stage.stageWidth / 2 - this.width / 2, y: 140 })); } } The child IskwabolText doesn't get displayed. What happening?

    Read the article

  • How to automatically resize an EditText widget (with some attributes) in a TableLayout

    - by steff
    Hi everyone, I have a layout issue. What I do is this: create TableLayout in xml with zero children: <TableLayout android:id="@+id/t_layout_contents" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/l_layout_tags" android:stretchColumns="1" android:paddingLeft="5dip" android:paddingRight="5dip" /> Insert first row programmatically in onCreate(): tLayoutContents = (TableLayout)findViewById(R.id.t_layout_contents); NoteElement nr_1 = new NoteElement(this); tLayoutContents.addView(nr_1); Class "NoteElement" extends TableRow. The 1st row just consists of a blank ImageView as a placeholder and an EditText to enter text. NoteElement's constructor looks like this: public NoteElement(Context c) { super(c); this.context = c; defaultText = c.getResources().getString(R.string.create_note_help_text); imageView = new ImageView(context); imageView.setImageResource(android.R.color.transparent); LayoutParams params = new LayoutParams(0); imageView.setLayoutParams(params); addView(imageView); addView(addTextField()); } Method addTextField() specifies the attributes for the EditText widget: private EditText addTextField() { editText = new EditText(context); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); editText.setMinLines(4); editText.setRawInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); editText.setHint(R.string.create_note_et_blank_text); editText.setAutoLinkMask(Linkify.ALL); editText.setPadding(5, 0, 0, 0); editText.setGravity(Gravity.TOP); editText.setVerticalScrollBarEnabled(true); LayoutParams params = new LayoutParams(1); editText.setLayoutParams(params); return editText; } So far, so good. But my problem occurs as soon as the available space for the chars is depleted. The EditText does not resize itself but switches to a single line EditText. I am desperatly looking for a way in which the EditText resizes itself in its height dynamically, being dependant on the inserted text length. Does anyone have a hint on this? Thanks & regards, steff

    Read the article

  • MP4box "moov atom"

    - by user293376
    Hi Iam using MP4box to "moov atom" on a mp4 file. Its working trough the terminal but not when iam using php5. $params = "MP4Box -inter 500 $outputUrl"; exec($params,$resultArray,$result); Result: Saving /assets/files/cf017537a51129cd773ae9e15fcaf93c.mp4: 0.500 secs Interleavi ng Any ideas?

    Read the article

  • how to use SQL wildcard % with Queryset extra>select?

    - by tylias
    I'm trying to add weights to search terms I'm using to filter a queryset. Using the '%' wildcard is causing me some problems. I'm using the extra() modifier to add a weight parameter to the queryset, which I will be using to inform a sort ordering. (See http://docs.djangoproject.com/en/1.1/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none ) Here's the gist of the code: def viewname(request) ... exact_matchstrings="" exact_matchstrings.append("(accountprofile.first_name LIKE '" + term + "')") exact_matchstrings.append("(accountprofile.first_name LIKE '" + term + '\%' + "')") extraquerystring = " + ".join(exact_matchstrings) return_queryset = return_queryset.extra( select = { 'match_weight': extraquerystring }, ) The effect I'm going for is that if the search term matches exactly, the weight associated with the record is 2, but if the term merely starts with the search term and isn't an exact match, the weight is 1. (for example, if 'term' = 'Jon', an entry with first_name='Jon' gets a weight of 2 but an entry with an entry with first_name = 'Jonathan' gets a weight of 1.) I can test the statement in SQL and it seems to work well enough. If I make this SQL query from the mysql shell, no problem: select (first_name like "Carl") + (first_name like "Car%") from accountprofile; But trying to run it via the extra() modifier in my view code and evaluating the resulting queryset gives me the following error: Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 68, in __repr__ data = list(self[:REPR_OUTPUT_SIZE + 1]) File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 83, in __len__ self._result_cache.extend(list(self._iter)) File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 238, in iterator for row in self.query.results_iter(): File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py", line 287, in results_iter for rows in self.execute_sql(MULTI): File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py", line 2369, in execute_sql cursor.execute(sql, params) File "/usr/local/lib/python2.6/dist-packages/django/db/backends/util.py", line 22, in execute sql = self.db.ops.last_executed_query(self.cursor, sql, params) File "/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", line 217, in last_executed_query return smart_unicode(sql) % u_params ValueError: unsupported format character ''' (0x27) at index 309 I've tried it escaping and not escaping % wildcard but that doesn't solve the problem. Doesn't seem to affect it at all, really. Any ideas?

    Read the article

  • Is there a goto statement in java?

    - by Venkats
    I'm confused about this. Most of us have been told that there is no goto statement in Java. But I found that it is one of the keyword in Java. Where can it be used? If it can not be used, then why was it included in Java as a keyword?

    Read the article

  • String formatting named parameters?

    - by Mark
    I know it's a really simple question, but I have no idea how to google it. how can I do print '<a href="%s">%s</a>' % (my_url) So that my_url is used twice? I assume I have to "name" the %s and then use a dict in the params, but I'm not sure of the proper syntax? just FYI, I'm aware I can just use my_url twice in the params, but that's not the point :)

    Read the article

  • Ruby On Rails Paths

    - by dweebsonduty
    I am having trouble with paths in ruby on rails My Routes: map.resources :companies do |company| company.resources :customers do |customer| customer.resources :jobs end end Currently I am creating the paths by hand: <td><%= link_to 'Show', "/companies/#{params[:company_id]}/users/#{user.id}" %></td> <td><%= link_to 'Edit', "/companies/#{params[:company_id]}/users/#{user.id}/edit" %></td> For some reason I cant figure out how to get new_company_user to work I keep getting errors. The routes are all there I just need help with dynamically creating them by using the API

    Read the article

  • Heroku Push Problem part 2 - Postgresql - PGError Relations does not exist - Ruby on Rails

    - by bgadoci
    Ok so got through my last problem with the difference between Postgresql and SQLite and seems like Heroku is telling me I have another one. I am new to ruby and rails so a lot of this stuff I can't decipher at first. Looking for a little direction here. The error message and PostsController Index are below. I checked my routes.rb file and all seems well there but I could be missing something. I will post if you need. Processing PostsController#index (for 99.7.50.140 at 2010-04-23 15:19:22) [GET] ActiveRecord::StatementInvalid (PGError: ERROR: relation "tags" does not exist : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"tags"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum ): PostsController#index def index @tag_counts = Tag.count(:group => :tag_name, :order => 'count_all DESC', :limit => 20) conditions, joins = {}, :votes @ugtag_counts = Ugtag.count(:group => :ugctag_name, :order => 'count_all DESC', :limit => 20) conditions, joins = {}, :votes @vote_counts = Vote.count(:group => :post_title, :order => 'count_all DESC', :limit => 20) conditions, joins = {}, :votes unless(params[:tag_name] || "").empty? conditions = ["tags.tag_name = ? ", params[:tag_name]] joins = [:tags, :votes] end @posts=Post.paginate( :select => "posts.*, count(*) as vote_total", :joins => joins, :conditions=> conditions, :group => "votes.post_id, posts.id ", :order => "created_at DESC", :page => params[:page], :per_page => 5) @popular_posts=Post.paginate( :select => "posts.*, count(*) as vote_total", :joins => joins, :conditions=> conditions, :group => "votes.post_id, posts.id", :order => "vote_total DESC", :page => params[:page], :per_page => 3) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } format.json { render :json => @posts } format.atom end end

    Read the article

  • Django CMS error when running project

    - by 47
    I'd set up a site a while back using Django-CMS and it was working fine. However, after upgrading to the latest version of both Django and Django-CMS, it doesn't work anymore...when I try to run the development server, I get this message: "Signal recerivers must accept keyword arguments (**kwargs)." AssertionError: Signal receivers must accept keyword arguments (**kwargs). What could be the problem here? I've tried running the sample app that comes with the CMS and it works just fine.

    Read the article

< Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >