w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Tween Multiple object turn by turn in tweenlite
Usually I'd do it like this: for (var i:int = 0; i < 5; i++) { TweenLite.to(object, duration, {delay: duration * i}); } It will create all the Tweens at once, but they won't really effect your performance since only the active tweens are really noticeable. I did that with over 200 objects and had no lag at all.You might however want to pool the TweenLite object on mobile platforms, but again - you probably won't see the difference up to 800+ objects.

Categories : Actionscript

How do I set a joda LocalDateTime object to a specified time with current and local daylight savings and time zone information in java
A LocalDateTime doesn't logically have any time zone or DST information. That's the whole point - it's "local" but not to any specific time zone. Two people in different time zones might both wake up at the same local date/time, but that doesn't mean they're the same instants. If you need a type which includes a time zone, you should be using DateTime. EDIT: Okay, one approach is to take "today in the local time zone", parse the time to a LocalTime, combine the two to form a LocalDateTime, convert that to a DateTime in UTC, then convert that DateTime to the local time zone instead. The difficulty is that the end dates may not be the same, in which case you may need to add or subtract a day. That could then change the time of day due to DST changes, which makes it harder still. There are

Categories : Java

Move/turn object in PyMOL
there is a good tutorial on pymol http://www.liv.ac.uk/~afcalder/apt1.html as it describes, and what I confirm, there are some commands like translate or rotate that can modify coordinates of the scene and particular objects when parameter object is given

Categories : Python

Turn float into string
If it is acceptable to print as 1.d1d2d3d4d5…*2^e1e2e3, then converting a floating-point number to decimal(-ish) representation can be simple. An implementation can be found here. If you need a scientific 1.d1d2…*10^e1e2e3 representation, then the naïve approach to repeatedly divide by 10 and extract digits from the number that you have in floating-point format. You will need some sort of multi-precision integer library. (Repeatedly multiply by 10 to extract the digits after the point.)

Categories : String

