w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Regasm in code (dynamic register)
You can to use the /regfile command line option to regasm, then execute the generated .reg file. I prefer using reg.exe import "%s" instead of regedit.exe, since it will avoid a popup. Or you can write your own .reg parser and update the registry, but it may be overcomplicated. Ensure every "CodeBase"="file://...." entry will be changed to expected (network) folder containing the COM .dll wrapper.

Categories : C#

Register OnClientItemSelected for a Dynamic AutoCompleteExtender
Moving the script to the code behind works when the static, 5-argument version of RegisterStartupScript is called. Provide the UserControl itself as the first parameter: string searchScript = "function " + this.aceItemSearch.ClientID + "_getByID(sender, e) { var hfield = $get('" + this.hfItemID.ClientID + "'); if (typeof hfield === 'undefined') return; var item = eval('(' + e._value + ')'); hfield.value = item.ID; if (typeof document != 'undefined') { var control = $get('" + this.btnSearch.ClientID + "'); } control.click(); }"; ScriptManager.RegisterStartupScript(this, this.GetType(), aceItemSearch.ClientID + "_getItemByID", searchScript, true);

Categories : Misc

PHP session variables taking a while to register change
Are you redirecting via a header('Location: ') call after setting these variables? As wrikken has suggested, you should call session_write_close() before your redirect. In addition to this, after your redirect ensure that you call exit; e.g. header('Location: newurl.php'); exit; Otherwise your original page will continue processing.

Categories : PHP

Register Javascript to Dynamic Nested Collapsible
As the comment was useful and you probably have found the solution based on it, I'm putting it as an answer. You can attach the click event handler out of the block where you generate the collapsible. This way all the future items will be covered automatically: ie: // Select all divs which id starts with... $("div[id^='collapsible_PG']").on("click", function () { // $(this) here will refer to the exactly element clicked onexpand($(this)); }); $('#tdDynamic').append('<div id="collapsible_PG' + i + '" data-role="collapsible" data-collapsed="true" data-theme="e" data-content-theme="c"></div>');

Categories : Javascript

GCM (Google cloud messaging) - can I register multiple devices with same register id?
No. Moreover, you should not need to. You can use user notifications to be able to send a single message from the server to all instances of your app across all the user's devices.

Categories : Android

Microarchitectural zeroing of a register via the register renamer: performance versus a mov?
Executive summary: You can run up to four xor ax, ax instructions per cycle as compared to the slower mov immediate, reg instructions. Details and references: Wikipedia has a nice overview of register renaming in general: http://en.wikipedia.org/wiki/Register_renaming Torbj¨orn Granlund's timings for instruction latencies and throughput for AMD and Intel x86 processors are at: http://gmplib.org/~tege/x86-timing.pdf Agner Fog nicely covers the specifics in his Micro-architecture study: 8.8 Register allocation and renaming Register renaming is controlled by the register alias table (RAT) and the reorder buffer (ROB) ... The µops from the decoders and the stack engine go to the RAT via a queue and then to the ROB-read and the reservation station. The RAT can handle 4

Categories : Assembly

