w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

Which one is more idiomatic/preferred in Scala: Map(: _*) or .toMap?
I would personally prefer the first variant as it's more clear and readable. There are no actual difference between the two in performance or other characteristics. In the first case you make an index seq and then convert it to map in the second you use this seq extractor sintax :_* And this is the best part of Scala. Like Prof. Odersky told many many many, it was a part of Scala design to give make design solutions for different problems. So in this case, you can choose any. But as i told you the first one is more clear and understandable, leave hard-core symbol programming to Scalaz =)

Categories : Scala

Extract ip addres and other stuff from a bind log string using python
Try this one (just added #d+ after the IP address saving group): "(.*?) queries.*client (.*?)#d+: query: (.*?) IN" DEMO: >>> s = '09-Sep-2013 10:22:42.540 queries: info: client 10.12.12.66#39177: query: google.com IN AXFR -T (10.10.10.11) ' >>> re.search("(.*?) queries.*client (.*?)#d+: query: (.*?) IN", s).groups() ('09-Sep-2013 10:22:42.540', '10.12.12.66', 'google.com')

Categories : Python

Python : ( msg = email.message_from_string(aaa) ) values are returning ( None ) when trying to parse stuff from raw e-mail source
The at the beginning and end of the string are causing the problem. Try this >>> msg = email.message_from_string(aaa.strip()) >>> msg.keys() ['Received', 'Received', 'From', 'Subject', 'To', 'Cc', 'X-Originating-IP', 'X-Mailer', 'Message-Id', 'Date', 'MIME-Version', 'Content-Type'] >>> msg['From'] 'root@a1.local.tld'

Categories : Python

put some stuff on the very right of a nav-bar(bootstrap)
Just use two different UL like on the following code : <div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <div class="nav-collapse collapse"> <ul class="nav"> <li><a href="#">THREE</a></li> <li><a href="#">LEFT</a></li> <li><a href="#"&g

Categories : CSS

Using STUFF to combine rows
You could remove t1.partnum from your SELECT Or list Partnum and Description together: SELECT DISTINCT STUFF(( SELECT ', ' t2.PartNum + '-' + t2.description FROM part t2 WHERE t1.class = t2.class FOR XML PATH ('')) ,1,2,'') AS description, t1.class FROM part t1 Or make the partnum's into a separate list too, something like: SELECT DISTINCT STUFF(( SELECT ', ' + t3.partnum FROM part t3 WHERE t1.class = t3.class FOR XML PATH ('')) ,1,2,'') AS partnum ,STUFF(( SELECT ', ' + t2.description FROM part t2 WHERE t1.class = t2.class FOR XML PATH ('')) ,1,2,'') AS description , t1.class FROM part t1

Categories : SQL

Destructor on polymorphic placed stuff
Overkill answer: with unique_ptr and a custom deleter! struct placement_delete { template <typename T> void operator () (T* ptr) const { ptr->~T(); } }; std::aligned_storage<sizeof(Implementation)>::type space; std::unique_ptr<AbstractBase,placement_delete> base{new (&space) Implementation}; Live at Coliru.

Categories : C++

What other stuff can a Scala message tell you?
You can actually send the actor that sent the original message as part of the message. actor1 actor2 ! ("message", self) actor2 receive (or react) { case (string: String, sender: Actor) => { sender ! "another message" } } It should be noted, though, that you should only use this to send a message to the original sender. Calling a function directly on the actor could cause all sorts of terrible things to happen! I actually just read about this in Programming in Scala today, so if you want to look up more about it, I highly recommend the book.

Categories : Scala

How does stuff have to be ordered when using dup2 and pipe?
End your printf() messages with newlines; the fflush() is still a good idea as you're about to change where standard output goes, though it's not usually necessary if the standard output of the program is going to a terminal. If the standard output was going to a file and the fflush() was not in place, then you'd get three copies of "Hello " written to the pipe. When you change standard output to the pipe, your message is indeed written to the pipe. When you close the write file descriptor, you don't run into any issues. You then write a second Hello to the pipe. You need this fflush() to ensure that the standard I/O package has actually written its buffered data to the pipe. You then read from the pipe into the output buffer. You should check how many bytes you read since the string

Categories : C

Pop up window to display some stuff in a fragment
The following should work perfect in accordance with your specification. Call this method from inside onClick(View v) of OnClickListener assigned to the View: public void showPopup(View anchorView) { View popupView = getLayoutInflater().inflate(R.layout.popup_layout, null); PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); // Example: If you have a TextView inside `popup_layout.xml` TextView tv = (TextView) popupView.findViewById(R.id.tv); tv.setText(....); // Initialize more widgets from `popup_layout.xml` .... .... // If the PopupWindow should be focusable popupWindow.setFocusable(true); // If you need the PopupWindow to dismiss when when touched o

Categories : Android

I can't add new/update Android SDK Manager stuff
I am also living in China, and I got problems too thanks to the "Great" firewall, like many other websites, sometimes it was working, sometimes not. What I do is using temporary a VPN to update my SDK when needed. I use this one, in case you need it (a free one): http://www.websitevpn.com/.

Categories : Android

How to set UIImageView as a title so that the stuff is not stretch?
When you use custom views as titleView, as well as for section footers and headers in tableViews and other similar use cases, iOS will ignore the offset part of your view's frame or change it in some not readily predictable way. To go around this issue you will need to create a container view such that your container has offsets (0,0): Try something like this: UIImage * img =[UIImage imageNamed:@"isikota_small.png"]; UIImageView * uiImage= [[UIImageView alloc]initWithImage:img]; uiImage.frame = CGRectMake(127,0,66,33); UIView * uiv = [[UIView alloc]init]; [uiv addSubview:uiImage]; uiv.frame = CGRectMake(0, 0, 66+127, 33); self.navigationItem.titleView = uiv; I'm not sure if the autoresizing masks are throwing it off as well, so try it without any masks and see if you can get the beha

Categories : Objective C

Can't understand some basic REST stuff
First of all It is not REST if you don't use HATEOAS I hope you understand this, I'll come back to that at the very end. POST on /users/ It perfectly ok to not use an ID in the POST payload. If an ID is present react with an error message, so developers understand they are doing wrong. Therefore only the nickname as a payload is perfectly valid if you don't have anything else in your user resource The output of your server should include three important things: HEADER: A status code indicating success or failure (usually 201 Created) HEADER: The location of the newly created resource (just Location: /path/to/resource) BODY: A representation of the created resource. Give back a complete payload like on a GET! GET perfectly valid PUT your analysis regarding PUT/PATCH matchs the

Categories : Api

Extract stuff between the first pipes in bash?
sed 's/^[^|]*|([^|]*)|.*/1/' That matches any non-pipes at the beginning (nothing in the example data), a pipe, captures the stuff that isn't a pipe, matches another pipe and anything at the end, and replaces it with the captured stuff.

Categories : Regex

Client Server Winform IPC and stuff
If I understand correctly, you want to be able to send the message to change color only when it is minimized. To do your color change when the window is minimized try: EDIT (This will see if the window is visible - not sure to check if it is minimized): [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool IsWindowVisible(IntPtr hWnd); msg = REDMESSAGE; if (hwnd == IntPtr.Zero) hwnd = FindWindow(null, "Winforms Application"); IntPtr hwnd1 = FindWindow(null, "ClientApp"); if (IsWindowVisible(hwnd1)) { if (hwnd != IntPtr.Zero) SetBackColor(hwnd, msg); } else { msg = YELLOWMESSAGE; SetBackColor(hwnd, msg); }

Categories : C#

How to use group by inside Stuff in Sql Server
You need to link the inner query (in the STUFF function) to the outer query: you have a join, but it isn't applying to that inner SELECT statement, so the STUFF function is always operating on the first record it find rather than the related record. Put this after "WHERE departmentid IN(5,6)": AND groupID = fr.ParentGroupID Then you can probably remove that JOIN entirely.

Categories : Sql Server

Using ob_ stuff inside a function and call it more than once
Drop the _once part. Replace: require_once("tpl.php"); with: replace("tpl.php"); or: include("tpl.php"); Else, you only use the template file once.

Categories : PHP

Using DHT to lookup stuff. SHA-1. Chord protocol
Since the keyspace is a ring, a single value can't be said to be greater than another, because if you go the other way around the ring, the opposite is true. You can say a value is within a range or not. In the Chord DHT, each server is responsible for the keys within the range of values between it and its predecessor. I would advise against using strings for the hash values. You shouldn't use the hashCode function for distributed systems, but you need to math on the hash keys when adding new nodes. You could try converting the hashes into BigIntegers instead.

Categories : Java

java bracket stuff and possible XML/XSD questions :)
I transferred your code to something that I would see as java code: public class SaveToFile extends ImageAnnotationInstance { public static void main(String[] args){ ImageAnnotation imageAnnotation = new ImageAnnotation(); PathXSD pathXSD = new PathXSD(); AnnotationBuilder.saveToFile (imageAnnotation, "./test.xml", pathXSD); System.out.println(AnnotationBuilder.getAimXMLsaveResult()); } } Since I don't know the classes of imageAnnotation and pathXSD I made some up. Hope that gets you an idea of how it should look. However I'd also recommend to read some java tutorial, like Rajesh advised.

Categories : Java

Apply certain stuff to multiple combobox
Add it in your Window.Resources via a Style without a x:key to thereby apply to all ComboBox control's in the Window implicitly <Window.Resources> <Style TargetType="{x:Type ComboBox}"> <Style.Resources> <sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">0</sys:Double> </Style.Resources> </Style> </Window.Resources> Sidenote: Do remember that your current approach "works" to hide the arrow of the ComboBox, but it does a bit more than that. So be aware of it incase you aren't already. Setting the SystemParameters.VerticalScrollBarWidthKey to 0 will thereby "hide" the vertical scrollbar in the ComboBox's Popup as well which uses the same system parameter for it's Width. So if that behavior is not de

Categories : Dotnet

in easelJS is there a way to say if(object == color red) then do stuff?
just put a property on a linked object, for example myObject.linked = true; and then you check if ( object.linked == true ) ... else ... There might be other ways to achieve what you want, but without seeing your code I'd say that this would be the easiest way, to solve this.

Categories : Javascript

What is PhoneGap doing with all the HTML CSS and JavaScript stuff?
At runtime, PhoneGap works by instantiating a browser component on the device. This is a chrome-less browser, meaning that it does not have an address-bar or forward/back buttons. The end developer’s application consists of HTML, JavaScript and CSS that are loaded into the browser component. PhoneGap provides a JavaScript API that allows developer code to access device functionality, that is currently not accessible to web sites loaded in the default browser. The web view used by PhoneGap is the same web view used by the native operating system. On iOS, this is the Objective-C UIWebView class; on Android, this is android.webkit.WebView. The idea being to display web components, it all starts with a web view! This webview should be able to load HTML (locally or remotely), and run Javas

Categories : Jquery

SQL Server Group by clause - Simple stuff
You can basically use ROW_NUMBER() which generates sequential number based on the group specified. The query belows group the records by QNumber and generates sequential number sorted by ID in descending order. The latest ID for every group has the value of 1 so you need to filter out records that has a generated value of 1. SELECT ID, SessionID, QNumber, Qanswer FROM ( SELECT ID, SessionID, QNumber, Qanswer, ROW_NUMBER() OVER (PARTITION BY QNumber ORDER BY ID Desc) rn FROM tableName WHERE SessionID = 11 ) a WHERE a.rn = 1 SQLFiddle Demo

Categories : SQL

Filtering Against User Input Efficiency.. And Stuff
2000+ items might is a fairly large number of records to hold in-memory in the client, but it might be manageable if those info fields are consistently small. But that might be a secondary issue, and you already recognize the solution to that problem. The bigger issue you're probably facing right now is that it sounds like you're creating 2135 show DIV's in the DOM, with all their children, and then trying to show and hide them dynamically. That's absolutely going to challenge the browser and make things slow and laggy. Try only creating a modest number of show DIV's, and then replacing the contents of those DIV's based on your search and filter results. You could use a templating system like ejs for this, or just do it yourself. For large result sets, just show the first N shows, and lo

Categories : Javascript

Can bad stuff happen when calling a class from an Activity?
You have to leverage the Android Activity Lifecycle. class MyActivity extends Activity { private MyWorkerClass myWorkerClass; void onCreate() { myWorkerClass = new MyWorkerClass(); myWorkerClass.startLoading(); } void onPause() { // You know the activity is going into the background // so act appropriately in your worker class myWorkerClass.stopLoading(); } } The issues you describe above are very generic, so explaining any specific implementation wouldn't help. If you wanted your worker class to complete the work even if your Activity goes into onPause then yes you would want to do the work in another Thread and possibly in a Service. You can still have your worker class though for nice OO & adhering to the SRP.

Categories : Android

How to avoid having my GameManager class be friend with most stuff?
The idea of identifying certain classes as friend and certain others as non-friend is not a good idea, for many reasons. What this means is that, How this class is being used is also a concern of this class. But this is not its concern at all. This class, whatever class is under consideration, should be designed to do its own responsibility. Now, with your case, first of all you should decide on where the action/behaviour of changing position belongs to; does it belong to Entity, Entity Manager, or something else. For example, which of these two cases make more sense: Entity changes its position from x1 to x2. Entity Manager changes to position of Entity from x1 to x2. Suppose you decided that this behaviour really belongs to Entity, rather than Entity manager (case 1). In that cas

Categories : C++

Spooky stuff happening when hovering over dropdown
The reason the menu jumps to the right is because of the margin-left style: .navbar-menu:hover { ... margin-left: 200px; // remove this ... } Here is your jsFiddle with the margin-left removed: http://jsfiddle.net/kavqc/3/

Categories : HTML

Converting a list of "stuff" to a single string
As mgilson says: ''.join(str(x) for x in strlist) is more 'pythonic' as I don't think map is so widely liked anymore. It also generalises more to the case where you didn't have a list but some other iterable thing.

Categories : Python

Where does stuff "print" to when not running application from terminal?
It goes to standard output (so in the command line, if you are opening it in command line, or eg. to the log, if you are running it with cron jobs). For more advanced and flexible usage try using built-in logging support (logging module). It allows you to direct messages to the console, to the file, stream (like external logging server), syslog process, email etc., as well as filter based on log message level. Debug statements (logging statements) can then be still placed in the production code, but configured to not cause any logging other than errors. Very useful and simplifies logging a lot.

Categories : Python

How to rename SQL table column name(s) and not break stuff
While refactoring a database is no doubt a large and risk activity here are some tips to mitigate risk. Below are some suggestions with various pros and cons (as I see the them) hopefully they will help. Code Depending on your programming language, comfort and time frame you can replace inline direct SQL with a RDBMS independent object relational mapper like Hibernate / NHibernate etc. Pros Provides abstraction for future database refactoring. May provide improvements and re-usability. Reduces any SQL injection attacks. Cons A lot of effort and risk in rewiring your code base, but you can do this in a piecemeal approach. Not suitable for every type of application / service (E.G., reports). Stored Procedures Depending on your RDBMS you can provide abstraction and additional s

Categories : SQL

Focused selector in variable . How to do that stuff in LESS like in SCSS
Hmm, interesting. Currently LESS does not expand its "&" within a selector interpolation, i.e. the straight-forward conversion DOES NOT work: @selector-active: &:hover, &:focus, &:active; .class { color: red; @{selector-active} { color: green; } } So you'll need some more tricky code... Using a callback/hook technique for example: .selector-active() { &:hover, &:focus, &:active { .selector-active-properties(); } } .class { color: red; .selector-active(); .selector-active-properties() { color: green; } }

Categories : CSS

C - my program prints weird stuff after reading from a file
The part where you assign "" to buf[3] is wrong. You should use single quotes: buf[3] = ''; The reason is that double quotes means a string literal (which is a null terminated char array) and not a char variable.

Categories : C

Sencha opposite of Ext.getCmp('mainpage').add({items:stuff});
If you are using id: 'carousel', you can do that like this: Ext.getCmp('mainpage').remove(Ext.getCmp('carousel')) You could also do it using a component query: var main = Ext.getCmp('mainpanel'); main.remove(main.down('#carousel'));//added missing closing brackets //OR, if there is only one component of xtype 'carousel' on your mainpanel: main.remove(main.down('carousel')); I personally would avoid using IDs and go with the second method (you could give the carousel an itemId: 'carousel' and still use main.remove(main.down('#carousel')) if you want).

Categories : Extjs

Dev Tools Chrome with JQuery you can enable / disable stuff
So are you asking if you can use jQuery to prevent people from running additional javascript/jQuery from the browser console? No, you cannot do this, the console is built into the browser for developers to test and experiment with by running additional javascript after/while javascript on the page is running. Same thing goes for other browsers as well.

Categories : Javascript

Trouble sending stuff from an EditText to another activity using intents
It is returning empty text because putExtra is called inside onCreateOptionsMenu and at the begining (when the option menu is being created) your EditText is empty. You can add TextChangedListener to your edit text and update your share intent whenever EditText changes. et.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // Update your intent here. } });

Categories : Android

Windows Metro App : How can I add stuff on my screen which is displayed only when I scroll on it?
The standard way for managing application options is using App Settings API. You can use this sample from MSDN http://code.msdn.microsoft.com/windowsapps/app-settings-sample-1f762f49 If you really insist on having horizontal scrollbar, then maybe you need a ScrollViewer <ScrollViewer HorizontalScrollBarVisibility="Visible" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" > <StackPanel Orientation="Horizontal" > <ListView Width="400"/> <ListView Width="400"/> <ListView Width="400"/> <ListView Width="400" Background="Wheat"/> <ListView Height="396" Width="400"/> </StackPanel> </ScrollViewer> Also you may consider using FlipView or Navigation API fo

Categories : Windows

Replace content of a web page with stuff from AJAX response
If you can make some assumptions, then it's not so hard: Assumption 1: The markup is exactly the same every time Assumption 2: The only thing which changes is the TEXT inside of certain html tags You must then know the HTML tags. If you are a consistent person, all of your dynamic data should be wrapped in a similar tag - in your question you mentioned a <b> tag, so lets make a third assumption: Assumption 3: All dynamic data is wrapped with a <b> tag Then all you have to do is this: var replace = function(first, second) { var oldValues = first.find('b'), newValues = second.find('b'); oldValues.each(function(i) { if(oldValues[i].textContent != newValues[i].textContent) { oldValues[i].textContent = newValues[i].textContent;

Categories : Javascript

Creating HTML5 canvas patterns and filling stuff with them
You will need to create a separate canvas for the pattern as you cannot self-reference the canvas for use with patterns. The reason is that when you reference the original canvas you are trying to draw to, the pattern will have the same size and will only draw one instance as there is no room for more than that. So to make it work you need to define a pattern of a smaller size, hence we need a separate canvas or image and pass that in as a source for the pattern. Modified code here: http://jsfiddle.net/AbdiasSoftware/FXGty/ var canvas = document.getElementById("canvas"); var context = canvas.getContext("2d"); /// create the off-screen canvas var canvasPattern = document.createElement("canvas"); canvasPattern.width = 10; canvasPattern.height = 10; var contextPattern = canvasPattern.ge

Categories : Javascript

Adding a control to to the footer of gridview (asp.net) next to the paging stuff
Yes, you need to check in the Row_Created event for a row of type Pager, like this: private void grdClientServiceType_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.Pager) { // Create your control here, button is an example create whatever you want Button theButton = new Button(); theButton.Text = "Click Me"; // Add new control to the row with the pager via a table cell e.Row.Cells[0].ColumnSpan -= 1; TableCell td = new TableCell(); td.Controls.Add(theButton); e.Row.Cells.Add(td); } }

Categories : C#

xCode 3.2.5: Developing non-fullscreen Camera to record stuff
You can use AVFoundation framework for this. Have a look at this sample code http://developer.apple.com/library/ios/#samplecode/AVCam/Introduction/Intro.html

Categories : Iphone



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