Turn my stack into a string?
Use a StringBuilder to handle the toString creation. A template you could use is public String toString(){ StringBuilder output = new StringBuilder(); output.append(this.getClass().getName()); output.append("["); // append fields // to append the Stack you could use Arrays.toString // or just iterate as you are trying to do int i=top; do { T result = stack[top-i]; i--; output.append(result != null?result.toString():"null"); } while (i>=0); output.append("]"); return output.toString(); }

Categories : Java

To turn string into code
Break it into pieces. Let's ignore the loop and the double search, and focus on the core problem: getting a field's value when you have its field number (or name): string Computer::getFieldValue(int fieldNumber) { stringstream str; switch (fieldNumber) { case 1: str << this->processor; break; case 2: str << this->videocard; break; case 3: str << this->display; break; case 4: str << this->RAM; break; case 5: str << this->size; break; } return str.str(); } Given this helper function, it's now possible to write the checking code. for (int i = 0; i < size; ++i) { if (computers[i].getFieldValue(first) == search1 && computers[i].getFieldValue(second) ==

Categories : C++

c++ can one turn a string value into a type?
c++ is statically typed language, and it is not possible to create variables of some random type at run-time. You could do it if your classes have a common interface, as shown in the example at the end. To get a unique name of a type at run-time is easy with typeid. #include <iostream> #include <string> #include <typeinfo> #include <memory> struct B { virtual ~B(){} virtual void foo() = 0; }; struct A1 : B { virtual void foo() { std::cout << 1 << std::endl; } }; struct A2 : B { virtual void foo() { std::cout << 2 << std::endl; } }; std::unique_ptr<B> getFooCaller( const std::string v ) { if ( v==typeid(A1()).name() ) { return std::unique_ptr<B>(new A1); } else if ( v==typeid(A2()).name()

Categories : C++

Is there a way in C# to turn the property into a string containing it's name?
I think this could be helpfull: // This method is called by the Set accessor of each property. // The CallerMemberName attribute that is applied to the optional propertyName // parameter causes the property name of the caller to be substituted as an argument. private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } Source and more explanation: http://msdn.microsoft.com/de-de/library/system.componentmodel.inotifypropertychanged.aspx And here: http://msdn.microsoft.com/de-de/library/system.runtime.compilerservices.callermembernameattribute.aspx

Categories : C#

turn jQuery object/code into a plugin
Don't have the time to go to into depth on this right now but my favorite boilerplate for plugin creation is Stefan Gabos's Good comments and pretty easy to follow. Hope that helps. I'll check back later when I have more time but hopefully this is helpful for now.

Categories : Javascript

Laravel 4, Turn DB::select into Eloquent object
One way to do it would be to set the $exists property to true before saving the object. $campaign->exists = true; $campaign->save(); This way it will trigger the performUpdate() method instead of performInsert().

Categories : Laravel

Turn first part of string into a number in C
You're getting a segmentation fault since you're passing the value of an un-initialized integer (res_num) where sprintf() expects the address of a destination string buffer. You could use strtol() to convert the string to integer, or atoi(). That's not the problem, the problem is in the random memory overwrite of your sprintf() call. Also the printf() is referencing an unknown variable res; are you sure the above code even compiled? You can drop sprintf() and just use printf(): printf("found %d ", atoi(line + 22)); or, of course, store the number in a variable for further processing: const int res = atoi(line + 22); printf("by the way, res=%d ", res);

Categories : C

Turn this string: “ab1_cd2_ef3.php” into 3 variables: “ab1”, "cd2" and “ef3”?
$file = __FILE__; $arr = split("_",$file); $arr[$arr.length-1] = split(".",$arr[$arr.length-1]); $arr[$arr.length-1] = $arr[$arr.length-1][0]; did not test.. im working on it.. What i generally did is split by "_"; then i split "ef3.php" into [0]="ef3" [1]="php"; so i replace ef3.php with ef3

Categories : PHP

How do I turn a PHP variable string to output HTML?
Assuming you're using the built in mail function in PHP: <?php // multiple recipients $to = 'aidan@example.com' . ', '; // note the comma $to .= 'wez@example.com'; // subject $subject = 'Birthday Reminders for August'; // message $message = ' <html> <head> <title>Birthday Reminders for August</title> </head> <body> <p>Here are the birthdays upcoming in August!</p> <table> <tr> <th>Person</th><th>Day</th><th>Month</th><th>Year</th> </tr> <tr> <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> </tr> <tr> <td>Sally</td><td>17th</td><td&g

Categories : PHP

how to get a number form value and turn it into string javascript
Don't use setAttribute to define event handlers. And you don't need to parse the value as you want to put it back in a string. Change document.getElementById("nextButton").setAttribute("onclick", multipleSetWindow+containerCuantityValue); to document.getElementById("nextButton").onclick = function(){ window.location='multiSet.html?type=multi'+containerCuantity.value; }

Categories : Javascript

Turn $get result string into javascript array
var field, value, data = [], str = "'some_field_name',10,'some_other_field,33"; var arr = str.split(','); // just add 2 to each iteration to get every second item (last argument is i += 2): for (var i = 0; i < arr.length; i += 2) { field = arr[i].replace(/'/g, ""); // replace ', because otherwise your string will be "'some_field_name'" value = parseInt(arr[i+1], 10); // parseInt because you want numbers, but got a string data.push([field, value]); // push into your data-array an array with your field and value } jsfiddle here: http://jsfiddle.net/wLxyZ/

Categories : Javascript

Turn a property name as a string into a Linq Expression
Now that you've declared your intent for this in the comments, I believe that the accepted answer here is what you're looking for. Even if it's not doing exactly what you're looking for, these lines can carry over: // TODO: Get 'type' from the property you want. Type delegateType = typeof(Func<,>).MakeGenericType(typeof(T), type); LambdaExpression lambda = Expression.Lambda(delegateType, expr, arg); You could return LambdaExpression, or just use the extension methods found in that answer, or use DynamicLinq. I guess the moral of the story (as it often is) is that its probably been done already :).

Categories : C#

How can I use the get() function to turn the answer in the entry() box into a string
You're right about using get()! The syntax in this case would be City = Cap_Austria.get() if City == 'Vienna': #do stuff You can make default text: Cap_Austria.insert(0, 'default text') And even follow this template: class EntryTemplate(Entry): def __init__(self, master, status): Entry.__init__(self, master) Entry.insert(self, 0, status) Entry.bind(self, "<FocusIn>", lambda event: self.clickOnEntry(event, status)) Entry.bind(self, "<FocusOut>", lambda event: self.clickOffEntry(event, status)) def clickOnEntry(self, event, defaultText): if self.get() == defaultText: self.delete(0, END) def clickOffEntry(self, event, defaultText): if len(self.get()) == 0: Entry.insert(self, 0,

Categories : Python

What is the best way to turn strings into an JSON object with nested keys in Node.js?
I don't think theres an inbuilt function in underscore to do that, but its a fairly simple matter to write one yourself: var input = { "usa.ca.los": 12345, "usa.ca.sfo": 12346, "usa.ws.sea": 22333, "others.a.b.c.d.e": 33333 } function parse(input){ var output = {}; for(var key in input){ setByString(output, input[key], key); } return output; } function setByString(obj, value, key){ var split = key.split('.'); while(split.length){ key = split.shift(); if(split.length){ if(!obj.hasOwnProperty(key)){ obj[key] = {}; } obj = obj[key]; } else { obj[key] = value; } } } console.log(parse(input));

Categories : Json

Turn object instance that uses $.extend into proper jquery plugin
Solution 1 : jQuery Widget Factory see http://jqueryui.com/widget/ Solution 2 : (function($) { $.fn.testFunction = function() { console.log('test'); }; })(jQuery); $(document).ready(function() { $('#test').testFunction(); }); http://jsfiddle.net/jSwhN/ I personaly use the Widget Factory but the solution 2 is convenient.

Categories : Jquery

Turn comma-separated string into GetFiles SearchPattern
string newStr = string.Join(",", supportedImageFormats.Split(',') .Select(r => "*." + r)); Output: Console.WriteLine(newStr); *.jpg,*.pdf,*.doc,*.docx,*.xlsx

Categories : C#

How do I turn a string of digits into a list of one-digit integers?
I think you're simply looking for map(int, s) where s is the string you want to get integer digits from. For example: >>> import math >>> math.factorial(10) 3628800 >>> str(math.factorial(10)) '3628800' >>> map(int,str(math.factorial(10))) [3, 6, 2, 8, 8, 0, 0] >>> sum(map(int,str(math.factorial(10)))) 27

Categories : Python

turn array into string and remove specific item
You can use array_diff() to remove the current category from the $category array: foreach ($category as $cat) { $other_categories = array_diff($category, array($cat)); echo $cat . ' <a href="/news/' . implode('+', $other_categories) . '">[X]</a>'; }

Categories : PHP

How to turn silent mode on during a specific time period in Android? and turn back to normal after the whole duration?
You can use the android FrameWork class AudioManager as follow : AudioManager manager = (AudioManager)getSystemService(AUDIO_SERVICE); manager.setRingerMode(AudioManager.RINGER_MODE_SILENT); Hope it helps :)