PHP variables in dynamic CSS
I believe the problem is not what you're describing. So long as style.php is accessed via http, then the $_SERVER variables will be set. There is, however, some syntax error in the code you described: if($url == "this") $style = "blue"; else( $style = "red"; ) // Incorrect syntax The right way to write that would be: if ($url == "this") { // $url will _never_ be "this" $style = "blue"; } else { $style = "red"; } Edit: There's some funky code when evaluating the MySQL results: $row_rsTheme = mysql_fetch_assoc($rsTheme); $totalRows_rsTheme = mysql_num_rows($rsTheme); if($totalRows_rsTheme == 1){ // sucessful match, but ONLY if there's only one row ... } You should replace it with: if($row_rsTheme = mysql_fetch_assoc($rsTheme)){ // sucessful match ... } That way

Categories : PHP

dynamic variables in preg_replace in PHP
/[(.*)]/ does not escape the [ or ], and would match essentially everything if it did. Use /[(.*?)]/. Additionally, you need to strtolower the matched inner value. $template = "[FIRSTNAME] say hello to [NAME]"; $replacements = array( 'user_name' => 'myname', 'user_firstname' => 'myfirstname', ); $result['texte'] = preg_replace_callback('/[(.*?)]/', function ($match) use ($replacements) { return $replacements["user_" . strtolower($match[1])]; }, $template)

Categories : PHP

Dynamic variables in perl
If I understand you correctly, you need to locally override a global variable inside a function. package my_package; our $verbose = 0; sub function { my ($arg1, $arg2) = @_; # getting function arguments. local $verbose = $arg1; } It will restore old state of $verbose on return.

Categories : Perl

Why does this mathematical operation work? (Getting 8-bit register from 32-bit register)
"mod 256" is the remainder after division by 256. In binary, this turns out to be the lowest 8 bits (because 256 is 2 to the 8th). This is just like "mod 2" gives you the least significant bit (0 or 1). On (in decimal, base 10), "mod 100" gives you the last two decimals ( 2013 mod 100 => 13).

Categories : Assembly

Why simply use PHP variables for dynamic stylesheets?
Am I overlooking some serious problems by doing it this way? I host all static assets on a CDN, which you should too. CDNs don't do PHP. Also: caching, runtime performance, minification

Categories : PHP

less css calling dynamic variables from a loop
Why don't you use them in your CSS file? Why are you trying them in your File? its not a great idea. Using the CSS for each DIV will be good. Give it a class with the code Like: <div class='@if(condition == true) {"thisclass"} else {"thatclass"}'></div> And just use one CSS for all the conditions. That would be simple.

Categories : CSS

Dynamic Charts with Variables on Two Axes
I couldn't get this to work either, using the SERIES formula. Then again, I suppose it is considered an undocumented feature. However, if you edit using the Select Data dialog then it works.

Categories : Excel

JS: Storing dynamic variables across pages?
Welcome to stackoverflow! I don't really know about those plugins, but at the low level they are probably using localStorage or sessionStorage (that I think is better for your problem, as it gets cleared everytime you restart the browser, opposed to localStorage, that is permanent unless the user clears it). Your problem has a pretty easy solution, although I don't understand it fully without seeing a little code. But more or less I'd recommend you to, as you dynamically generate the fields, pre-fill them with values stored upon submitting, that is (assuming you use jquery): function generateFields(index) { $("<input/>") .attr("id","username_"+index) .val(getFieldValue("username_"+index)) .change(function() { setFieldValue("user

Categories : Javascript

Retrieve object variables with dynamic key strings
Replace this : $desiredKeyArrayPart = "[courses][lessons][lesson_name_required]"; $desiredKeyAttributePart = "required"; $desiredKey = $desiredKeyAttributePart . $desiredKeyArrayPart; // Get the value (Should return 1) $desiredValue = $myObj->$desiredKey; By this : $desiredValue = $myObj->required['courses']['lessons']['lesson_name_required']; The way you were trying to do it will not work. Also, quoting the array values is preferable to avoid warnings.

Categories : PHP

Golang dynamic amount of bind variables
Your second attempt was close to success. Build a, say var foo []interface{} containing all arguments and pass it as Bind(foo...) See also Passing arguments to ... parameters

Categories : Mysql

MySQL Join two tables with dynamic variables
You have things all over the place, I haven't tested this but it should work ... SELECT * FROM (SELECT *, MATCH(name) AGAINST('*McDonalds*' IN BOOLEAN MODE) AS `score_name_0`, MATCH(`city`) AGAINST('McDonalds*' IN BOOLEAN MODE) AS `score_city_0`, (3959 * acos(cos( radians(".$lat.")) * cos(radians(pinpoints.lat)) * cos(radians(pinpoints.lng) - radians(".$long.")) + sin( radians(".$lat.")) * sin(radians(pinpoints.lat)))) AS distance FROM `stores` JOIN pinpoints ON stores.id=pinpoints.id WHERE stores.id=pinpoints.id AND (MATCH(name) AGAINST('*McDonalds*' IN BOOLEAN MODE) OR MATCH (`city`) AGAINST('McDonalds*' IN BOOLEAN MODE)) ) AS tmp_tbl WHERE distance < 25 ORDER BY distance ASC, (`score_namn_0` + `score_s

Categories : PHP

Using dynamic variables to pass in custom objects
I see you're only using the ToString() method of a element. Why not pass a IEnumerable< string> into it? public void pageCheck(SiteData site, IEnumerable<string> pageObj, int lowAssignedScore, int highAssignedScore, int totalScore) Usage: pageCheck(site, page.H1s.Select(item => item.ToString()), 4, 6, totalScore); pageCheck(site, page.AltTags.Select(item => item.ToString()), 4, 6, totalScore); I'll always try to avoid dynamics, unless there's no other option.

Categories : C#

How do I create a dynamic list of variables for a GAE datastore query?
for i in range(1, fup + 1): i = str(i) followup = 'fu' + i + '_email_sent' fuemailsent_list.append(followup) fu_check = part.followup Means you are trying to access an attribute called 'followup'. with line fu_check = part.followup. To use the name stored in the variable followup use getattr fu_check = getattr(part,followup)

Categories : Google App Engine

Passing in Dynamic Number of "Variables" to Datomic API Functions
Ok, I got this solved over on the Datomic Google Groups (see here). Basically, fig.1 works. And also, I'm able to run the generated code (fig.2) without the dreaded quoting. Hope this helps others. (datomic.api/q '{:find [?e] :in [$ [?title ?content-type]] :where [[?e :posts/title ?title] [?e :posts/content-type ?content-type]]} (datomic.api/db conn) ["t" "c/t"]) fig.1 (datomic.api/q expression-intermediate-0 (datomic.api/db conn) (into [] param-values)) fig.2

Categories : Clojure

Rails dynamic routing to different instance variables of controller
your link is not redirecting to your instance, its redirecting to your action. so you have to define a new method for new link_to that, and define your @men_clothing_tshirt object in that method like this: def your_method @men_clothing_tshirt=Category.find_by_name("clothes").sub_categories.find_by_name("t-shirt").products end and in your link_to redirect to your_method: link_to "Tshirt", your_method_path Hope it will help.Thanks

Categories : Ruby On Rails

Dynamic method creation - define_singleton_method not using expected variables
Solution You need to create a copy of the frame object before manipulating it in in_frame. def in_frame(identifier, frame=[], &block) frame = frame.dup << identifier block.call(frame) end Explanation The behaviour you observe is perfectly valid, when you follow object identities. So let's follow the frame object on it's journey :) 1 def initialize 2 in_frame(:id => 'first_frame') do |frame| 3 add_method "bar", {:frames => frame} 4 in_frame({:id => 'second_frame'}, frame) do |frame| 5 #do absolutely nothing 6 end 7 end 8 end In line 1 we call in_frame with the arguments :id => 'first_frame', and implicitly frame=[]. Here frame is given birth as a new array to which :id => 'first_frame' is appended. At the beginning of line 3 our fr