Categories : Android

Can I reliably turn a string literal into a symbol name using templates (or fancy macros)?
Now I can call these by "name" anywhere without pre-declaring each one. To call any function at compile time, you need to forward-declare it. Because you want to call them at compile time, there's no need to use string literals. And you can only do this using preprocessor, not templates, because you cannot specify identifier names for templates (in C++03, at least). Example: #include <iostream> #define CALL_FUNC(func, args) name_ ##func args; void name_func1(){ std::cout << "func1" << std::endl; } void name_func2(int a){ std::cout << "func2:" << a << std::endl; } int main(int argc, char** argv){ CALL_FUNC(func1, ()); CALL_FUNC(func2, (46)); return 0; } You can forward-declare function within function body: #include <

Categories : C++

Python: How to turn a string of binary values (arbitrary length) into hex data?
Here is one option: >>> data = "00000111010110101" >>> new_data = data + '0' * ((8 - len(data)) % 8) >>> '{0:0{width}x}'.format(int(new_data, 2), width=len(new_data) / 4) '075a80' The first line appends zeros so the length is a multiple of 8, and the second formats your hex string.

Categories : Python

Android app: how to turn off listener and turn it back on again?
Instead of inline creating the SeekBar.OnSeekBarChangeListener, create a member variable of type SeekBar.OnSeekBarChangeListener. When you want it to turn it on, you can pass the variable to it. When you want to turn it off, you can pass it the null. private SeekBar sbt; //Not sure where this gets initialized in your code. private SeekBar.OnSeekBarChangeListener mListener = new SeekBar.OnSeekBarChangeListener() { int progressChanged = 0; @Override public void onStopTrackingTouch(SeekBar seekBar) { // Toast.makeText(ProductDetailsInfoActivity.this,"seek bar progress:"+progressChanged, // Toast.LENGTH_SHORT).show(); // TODO Auto-generated method stub } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TOD