Categories : Ruby

SHOW COLUMNS, Dynamic variables, INSERT INTO.. implode?
You should seriously think about changing your database structure. It is not a good idea to dynamically add columns to a table in a running database applcation. Your request is not an unusual one, but in most cases people solve the problem by having one column specifying the actual application and then a few more where they put in the information regarding the chosen application (in form of char, integer odr date fields). This has the advantage of keeping the table structure small and manageable but being very flexible at the same time. Tables with too many (mostly unused) columns are considered ugly or messy because they slow down your SQL server unnecessarily. So, maybe something like the following might help you: CREATE TABLE applications (apid int auto_increment PRIMARY KEY, apname

Categories : PHP

Dynamic Variables in Admin Tool in Ruby on Rails
You can use gsub to replace your wildcard with the actual content when you pull it out from the db. http://www.ruby-doc.org/core-1.9.3/String.html#method-i-gsub str = "{{location.title}} is a cool place" str.gsub!('{{location.title}}', 'foo') # "foo is a cool place"

Categories : Ruby On Rails

Dynamic LINQ to Entities, how to build query based on variables
If you only need AND logic you could just call .Where() repeatedly for every attribute that requires searching on. if(title != null) query = query.Where(x=>x.Title == title); if(genre != null) query = query.Where(x=>x.Genre == genre); If your query is always of a certain structure and you want to ignore null search values you could do one big query but short circuit the attribute comparison with null checks. query = query.Where(s => ( ((title1 == null || s.Title.Contains(title1)) && (episodeTitle1 == null || s.EpisodeTitle.Contains(episodeTitle1)) || ((title2 == null || s.Title.Contains(title2)) && (episodeTitle2 == null || s.EpisodeTitle.Contains(episodeTitle2)))) ); However if you need full control over the query the

Categories : C#

ColdFusion 10 CFCHART, how to pass dynamic variables via JavaScript API method?
You're passing a JSON string to handle.exec, which is turned into a JS object in a different place to where your x variable is defined, and thus causing the error. Instead, let x be resolved as part of the string and it should work: handle.exec( ... , '{"plotindex": 0, "values": ['+x+']}');

Categories : Javascript

Truncating table before dynamic SQL with looping variables inside of one function
CREATE OR REPLACE FUNCTION dwh.dim_table_notification() RETURNS void LANGUAGE plpgsql AS $func$ DECLARE myschema text; BEGIN -- truncate simply goes here: TRUNCATE dwh.prod_table_notify; FOR myschema IN SELECT quote_ident(table_schema) FROM information_schema.tables WHERE table_name IN ('dim_loan_type', 'dim_acct_type') AND table_schema NOT LIKE 'pg_%' AND table_schema NOT IN ('information_schema', 'ad_delivery', 'dwh', 'users', 'wand', 'ttd') ORDER BY table_schema LOOP EXECUTE ' INSERT INTO dwh.prod_table_notify (userid, acct_type_id, acct_type, acct_type_desc, loan_type) SELECT '''|| myschema ||''', loan_type_id, loan_type::varchar(10) , loan_type_desc::varchar(50), term_code, 1 AS loan_type FROM '|| myschem

Categories : SQL

Reference variables in a separate less file using SquishIt (support dynamic LESS content)?
You are right, SquishIt does the less processing before combining files. There is no way to do what you ask using only SquishIt, but I suppose you could combine the files on your own on the way in (use the .AddString method to add your resulting .less content to the bundle). One of the alternatives may suit your needs better, I'm not sure.

Categories : CSS

Reading dynamic/changing data from multiple threads without locks? Can it cause a crash? Or just corrupted variables?
Reading and writing to same data objects from multiple threads gives you Undefined Behavior and Undefined behavior does not mandate a crash, it simply means that the program can show any behavior. Simply put you cannot rely on the behavior to be consistent because it is simply not mandated as per the standard. The only safe way to access such a object will be to ensure: Atomic & synchronized accesses through locks

Categories : C++

AIX (KSH) Dynamic Variable Assignment - Split long string into multiple lines and assign each line to variables
You can create an array and then assign values. Something like: $ TEXT='LINE 1 LINE 2 LINE 3 LINE 4 LINE 5' $ echo "$TEXT" | fmt -w7 > myfile $ while IFS=$' ' read -r line; do export msg_txt_line_$((++x))="$line"; done <myfile $ echo "$msg_txt_line_1" LINE 1 Update: $ TEXT='LINE 1 LINE 2 LINE 3 LINE 4 LINE 5' $ echo "$TEXT" | fmt -w7 > myfile $ while IFS=$' ' read -r line; do export msg_txt_line_$((++x))="$line"; done <myfile $ echo "$msg_txt_line_1" LINE 1

Categories : Shell

Build Curl on vc9/vc11 with release dynamic library with dynamic ssl, ssh2 and dynamic zlib
The answer is: you can't What you should do is build curl with ssl, ssh2 and zlib internally using CFG=release-ssl-ssh2-zlib. Then use this patch to add the dlls to the link command. Note this patch is for VC10, but can easily be done on the vc9 makefile. After the builds, you will need to add libssh2.lib in to lincurl.lib, if you want to build something against it (say PHP). That can be done with this command (set the paths to the your libssh2.lib and libcurl.lib): lib.exe /OUT:libcurl_merged.lib libssh2.lib libcurl.lib copy libcurl_merged.lib libcurl.lib

Categories : Windows

jinja2 variables naming - Are variables naming restrictions the same as for Python variables?
Jinja's naming convention generally matches your python interpreter's identifiers. So it also depends on your Python version (2.x: like [a-zA-Z_][a-zA-Z0-9_]*) (source: #pocoo on irc.freenode.net)

Categories : Python

Limit of performance benefit gained in Python from using local variables instead of global variables?
As I understand it, that performance boost only applies when global variables are moved into a local scope of a function, as it improves their access time. Further breaking your code down into more functions won't provide any similar boost.

Categories : Python

How to save variables to a file so that those variables are loaded the next time the site runs?
You can use local storage or even cookies. local storage is your best bet, although it doesn't work in older browsers. cookies are (more) limited in their capacity (4KB vs 5MB for local storage) and also are sent to the server with each request, which may not be what you want. Alternatively, you can store the state on your server (you'll need some server side scripting as well), and only store a user/gamer id in a cookie.

Categories : Javascript

How to creating ctypes variables using python variables instead of hard-coded values?
The field attributes of a Structure are CField descriptor objects. A descriptor is like a Python property or like a __slots__ attribute, if you're familiar with either of those. A CField knows the data type of the field and its offset into the buffer. Each C data type has a associated get/set function that converts to and from Python objects. So generally you can assign a Python object directly to the field. For example: thresholds = [1, 0.9, 0.8, 0.7] c_parameters = Params( var1 = 100, var2 = 4, var3 = 5, var4 = 5000, var5 = "modelname", var6 = 0.5, var7 = 90, var8 = (C.c_double * 4)(*thresholds), var9 = 2, H = Good('H', 0.5, 100, 20), L = Good('L', 0.5, 75, 20), ) If ctypes needs to hold a reference to a Python object to keep it alive,

Categories : Python

Having problems using drop-down menu variables to create a table filled with these variables in PHP
Welcome to SO. $_POST['submit'] is not neccesary. In your PHP script, create the HTML for the table, and then <?php echo $num_1; ?> (or the others) where needed. The HTML must be outside the PHP code.

Categories : PHP

Time Dummy Variables and Regressing columns of a dataframe as dependent variables
You can create a list of stocks as follows and then use Map function and can avoid R for loop (Not tested since you didn't provide the sample data) Assume your data is mydata with month as 1,2, you use 11 months as dummy if there are 12 months mystock<-list("APP~","INTEL~","MICROSOFT~") # stocks with tilde sign myresi<-Map(function(x) resi(lm(as.formula(paste(x,paste(levels(as.factor(mydata$month))[-1],collapse="+"))),data=mydata),mystock) #-1 means we are using only 11 months excluding first as base month Say your independent var is indep1,indep2, and indep3 and dependent is dep (And assuming that dep and indep are same for each stocks) myestimate<-Map(function(x)lm(dep~indep1+indep2+indep3,data=x),myresi)

Categories : R

How to write a random generator function without using time functions, static variables or global variables?
do #include <time.h> #include <stdlib.h> srand(time(NULL)); int r = rand(); if you want to limit the number use int r = minNum + rand() % maxNum; do not try to create your own random function. it will not end well

Categories : C

Changing object variables in an array of instance variables in Ruby
class Cell attr_accessor :values @arrs = [] #Creates a "class instance variable" class <<self #Creates an accessor for the "class instance variable" attr_reader :arrs end def initialize(values) @values = values self.class.arrs << @values #Add the @values array to the "class instance variable" end end test_array = [1, 2, 3] @cells = test_array.map do |num| #Create the cells Cell.new(test_array.dup) end p @cells --output:-- [#<Cell:0x0000010085ffd8 @values=[1, 2, 3]>, #<Cell:0x0000010085ff88 @values=[1, 2, 3]>, #<Cell:0x0000010085ff60 @values=[1, 2, 3]>] @cells.each_with_index do |cell, i| #Change the last value of each cell's @values array cell.values[-1] = i end p Cell.arrs #Show all the @values arrays of

Categories : Ruby

Difference between variables inside the function and variables functioning as arguments in C++
You can't tell almost anything about a functions's performance only from its signature. I can write the fastest and the slowest functions you can imagine with either one of these signatures. In the second option you are adding a third parameter to the function. Do you need that parameter? If you need it, use that option. If you don't, use the first one.

Categories : C++



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.