Categories : Android

Drupal services module JSON response fetched: Backbone.js model attributes turn into string
So I finally managed to crack this issue and I found my solution here: how to get numeric types from mysql using PDO. I thought I'd document the solution. Drupal 7 uses PDO. Results fetched using PDO, using Drupal's default PDO settings result in stringified values. In Drupal's includes/database.inc file you will find this around lines 40-50: $connection_options['pdo'] += array( // So we don't have to mess around with cursors and unbuffered queries by default. PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE, // Because MySQL's prepared statements skip the query cache, because it's dumb. PDO::ATTR_EMULATE_PREPARES => TRUE, ); The statement here that MySQL's prepared statements skip the query cache is not entirely true, as can be found here: http://dev.mysql.com/doc/refman/5.1/

Categories : Backbone Js

How to do a string-based query against an object? (Like LINQ-string to object)
Dynamic LINQ sounds good. If you would prefer to use javascript you could use a script engine. See parse and execute JS by C#

Categories : C#

create constructor string string1,string string2,string string3,Object object1
you should pass View.OnClickListener to your MyCard constructor instead of Object Change public MyCard(String title, String desc, String string, Object setOnClickListener){ super(title, desc); } with public MyCard(String title, String desc, String string, View.OnClickListener setOnClickListener){

Categories : Java

ARC: how to inject custom dealloc IMP in object which in turn calls original dealloc without causing malloc error
If you really want to know when an object is deallocated, then use associated objects. Specifically, associate an object with the object you want to observe such that the object being observed has the only strong reference -- the only retain'd reference -- to the object. Then, you can override dealloc and know that when it is called the object being observed has been (or is just about to be) deallocated. Do not mess with the object being deallocated, though!! It will already have had all of its dealloc methods invoked (by inheritance) and, thus, the internal state will be completely undefined. Note that if your goal is to try and clean up something in the system frameworks, then... don't. Down that path is nothing instability and pain. like I mentioned in the comments to niels

Categories : IOS

How to convert Map to Map in java?
Map<String,String> getPropInMap(Properties prop){ Map<String, String> myMap = new HashMap<String, String>(); for (Object key : prop .keySet()) { myMap.put(key.toString(), prop .get(key).toString()); } return myMap; }

Categories : Java

String flashvar coming out as [Object object] rather than string
The problem is that you are making an incorrect assignment. When your ternary expression is true, you set the variable xmlLocation equal to FlexGlobals.topLevelApplication.parameters. So now xmlLocation is the parameters object, not the String you are expecting. Instead do this: xmlLocation = (FlexGlobals.topLevelApplication.parameters.location) ? FlexGlobals.topLevelApplication.parameters.location : "";

Categories : Actionscript

What does The Response content must be a string or object implementing __toString(), "object" given. mean and why do I only get it on the remote?
Do this to see what is returned. dd(Twitter::getSearch(array('q' => $q, 'count' => 5, 'lang' => 'sv', 'result_type' => 'recent'))); You have to return View class which has __toString() method or if it's ajax request then something like Response::json($data);

Categories : Laravel

object reference not set to an instance of object exception when I try to add element to an array of type List
You haven't created any lists. When you create an array of lists, it won't automatically create all the lists in the array, you have to do that manually: List<string>[] Toursist = new List<string>[numtoursut]; for (int i = 0; i < Toursist.Length; i++) { Toursist[i] = new List<string>(); }

Categories : Asp Net

Passing JavaScript object to C# WCF service as Dictionary
Maybe this will help you or put you in the right direction: An example of an Ajax call I'm using: var data2Send = { "CategoryID": CatID, "AccountID": AccID, "RegionID": RegID, "PersonID": PerID, "BudgetID": BudID, "AccountDetailTypeID": AdtID } //data2Send could also contain i.e. an array of arrays, list of lists, etc $.ajax({ type: "GET", url: '../../Service/myservice.svc/GetAccountDetails', dataType: "json", data: data2Send, contentType: "application/json; charset=utf-8", success: function (data) { var accountDetails = JSON.parse(data.d); }, error: function (jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); The WCF contract: [WebInvoke(Method = "GET")] [OperationContract]

Categories : C#

Jackson Default Typing for object containing a field of Map
Hi there man please do this to solve your problem first create a class MyObject with the appropriate getter and setter methods. /** * * @author qualebs */ public class MyObject { private String a; private Map<String, Object> map; public String getA() { return a; } public void setA(String a) { this.a = a; } public Map<String, Object> getMap() { return map; } public void setMap(Map<String, Object> map) { this.map = map; } } then create an instance of your ObjectMapper with the following Configuration in the class where you are serializing MyObject ObjectMapper mapper = new ObjectMapper().configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false) .enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); // get an create a new MyObject

Categories : Java

Should I define a function to handle a string object or a unicode object?
Yes, this is exactly what they mean. Handle textual input from outside sources as strings, but immediately decode to unicode. Only encode back to some encoding to output it (preferably this is done by whatever function/method you call to do the output, rather than you needing to explicitly encode and then pass the encoded string somewhere). Obviously, if you're dealing with non-text binary bytes, keep them in byte strings.

Categories : Python

Extract a new object by matching a common property between an IQueryable and a Dictionary
Assuming the DirectoryMappingsCollection is coming from Entity Framework, you can't include Dictionarys in the query. Entity Framework can't transform the KeyValuePair to actual SQL-code. You can add a .ToList to DirectoryMappingsCollection to force it to fetch the entire table in your query and it should work. If you are dealing with large datasets, adding a .Where() to limit the data is recommended. combinedCol = (from mapCol in DirectoryMappingsCollection.ToList() join propCol in DirectoryProfilePropertiesCollection on mapCol.DirectoryAttribute equals propCol.Key select new CombinedMappingDataCollection { DetailName = mapCol.DetailRequirement.DetailName, AttributeName = propCol.Key,

Categories : C#

GSON: Deserialize inner Object based on String in containing object
Sadly, no. At least not that I was ever able to determine. There is no way to have it do something like "custom deserialize field X, but super.deserialize() for the rest of it". God knows I tried. If it's any consolation, that seems to be true with every Json deserializer I've looked at.

Categories : Java

convert an IEnumerable> object to XML
IEnumerable<KeyValuePair<string, object>> myObject = ... XElement el = new XElement("root", myObject.Select(kv => new XElement(kv.Key, kv.Value))); el.Save("myFile.xml"); // if you need to save it to file

Categories : C#



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