Thursday, 15 July 2010

mysql - How to solve the "Data source name not found and no default driver specified" -


I was working with MySQL ODBC 5.1 on my website (ASP.NET 4.5), but due to this problem: I Try setting MySQL to ODBC 5.3.4 and change the connection string from 5.1 to 5.3. Now I have not got the name of the error [IM002] [Microsoft] [ODBC driver manager] data source and no default driver is specified exception that many others have done.

Nevertheless, uninstalled I 5.3 and 5.1 and then 5.1 64bit was installed on my Windows 8.1 64 but I still get the same exception! I tried to restart and reinstalled / installed, but it throws the same exception.

I have tried to add the driver (pointing the server) to Controlpanel> ODBC Data Source 64> System DSN but it still does not work.

Edit: I can work with the database without problems and work with the MySQL workbench without problems.

Exact exception: error [IM002] [Microsoft] [ODBC Driver Manager] The name of the data source is not found and no default driver is specified

This is the current connection string:

  & lt; Add name = "MySite" connectionString = "driver = {MySQL ODBC 5.1 driver}; server = 127.0.0.1; port = 3306; database = 195414-mice site; USER = [myuser]; password = [mypassword] OPTION = 3" / & Gt;  

The server has been set to 127.0.0.1 because BSAS is using SSH and has worked well before that.

I tried uninstalling all mysql odbc drivers and then installed 32 bit 5.1 and Worked fine! Although it still does not work with 5.3 32 bit.


javascript - What does stub.callsArg(index) from Sinon.JS do? -


Seriously, I can not understand that document gives us:

stub.callsArg (Index) - The reason for the stub is to call the argument in the index provided in the callback function. Stub.callsArg (0); Callback is the reason for the stub to call the first argument.

However, I do not know that to be indexed in the list of these objects, I probably could not understand what a stub is ...

A stub is a nock function, program on the stub to implement a program on index and apply it immediately.

  function sayHi () {Console.log ('Hi'); } Var stub = sinon.stub (). CallsArg (2); Stub ('ABC', 42, is to say); // print "Hello"  

r - Specify error as interaction between block and treatment -


Programmers,

I am trying to specify in R that interaction of error word in AOV Is Block and My Cure Can You Help Me? I have created an example below.

-Rick

  d < - data.frame ("a" = as.factor (representative (1: 3, 12)), "b" = a.factor (representative (1: 3, every = 3)), "block" = like. (Representative (1: 4, each = 9))); D $ y & lt; - as.numeric (d $ a) * rnorm (36, mean = .75, sd = 1) + as.numeric (d $ b) * rnorm (36, mean = 1.2, sd = 1) + As.numeric ( D $ block) * rnorm (36, mean = 1.2, sd = 1) + rnorm (36); Anova1 = aov (y * a + b + error (a * b * block), data = d) summary (anova1)  

I did the above but there was no P-value in my output :

  Error: A DF amount Sq Pisces square one 2 50.38 25.19 Error: BDF amount Sq Pisces square B2 16.61 8.307 Error: Block DF amount Sq mean square F value P (& gt ; F) Residual 3 138.2 46.06 Error: A: BDF Sum class Mequa square F value value (F) Residual 4 46.3 9 11.6 Error: A: Block DF Sum class Mequa square F value Price (& gt; F) Residual 6 69.71 11.62 Error: B: Block DF Sum class MEQ squared F value P (F) Residual 6 110 18.33 Error: A: B: Block DF Sum class MEQ square F value As a help for residual 12 28 9.5 24.12  < summary.aov , P-values ​​are returned only "if there are non zero residual degrees of independence . " This is understandable, because with residual DF, no randomness has been left to guess in the model. 

Your model is 'completely saturated', which means that there is no replication within the combination of factor level, which attempts to guess it. See for further discussion.

To diagnose this problem in your data, try the code below that indicates that each block / A * B combination has only one overview:

  & Gt; Xtabs (~ a + b + block, d), block = 1 ba 1 2 3 1 1 1 1 2 1 1 1 3 1 1 1, block = 2 ba 1 2 3 1 1 1 1 2 1 1 1 3 1 1 1, Block = 3 BA 1 2 3 1 1 1 1 2 1 1 1 3 1 1 1, Block = 4 BA 1 2 3 1 1 1 1 2 1 1 1 3 1 1 1  

android - MPAndroidChart - How to customize the markerview text? -


I'm using.

How do I customize the text of marker view ?

I want to say that when pressed once, markerview is displayed, and the text of marker view displays me a text that I want.

please refer to it.

There you can find information about what you want to achieve. Basically, you have to expand the marker view category and refresh the content in this refresh content (Entry e, Int DatasetXx) method.


ios - UIRefreshControl flicker -


I under iOS 8. With my implementation of UIRefreshControl every first time I get a problem of flicker come back to the top My table view (which means when the app has just started), I have shown flicker down in GIF. It does not happen at any later time until I go to the top of the table until this view is again full, so I did something in the second scene of the app or it completely restarted.

screen recording of flicker

This is in the viewDidLoad of your application Code ():

  go to refreshControl = UIRefreshControl () override viewDidLoad () {super.viewDidLoad () function // UIRefreshControl when appearing in self.refreshControl.endRefreshing (sometimes waking up to appear To prevent this here) UpdateData () refreshControl.backgroundColor = UIColor (Color: 0.58, Saturation: 1.0, Brightness: 0.43, alpha: 1.0) refreshControl.tintColor = UIColor.whiteColor () refreshControl.addTarget (self, action: " UpdateData ", forControlEvents: UIControlEvents.ValueChanged) tableView .addSubview (Refresh The control controller has been declared out of view, as a deedload () function, I want to call the end refreshing method from within my updateData () function. The obvious way of doing this seemed like this.   

I was able to solve it by changing the following line

  TableView.addSubview (refreshControl)  

to
  tableView.insertSubview (refreshControl, atIndex: 0)  

this Thanks for the comment:


C++ win32 Api resource file -


I'm learning Win32 api I know how to add pushbutton on the fly now I have a resource file (rse.rc) I'm trying to add a pushbutton using Below is my res.rc file definition:

  IDB_B1 pushbutton "toggle", 7, 20, 180, 200, 30  

and I created evn Is a source.h file for inclusion in the source. The problem I am facing now is how do I add this button to my main window? I tried to add a cursor and an icon using the .rc file which is easy but my head can not be found around this button.

I think it should be below:

  WM_CREATE:  

But how to fix it with .rc file?

This does not work in this way.

The resources in Win32 are used to create many things: menus, accelerators and dialogs, among others; But not single control

What you want to do, a main window with a button can be obtained by using two techniques:

  1. Become a dialogue of your main window you complete For the dialogue, write the resource with the button and everyone, and from WinMain () you call CreateDialog () . dialog box () or similar.
  2. Your main window is a normal window, and you manually create a child copy as an answer to WM_CREATE , as you guessed, the class name With WC_BUTTON , these controls are created in the CreateWindowEx () call.

In addition to this, you can make a child a child of the main window, but I do not suggest that, especially if you are still learning.


python how to include a file of lists in a script -


मेरे पास एक ऐसी फाइल है जो उत्पन्न होती है:

अंश:

 < कोड 'ग्रुप' = ['पेरेंटपॉम'] समूह 1 = ['कॉमन्स', 'एचटीटीपी', 'उपलब्धता', 'निगेटपोम', 'एबीसीकॉम्मन', 'सॉलट्रैंडएक्स', '123 एससियर'] ... समूह 10 = ['कुल कॉमन्स' 'जेनरेटर']  

मैं इसे कैसे अपनी अजगर स्क्रिप्ट में शामिल कर सकता हूं, आयात करने की कोशिश की लेकिन

  & gt; & gt; & gt; आयात निर्भरताएंग्लैगमेंट & gt; & gt; & gt; प्रिंट (समूह 2 [0]) ट्रैसबैक (सबसे हाल ही में कॉल अंतिम): फ़ाइल "& lt; stdin & gt;", पंक्ति 1, & lt; मॉड्यूल & gt; NameError: नाम 'group2' परिभाषित नहीं है  

आयात में फॉर्म का उपयोग कर रहे हैं, आपको

  dependencies_custom.group2 [0]  

टाइप नोटेशन द्वारा समूह तक पहुंचने में सक्षम होना चाहिए। यदि आप चाहें तो बस group2 [0] नोटेशन का उपयोग करने का प्रयास करें: dependencies_custom import * से

   

jquery - FTP Image Slider -


Is there a slider that I fill in an FTP link address with YouTube and password then it contains images of that folder location Is the server played?

I have tried the wow slider but this slider only allows anyone to publish on an FTP server, otherwise the rounds will not be.

I do not think that's it. I need this:

  1. Upload my Android app to a folder called "Event" via FTP from my server
  2. Now I should be able to play my website All the images in the folder "Event"

How do I do this?

If you have basic knowledge of html5 CSS and jquery, you should use it. If I understand, then I think that if you are going to use this slider for the website then there is no need to use FTP. Make sure the images in your folder should be accessed through the web URL.


Is there a way to do this in FullCalendar jquery -


You can call Kids Arts School Day from April 12 to 17 April. This will fill up once a day like "Kids Art School Day", how do you show the same thing every day as a traditional paper calendar? On April 12, it is called "Kids Art School Day", April 13 says "Kids Art School Day", April 14 says "Kids Art School Day" ... ... all these are saying the same thing ? I like it in events, such as

  'title': 'Kids Art School Day', 'Start': '2015-04-13', 'End': '2015-' Art school day ',' Start ':' 2015-04-14 ',' End ':' 7-13 ',' Colors ':' #FFFFF ',' TextColor ':' # 3300FF 'Title' 2015-07 I have set a limit but they want each box to have the same thing: - 14 ',' color ':' #FFFF ',' textclosure ':' # 3300ff ' ..im .. ideas? There is a lot of things in the calendar ... there will be a lot to make this JSA readable ...   

This is not directly supported and hence the solution is a bit difficult.

Basically, you break the event in one day's event when they are loaded. Use it for

  event: function (start, end, timezone, callback) {// Get an event with an AJAX call or whatever // here , They have been declared globally as 'Events' var chunkedEvents = []; (Var i = 0; i & lt; events.length; i ++) {var day = moment (events [i] .end) .diff (events [i]. Start, 'day'); // event length if (types of events [i] .end! == "undefined" & amp;; & amp;; day; 0) {for (var j = 0; j & lt; = days; j + +) {ChunkedEvents.push $. Extensions ({}, events [i], {start: moment (events [i] .start). Subtracts (j, 'day'), intervals (events [i] .and). Subtracrack (day + j, 'Day')}))}} Other {selected events pash (events [i]); }} Callback (selected events); }  


PHP error after new install of xampp -


I recently stopped the computer at work, and I am trying to run all of my projects again. I'm working on testing some php / html / javascript pages for a website using a local xampp server. I was working properly on one computer, but when I tried to load the pages I get the following error:

  Unwanted syntax error: Unexpected token & lt; I have tried a PHP-only test page, so I know that breaking party is capable of parsing.  

I also know that this is not a small tag issue, because all the PHP code

   

Are there any other configuration settings that are causing this problem?

The error message does not look like a PHP error. Check that you can find solutions there.

It seems that Google Chrome is notified of an error when it is expected to parse the .js file and get HTML (or PHP?) ? instead of this.


wpf - Apply DataRecordPresenter style to a specific grid -


I have some Xmadatagri (version 11.2) on my WPF form, when I get triggers, I want to paint the whole row in yellow Created a style.

& gt; Style target type = "{x: type igDP: DataRecordPresenter}" & gt; & Lt; Style.Triggers & gt; & Lt; Datatrigger binding = "{binding path = some property name names}" value = "1" & gt; & Lt; Setter property = "background" value = "# ECEC85" /> & Lt; / DataTrigger & gt; & Lt; /Style.Triggers> & Lt; / Style & gt;

This is the fact that there is no property in the second grid view model which is using data triggers and it generates a binding exception that I would like to fix, so I think The easiest way to fix this is to apply the style to the first grid but I do not know how to do this ... any help please?

You can give a specific style on the grid. Refer to the code below.

  & lt; Page. Resources & gt; & Lt; Style x: key = "first gridrp" target type = "igDP: datacarc presenter" & gt; & Lt; Style.Triggers & gt; & Lt; Datatrigger binding = "{binding path = some property name names}" value = "1" & gt; & Lt; Setter property = "background" value = "# ECEC85" /> & Lt; / DataTrigger & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /Page.Resources> & Lt; Grid & gt; & Lt; IgDP: XamDataGrid x: name = "firstgard" & gt; & Lt; IgDP: XamDataGrid.FieldLayoutSettings & gt; & Lt; IgDP: FieldLayoutSettings DataRecordPresenterStyle = "{StaticResource FirstGridDRP}" /> & Lt; / IgDP: XamDataGrid.FieldLayoutSettings & gt; & Lt; / IgDP: XamDataGrid & gt; & Lt; IgDP: XamDataGrid x: name = "secondsgreat" & gt; & Lt; / IgDP: XamDataGrid & gt; & Lt; / Grid & gt;  

javascript - How do you add a "touch to select" on a WinJS ListView? -


I did most of this in Microsoft Windows Phone applications, where you tap on the left hand of a list, and it's multi -Choice mode starts.

How can you get the same functionality using WinRT / Javascript / WinJS?

To clarify this, there is a picture of the mail app to ensure that it has been done with XAML / C #.

Enter image details here

< / Html>

python - Rename Pandas Multiindex based on another column's name -


I have found a CSV file that is generated in the format that I can not change. The file has a multi index: headers on two rows.

What does my headline look like:

header luos

It really comes down and what I want:

the header really What is

I would like to process it correctly with Pandya in Python 2.7.

I had to loosen to the first level of the index and if the value is empty, set it to the same one on the left side.

I start by loading dataframes into pandas:

  df = pd.read_csv (myFile, header = [0,1], sep = ',') df  

Dotframe loaded in pandals

I have tried the following:

 for , value in value (df.columns.values): If Val [0] [: 7] == 'Anonymous': l.append ([L [i-1] [0], val [1]] and: L.append (val)  

list "L" I think what I want to do ('Foo', 'A'), ['Foo', 'B'], ['Foo' 'C'], ('Bar', 'A' ), ['Bar', 'b'], ['bar', 'c']] < I have tried both:

  df.column = l  

produces a non-multi index dataframe

flat dataframe

  index = pd Multindex From_tepplease (L) df.reindex (column = index)  

This one gives me the correct indicator, but values ​​disappear.

missing value

I think the whole approach I try I am not sure that the whole approach is very dragon, nor does it make sense to use a list that there is a strong intestine, how can I do the multi index properly with any idea? Instead of using

reindex , set directly in your new index Column:

  df.columns = pd.MultiIndex.from_tuples (l)  

It should produce the desired result

reindex not only changes the index values ​​(though it seems to be what it should do, and the documentation is not particularly obvious). Instead it goes through your new indices, chooses the rows or columns that match the new indices, and puts NaN , where no old index matches the new index. What's happening to: When reindex hits ['Foo', 'B'] , which is not present in your original dataframe, this column fills in the new < Dataframe with Code> NaN .

If your columns always follow a consistent pattern (for example, a top-level column for each three-second-level column), you can also use the column index to create To: Products (Iterables) from

> iterables = [["foo", "bar"], ["a", "b", "c"]] index = pd.multiindex


Does c++ linker throw away what is not needed or adds only what is needed? -


If a linker begins to satisfy the missing symbols, until it does so until all the necessary The symbols are not satisfied, we are "only needed". On the other hand there is a complete collection of symbols and then based on some algorithm, it is not necessary to remove symbols from scanning, we are called "throw". For me it is sensitively correct that we are only required to add this aspect of the process of adding.

I am curious that the Stakeworf community community agrees, because I believe that it gives a strong argument to rely on the facilities of such linkers.

All links work in a connector mode. Graph theory is best explained by using

By identifying one linker for one or more entry points (for an executable, for export functions for a library, for the main ) begins. These entry points should be included.

However, these export points can be included in large areas / segments (many compilers can not package different functions or data).

In addition to this, functions are called other functions, a linker may need to add those functions - and then, the limitations of the compiler can be very extra when things are too large, the dragging objects This phase is called "Resolve dependency" and is usually done recursively until any other function is missing.

Why are these sections too big? A common problem is that compiler / linker pairs can not say dependencies if the linker can not be told that depending on XY, the compiler should keep X and Y in the same segment. It rises to that point where a whole. The CPP file ends in a single section, unfortunately - and drag all those unnecessary functions, which are in their unnecessary dependencies. I have seen executable balloons up to 600 MB.


excel - Odoo/OpenERP - custom module's export links visibility in tree, list view -


I have installed the web_printscreen_zb module in my Odoo v8 system. If type is of type "list" then module at the top of the page correctly shows "pdf" and "excel" link However, if the scene type is "tree", then these two links are not visible. I have tried to hack an active file by modifying the "web_printscreen_export.xml" file of the module from "list" to "tree", but with no results, the links are still not displayed.

What do I need to do to enable the "pdf" and "excel" link to show the type "tree"? Example of concrete "Bill of materials" list view (model "MRP."), Link visible, and "Bill of content structure" tree view (model "mrp.bom.line"), links are not visible. View attached diagram There is a difference between the list and the tree view.

Enter image details here


bash - Create subdomain on the fly Ubuntu bind -


What I'm trying to do is create a subdomain of an already existing region, but I "update failed: SERVFAIL "Get error.

What do I still have:

  #! / Bin / bash record = yyy.mydomain.com ttl = 5 (echo "server localhost" echo "area mydomain.com" echo "update $ {record} add 300 a217.xxx" resonance "" add ") | / usr / Bin / nsupdate  

Does anyone know what I'm missing


sql - Dynamically populate external tables location -


I am trying to use Oracle external tables to load flat files in a database but I have a problem The same is being done with the number of files we get with the location section, along with the date of the files, so I was hoping to use the wildcard in the location section but it does not seem that I am capable.

I think that I am right, I am unable to use wildcards, do anyone have any idea how can I do this without writing a large amount of code in the external table?

Current Thoughts:

The only way I can think of doing this at this time is to have a shell watch script and parameter table. The user can specify: input directory, file mask, external table etc. Then when a file is found in the directory, the shell script creates a list of files found with the file mask. For each file, an external table command was found to change the location in the external table given in that file and to launch the remaining PL / SQL associated with that file. It can be duplicated for file found with file mask. I think the advantage of this is that I can add logs and the expiry of bad files after every run.

I will post a solution that I did at the end that appears to be the only way.

I have a file viewer compared to appearing for files in the input diary given with a fixed file mask. I also include the name of the external table in the lookup table, I just added a new Continue to change a table with a list of table names.

This was not a lot of problem for me because I'm already using Shell to view most files File manipulation Hopefully it saves someone looking for a solution for a solution < / P>


Read from an excel cell & write to another excel sheet applying the same format in python xlrd/xlwt -


I am using xlrd, xlwt and so on; Write the exceltes library and read excel sheet in reading, then I have read successfully and am amp; Written to Excel Sheet

But I need some guidelines in capturing the format of that cell from which I am reading & amp; Applying the same format in the room that I am writing.

Below I've tried -

  # Open Excel Sheet & amp; Refer to Tab1 rb = open_workbook (r'C: \ users \ abc \ excel.xls', formatting_info = true) sheet = rb.sheet_by_name ("tab1") # Search excel sheet for string and return to cell def searchStringCell Find Location (Search String): In Category (Sheet. NRO): Line = sheet.row_values ​​(i) Category: Jammu (Lennon): If line [j] == searchString: return i, j # Search string header = '& lt; Title & gt; HeaderTitleX, headerTitleY = searchStringCell (headerTitleX, headerTitleY) Print "Title Cell: (", HeadTitleX, "," HeaderTitleY, ")" Write data to # cell, which is 2 columns of right cell first Only wb = copy (rb) w_sheet = wb.get_sheet (0) read w_sheet.write (headerTitleX, headerTitleY + 2, 'new data') # Try it below; Not sure what to do fmt = rb.xf_list [cell.xf_index] bg = fmt.background.pattern_colour_index rgb = wb.colour_map [bg] # save changes wb.save (r'C: \ users \ abc \ excel Xls ')  

I have tried to read fmt, bg & amp; RGB from letter; But I am unsure of how to apply the same format of the cell in which the data has been read & amp; Apply it to a new cell Thank you.


database - How to perform an update query in Java? -


यह प्रश्न एक सटीक डुप्लिकेट है: < / P>

  • 1 उत्तर

मैं डेटाबेस में नहीं हूँ और मेरे पास एक जावा एप्लिकेशन में निम्नलिखित समस्या है जो कि मेरे डीबी की एक मेज पर एक फ़ील्ड को अपडेट करने वाली एक बहुत ही साधारण क्वेरी करना है।

तो, मूल क्वेरी इस तरह की है:

<पूर्व> अद्यतन coda_tx c SET c.FK_STATO = 2 WHERE c.PK_CODA = 62816;

इसलिए मैंने पिछली प्रश्न को कार्यान्वित करने वाली निम्नलिखित जावा विधि को कार्यान्वित किया है, यह एक:

  सार्वजनिक शून्य अद्यतन स्थिति (int pkCoda, int newStatus) {String एसक्यूएल; स्ट्रिंगबफर एसबी = नया स्ट्रिंगबफर (); Sb.append ("UPDATE coda_tx c SET c.FK_STATO ="); sb.append (NEWSTATUS); Sb.append ("WHERE c.PK_CODA ="); sb.append (pkCoda); Sql = sb.toString (); कोशिश {statment = connection.createStatement (); परिणामसेट rs = statment.executeQuery (एसक्यूएल); } पकड़ (SQLException ई) {ई.प्रिंटस्टैक्सट्रेस (); // कैच स्टेटमेंट का इस्तेमाल करने के लिए फ़ाइल का उपयोग करें | सेटिंग्स | फाइल टेम्पलेट्स }}  

मेरा केवल संदेह उस अनुभाग के बारे में है, जिसके द्वारा क्वेरी किया जाता है, यह एक है:

  statension = connection.createStatement (); परिणामसेट rs = statment.executeQuery (एसक्यूएल);  

मुझे लगता है कि यह गलत है क्योंकि वास्तव में ResultSet है जो एक SELECT ऑपरेशन द्वारा पंक्तियों को प्राप्त करने के लिए एक वस्तु है इस मामले में मैं एक विशिष्ट पंक्ति के एक क्षेत्र को अद्यतन कर रहा हूं और मैं एक ResultSet ऑब्जेक्ट में विषय डालते हुए पंक्तियों को पुनः प्राप्त नहीं कर रहा हूं।

तो, मैं इस स्थिति को सही ढंग से कैसे प्रबंधित कर सकता हूं? मुझे अपनी क्वेरी कैसे करनी है?

यहां आप यह कैसे कर सकते हैं:

< पूर्व> // updateCount में अद्यतन अद्यतन पंक्तियों की संख्या int updateCount = statment.executeUpdate (sql);

database - How to write a Bash script which queries a PosgreSQL on another physical server -


I would like to create a bash script, I would say queryserver.sh, which is at IP at 1 2.168.2.1 on computer at, USERA With PASSA and PASSA password and computer user asks a Postgresql database on the computer. 192.160.10.1 user user and passwords with PASSB example.

In short, ComputerB has a PostgreSQL database table whose data is used to update the Postgresql table computerâ. The computer hosts a database used for a web application, while ComputerBank hosts backend number crunching functionality.

In Microsoft SQL Server, there is a concept of linked server, but I did not get the same concept on PostgreSQL / B>

There are several ways to solve this problem. psql can connect to remote hosts You can use ssh to remotely psql but since you were linked to MSSQL If you refer to the server, then PostgreSQL is most comparable.

  Certificate ComputerBrand Postgres_fdw option on foreign data wrap (host '1902.16.10.1', to access tables on Computer B as 'Port', on user A on Postgrass SQL instance of Computer A To allow, <5432 ', dbname' computerB '); Create user mapping for user server computer backup options (user 'USERB', password 'PASSB');  

Then you must use Create foreign table to use each table


.net - asp chart x/y axis lines not changing color -


I have an aspir chart, I should have the main X / Y axis lines white, though they keep showing black. Can anyone tell me what option will change the X / Y axis lines in the HTML code or back? Enter image details here

Use line color property for both XXX and Acideways just inside your chart.

Example. Axisline = "1" line collar = "# 99 99ff" title = "x2"


python - Containing Pygame Sprite to Surface -


I'm writing a chess program in Pygame's attempts ... Well, to write chess. Currently, one of the problems I am facing is trying to attract each piece in my affiliate square. I mean, I think one way to force the phantom to join each other in its own class.

The logic behind my program is basically no one (pieces can move anywhere, etc.), but I have to see that this is possible before proceeding with the rest of the project.

It requires some photos for pieces, but I'm not sure where to upload them, so just pretend they are not needed :)

Thanks in advance.


node.js - Use dynamic express routes within another Express route -


For a school project, I have created a plugin for the application in an express.jis-node.js. The main page of the application should display a dashboard, where each root page of each plugin should be displayed in a div. Each root page is accessible on PluginName / Root.

What I would like to do is the following: I want to include the HTML-string of each home-root in the dashboard. But for this, let me node. There is a need to call routes within JS (partially) and for some plugins I also have to provide some properties.

Does anyone have an idea, how can this be implemented? / P>

For example, I have a route:

  router.get ('/ pluginname', function (rik, ridge) {res.render (__DERNAM + '/ view / email / Handlabar ', {layout: __dirname +' / views / layouts / main.handlebars', markup: markup // pass remarket markup});});  

Now I want to pass the resulting HTML from this route to another.

So far I had the following thoughts:

  1. Just add the URL of the plugins for the "Data-ajax-url" attribute of the Divis and the goods through AJX Load from
  2. Make an HTTP call on every route and add results to server side (too bad ...).
  3. Create a render dashboard-function for each plugin, where I'm going to app. HTML is found using render (...) and then I add results.

But I'm not sure which approach (if any) would be best.


sap - ABAP Join Query not returning data in function module -


I'm new to ABAP. I had created four tables (Z588B, Z588T, ZFINALTABLE) which I wanted to populate in the function builder using SQL.

At first I tried to join these tables T588B, T588T and deposit this for the cluster table cluster "Got tables and launch ideas are not allowed".

That's why I created temporary table to store data T588B, T588T tables, so I can use Z588B, Z588T temporary tables Jedfintlabl in Jeflainlbl are, I need it.

I was able to populate the Z8888B, Z888T with the data that I needed, but no data came back after being included in the use of these temporary tables.

This is what I had

1) Function module created using SE37 "Z_BAPI_TESTP_FM"

2) In the import tab I define the parameters I do

  MANDT TYPE ZTESTPA30 -MANDT customer USERG type ZTESTPA30-USERG user group  

3) declared temporary tables that I se11

 < Z588B like Z588B was created using the T588B Z588T for the temporary structure like ZFINALTABLE  

4) entered my SQL query in the source code.

  function Z_BAPI_TEST_FM * "--------------- --------------------------------- ----------------- ----- * "*" local interface: "import *" VALUE (Maanditi) type ZTESTPA30-MANDT * "VALUE (USERG) type ZTESTPA30 -USERG *" export * "VALUE (RETRUN) type BAPIRET2 *" Tables * "ZPA30 Structure ZPA30 *" Z588B Structure Z588B * "Z588T Structure Z588T *" Z582S Structure Z582S * "Z588BTEST Structure Z588BTEST *" ------- ---------------- ---------------------------------- ------------- Tables :. Z588B, Z588T, ZFINALTABLE MANDT USERG MNTYP MENUE infty choose T588B customer's table Z588B specifies that where the MANDT = MANDT and USERG = USERG and MNTYP = 'I tables and SPRSL =' N ''. T588T where customers MANDT = MANDT and MNTYP = specified Z588T grounds that investigations select MANDT SPRSL MNTYP MENUE DTEXT '. as a ~ MANDT MANDT a ~ USERG USERG a ~ MNTYP as selected as the MNTYP a ~ Infty as a ~ menu infty b ~ SPTRSL SPRSL as B ~ DTEXT D51 as Z588B table ZFINALTABLE field as a left Z588T B as a ~ MNTYP = b ~ MNTYP Switch to join. ENDFUNCTION  

The Z588B was able to load data on Z588T for the given parameter, but with the joining, the last SQL ZFINALTABLE is not returning data in the table.

Do anybody tell you that there is no data in the last SQL ZFINALTABLE using JOIN?

If you use JOIN, then this display will cause a problem. Try binary search instead, then add all your data to the last tab.


curl - PHP image purging exceeds maximum execution time -


Text after "<" post = "itemprop =" text ">

I am cleaning an old PHP application on a lamp-stack. Everything works normally, but there is a function to purify within the time of request-library. Code takes an image URI

I get a timeout-error after 30 seconds of this kind: Fatal error:. Exceeded maximum execution time in 30 seconds / & LT; PathToFolder & gt; / Device / Request Line 133 is , which is the line if (curl_multi_select ($ MH)! = -1) { on .php. There is nothing wrong with the image URI. I have also tried to maximize execution time of 360 seconds, but it still fails. Infinite loop, maybe? If so, why?

Anyone have any ideas? Public stable function purge ($ uri = '') {if ($ uri == '') {Throw new exception ('Uri is not set'); } $ ChVarnish01 = curl_init ($ uri); $ CHVarnish02 = Curl_init ($ Yuri); $ CHVarnish03 = Curl_init ($ Yuri); Curl_setopt_array ($ chVarnish01, array (CURLOPT_CUSTOMREQUEST = & gt; 'pure', CURLOPT_RETURNTRANSFER = & gt; true, CURLOPT_TIMEOUT = & gt; 5, CURLOPT_HTTPHEADER => array ('varnish: 01'))); Curl_setopt_array ($ chVarnish02, array (CURLOPT_CUSTOMREQUEST = & gt; 'pure', CURLOPT_RETURNTRANSFER = & gt; true, CURLOPT_TIMEOUT = & gt; 5, CURLOPT_HTTPHEADER => array ('varnish: 02'))); Curl_setopt_array ($ chVarnish03, array (CURLOPT_CUSTOMREQUEST = & gt; 'pure', CURLOPT_RETURNTRANSFER = & gt; true, CURLOPT_TIMEOUT = & gt; 5, CURLOPT_HTTPHEADER => array ('varnish: 03'))); $ Mh = curl_multi_init (); Curl_multi_add_handle ($ mh, $ chVarnish01); Curl_multi_add_handle ($ mh, $ chVarnish02); Curl_multi_add_handle ($ mh, $ chVarnish03); $ Active = null; Do {$ mrc = curl_multi_exec ($ mh, $ active); } While ($ mrc == CURLM_CALL_MULTI_PERFORM); While (! Curl_multi_select ($ MH) = -1) ($ active & amp;; amp $ MRC == CURLM_OK) {if {$ make MRC} {= curl_multi_exec ($ MH, $ active); } While ($ mrc == CURLM_CALL_MULTI_PERFORM); }} Curl_multi_remove_handle ($ mh, $ chVarnish01); Curl_multi_remove_handle ($ mh, $ chVarnish02); Curl_multi_remove_handle ($ mh, $ chVarnish03); Curl_multi_close ($ MH); Back true; }


javascript - Extjs Tree how to change text color of child elements? -


I have a tree and I want to change the text color of the hair elements.

  {text: "alegrbra", address: true, iconCls: 'button-along-icon icon-flag_green', style: {'color': 'red'}}  

I can change the icon but the color can change.

How can I style that element?

I added

CLS: 'rednode'

, and CSS is

  .rednode {color: red; }  

This fixes the problem to me


Set SAP RFC import table parameter using php multidimensional array -


I am trying to call a SAP RFC function that contains the import parameter as the table. Currently I have a SAP- I am using saprfc for communication between PHP but it does not accept table in import parameter.

This is giving the following error for the import parameter: EX_ORDER_HEADER:

The interface name EX_ORDER_HEADER can not be found, __cal_refresh_internal_buffer ();


html - How can I create a vertical bootstrap responsive navigation? -


I'm very new at this. I would like to know how to create a vertical navigation bar with bootstrap but I want to set it on the left side in the 100% height. And be responsible for mobile

I have tried to do something like that, but in reality it is not what I want

Fixed (in this case X and SAP size) main content should then take full screen width.

All you need to do is styled the navigation with CSS, so that its full height, negative left positioning (to hide it by default), different background color etc.

An example of the HTML "skeleton":

  & lt; Div class = "container" & gt; & Lt; Div class = "row" & gt; & Lt; Div class = "col-lg-3 col-md-4 mobile-menu" & gt; & Lt; Ul class = "navigable nav-pills nav-stack" & gt; & Lt; Li class = "active" & gt; & Lt; A href = "#" & gt; Menu item & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Menu item & lt; / A & gt; & Lt; / Li & gt; ... & lt; / Ul & gt; & Lt; / Div & gt; & Lt; Div class = "col-lg-9 col-md-8" & gt; & Lt; Div class = "row" & gt; & Lt ;! - Your content - & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

and CSS:

  .mobile-menu {padding-top: 15px; Overflow-y: auto; } @ Media (max-width: 991px) {. Mobile-menu {status: fixed; Top: 0; Width: 240 pixels; Left: -243px; Z-index: 100; Height: 100%; Box-Shadow: 3px 0 5px RGBA (0, 0, 0, 0.23); Background color: #fff; }}  

Then you just need to open some javascript to open / close the menu (actually a simple left: 0 / left: -243px in this example), and maybe you have animations Want to

I have created such a bootstrap for you, you can find it and it's really easy to use.


linux - Very strange behavior in awk -


I have run a very strange behavior in awk.

The following is an input file: <

My awk script is as follows:

  / ^ / {print "ss", < / P> 
  ABCD Yes EFG Yes  

$ 2, "DD \ n"}

I hope that The following is:

  ss yes dd ss yes dd  

But, surprisingly, the result is:

  DdYes ddYes  

Where is my "ss" and how is engage in yes behind "DD"?

In the input file are DOS Newline \ r character at the end of each row Is getting the output as part of the $ 2 and reset the inclusion point to start that line, from which point to , and DD is then printed to overwrite the initial ss . (You can either modify the ss prefix or dd suffix length to look more clearly.)

Strip from and move away from it.


matlab - Using boxplot with different length of vectors -


Hi, I try to create a box plot for hourly values ​​of data for differnt months. So in one figure I have a box plot for January February March and so on ... Since the boxplaces are different in each month's hours, I always get an error.

code

  x = [n11 (:, 9) d12 (:, 9) j1 (:, 9) f2 (:, 9)] ; G = [1 2 3 4]; The size of the data:  
  J1 = 744F2 = 624D12 = 744N11 = 720     You can manually add all your data in a single vector in the same vector. 
 

Thanks Mathith

g whose label indicates which group of data points on this line, for example:

  A = Randon (10 , 1); B = Randon (12, 1); C = Randon (4, 1); G = [rep (1, [10, 1]); Repat (2, [12, 1]); Repat (3, [4, 1])]; the figure; Boxplot ([A, B, C], G);  

Editing the footer menu label in wordpress -


I want to edit footer menu text, not sub menu in WordPress. Like if the menus in the footer menu like -
Products

prod1

prod2
I do not want to change the "product" text which is not prod1 or prod2.
When I try to edit the menu in the menu, I list the menu in the dropdown but there is no provision to edit the menu label. Anyone can suggest a solution.

Thank you

You click on the "navigation labels" just carat on each navigation item Do what you want to change, and you'll see the navigation label field there.

navigation label


android - Change activity's layout by an XML string contained in main memory in runtime -


I have an activity that is displayed to the user. On the activity, I have a button every time the user pushes the button, the app will load an XML file from a remote server. The XML file is actually a layout designed for the application. After the new XML file is loaded and corrected in the new layout variable, I am showing the user who would like to set the XML file to replace the current layout.

  string newLayoutStr = ""; OnClickButton () {newLayoutStr = loadNewLayoutFromRemoteServer ();  

any comment

with this you ask Will not be possible. Android depends on resource identifiers which uses class call R which is generated automatically. The file contains the public static final int reference for different square values ​​of your code. Here can be found in the referenced sections

This class is going to be used in the context of various resources in your application, one of these is layout . Therefore, all the layouts defined in XML are expected to be included in the generated code in the R category.

So in one sentence: You will not be able to fulfill the way you want.

What I will do is a Jason reaction and it has changed into a dynamically-generated layout.

For XML, you download test.xml

  & lt; ? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; RelativeLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_height = "match_parent" android: layout_width = "match_parent" & gt; & Lt; TextView android: id = "@ + id / textViewTest" Android: layout_centerInparent = "true" Android: gravity = "center" Android: layout_height = "wrap_content" Android: layout_width = "match_parent" /> & Lt; / RelativeLayout & gt;  

If you want to create a layout created in your app, then create Jason Reaction:

  {"layout_parent": "Relative layout", "layout_heart" "Layout_width": "match_parent", "layout_children": [{"layout_children": "textviewview", "layout_child_id": "textvivestest", "layout_hete": "wrap-content", "layout_width": " Then, I will parse a model object and use that model object as your "match_part", "Layout_gravity": "center", "layout_centerInParent": "true"}]}  

To make the layout dynamically. To add the field you will need some layout defined in XML to be able to add more fields to your app.


c# - How to know when a A-Synchronous REST call in Windows 8.1 Mobile Library has been completed? -


पृष्ठभूमि ::

  1. मैं एक विंडोज 8.1 बना रहा हूँ मोबाइल एसडीके में एक लाइसेंस प्रबंधक (एलएम) मॉड्यूल होगा।
  2. जब भी एप्लिकेशन शुरू होता है, ग्राहक को अपने कोड में लाइसेंस प्रबंधक को कॉल करना होगा।
  3. लाइसेंस प्रबंधक पंजीकृत होगा क्लाइंट को भेजें और JSON रिस्पांस का एक सेट भेजें जो भविष्य की मान्यताओं के लिए डिवाइस पर संग्रहीत किया जाएगा।
  4. लाइसेंस प्रबंधक फ़ंक्शन हमारे सर्वर पर अस्थाई कॉल करता है।

< मजबूत> समस्या ::

  1. एसडीके में दिए गए लाइसेंस प्रबंधक फ़ंक्शन को कॉल करने के लिए विंडोज 8.1 के अंदर सबसे अच्छी जगह क्या होगी?
  2. कैसे करें एलएम सिंक्रोनस को कॉल करें ताकि ग्राहक को प्रतिक्रियाओं को संभालने का मौका मिलेगा यदि लाइसेंस वैध नहीं है। या इससे पहले कि ग्राहक एसडीके में शामिल अन्य एपीआई को कॉल करता है।

कार्य पूर्ण:

  1. मैंने एलएम फ़ंक्शन बनाया है और वांछित परिणाम लौटाता है।

  2. एक डेमो ऐप बनाया गया है जो बटन क्लिक करने पर एलएम कॉल करता है।

कृपया नीचे नमूना कोड ढूंढें,

क्लाइंट अनुप्रयोग:

  निजी async void Button_Click (ऑब्जेक्ट प्रेषक, RoutedEventArgs E) {try {var x = await sdk.InitializeAsync ("xxxxxxx-xxx-xxxx"); // एसडीके में शामिल एक एपीआई कॉलिंग APIResponse res = await laas.Function1_Async (par1, par2); Msg.Text = x.ToString (); } पकड़ (अपवाद पूर्व) {}}  

एसडीके:

  टास्क के & lt async सार्वजनिक; पूर्णांक & gt; InitializeAsync (स्ट्रिंग एपीकी) {int स्थिति = 0; अगर (! _िस आरंभिक) {status = GetLicenseInfo (स्थानीय सेटिंग्स) इंतजार करना; } This._isInitialized = true; वापसी स्थिति; } निजी async कार्य & lt; int & gt; GetLicenseInfo (Windows.Storage.ApplicationDataContainer स्थानीय सेटिंग) {एपीआईआरपीएसपैशन रिज़र्व = नया एपीआईआरपीएस (); Res.Status = -10; Res.Message = "अज्ञात त्रुटि!"; // वेब अनुरोध स्ट्रिंगबइल्डर डेटा = नया स्ट्रिंगबिल्डर बनाएं (); डेटा। Append (* JSON String *); स्ट्रिंग उरी = _regisUrl; का प्रयोग (एचटीटीपी क्लाइंट क्लाइंट = नया एचटीटीपी क्लाइंट ()) {उरी यूआरएल = नया उरी (उरी); स्ट्रिंग कंटेंट सामग्री = नया स्ट्रिंग कॉन्टैन्ट (डेटा। टॉस्ट्रिंग (), एन्कोडिंग.UTF8, "एप्लिकेशन / जेसन"); Client.DefaultRequestHeaders.Accept.Add (नया MediaTypeWithQualityHeaderValue ("एप्लिकेशन / जेसन")); Client.DefaultRequestHeaders.Host = url.Host; का उपयोग करके देखें {(HttpResponseMessage प्रतिक्रिया = इंतजार client.PostAsync (यूआरएल, सामग्री)) {अगर (response.IsSuccessStatusCode) {रेस = JsonConvert.DeserializeObject & LT; APIResponse & gt; (का इंतजार response.Content.ReadAsStringAsync ()); // जाँच करें कि रिस्पांस सफलता है अगर (res.Status == 1) localSettings.Values ​​[ "IsDeviceRegistered"] = StringCipher.Encrypt ( "पंजीकृत"); }}} पकड़ {}} रिटर्न res.Status; }  

किसी भी मदद की सराहना की जाएगी।

यह बदल जाएगा अपने कोड तुल्यकालिक होने के लिए ...

  टास्क & LT; पूर्णांक & gt; टी = sdk.InitializeAsync ("xxxxxxx-xxx-xxxx"); t.Wait (); Var myvalue = t.Result; .....  

actionscript 3 - Flash IDE and AS3 Blank Space -


I was working on the file 'as' and then ctrl + entered the project only one thing that I see It is empty space before the test was completely functional and visual. Is there anything about 'flay' size or something?


There is a mouse event in the very beginning and it does not go to the event function.


  Public function game () {// constructor code init (0); } Private function init (level: int): zero {switch (level) {case 0: pis = new Yesil; Yldz_bir.addEventListener (MouseEvent.CLICK, Goto First, False, 0, True); Yldz_bir.buttonMode = True; break; Case 1: Piss = New Isyl; Item_speed = 3; _pune = 0; InitialMain (); Point.texts.text = "0"; Can = 4; Main(); break; }}  


android on click list item i want to select 2 item(tick mark) -


"itemprop =" text ">

I'm a newbie, I want to ask on the click list view to mark the selection (tick) on the particular item How do I get a status on the click item. Here's my code below

  Increases the MainActivity activity of the public class {ListView listView; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.activity_main); // Get list object from XML listview = (list view) findViewById (R.id.list); // List view string to show in the string [] value = new string [] {"first name", "full name", "simple list view in android"}; ArrayAdapter & lt; String & gt; Adapter = new ArrayAdapter & LT; String & gt; (This, android.R.layout.simple_list_item_1, android.R.id.text1, value); ListView.setClickable (true); // Assign the adapter to ListView listView.setAdapter (adapter); // ListView Item Click Listener listView.setOnItemClickListener (New OnItemClickListener) {@Override Public Zero onItemClick (View AdapterView & LT;?; Gt; Parents, View, Integer Status, Long ID) {// ListView Clicked Items Index integer itemPosition = Status; / ListView clicked item value string itemValue = (string) listView.getItemAtPosition (status); // Show Warning Toast.makeText (getApplicationContext (), "Status:" + itemPosition + "ListItem:" + ItemValue, Toast.LENGTH_LONG) .show (); ListView.getAdapter (). GetView (status, empty, blank) .performClick ();}}); }}  

Thank you..Please

check sample project . It can help.


PowerShell - Remove certain string from multiple filenames -


I have multiple in the list. Are MP3 files and want to remove the artist's name from their filenames. The name of all the files includes a string

"adhesive wambet -"

After the title of the song. I want to delete every time (not replaced) of that specific string in each file name in the current folder

To not mention, I have searched the answer on this site and an elegant and satisfactory solution.

This is my first encounter with PowerShell.

As you know that you have actually Is closed

  Dir | Ren -NewName {$ _. Name - Here "Adhesive Wombat -", ""}  

You have made a condition that "adhesive vambat" can not be space or space. If the -uninstall uses regular expression, what does it exploit and ? I am also showing you the name as the full name of CMDlet so that you know about what is happening behind the scenario. It's hard to see, but I have to "pop" it in bold for ? Attempted to highlight

Get-ChildItem | Rename-item-newname {$ _. Name - Your adhesive ? Wombat - "," "}

In addition to that, depending on how much white space you can use the "Text"

Other Text Enhanced Wobbit - S + where you have a location that will consistently match the white space.


how to handle spaces in database name for Sql server CREATE TABLE? -


I have the following code and I use it in vb.net project It works well if there is no place in the database name, for example, if the name of the database is "sample company" then it works fine, but if the name of the database changes in "sample company" then we Generates an error in the command: "Start Table" & amp; Cn.Database. We should be able to handle / without database spaces without database names.

Any suggestions to solve this problem? Thank you

  cn.Database = "sample company" sqlCreate = "If not present (select notification * from Sachecha. Tablels where tabline = 'cloud_user settings' and 'tablecatOlg ='" & CN. Database & amp; "')" & amp; _ "Create tabs" & amp; Cn.Database & amp; ".dbo.Cloud_UserSetting (Cloud is not Intel, name varchar (100) No, zero," & amp; _ "varchar setting (250) NULL" & _ "CONCRETET PK_Cloud_User Primary key classification (CloudId, name)) END "Command = new SqlCommand (sqlCreate, cn) command.ExecuteNonQuery ()  

Use square brackets for column names and table names.

Example: Instead of table name : [table name]


c# - Async Await performance - Direct method call vs Task wrapper call -



c# - Async Await performance - Direct method call vs Task wrapper call -

a little programme have created understand working of async await , calling async method in loop, direct method call:

sumprogram.callsum(i, + 1);

or using task apis task.run / task.factory.startnew

my initial understanding task api create substantially faster, contrary expectation, reflect lack in understanding, direct phone call much improve in terms of performance. in fact when additional thread sleep introduced in getsum method, seems impacting task calls , big margin.

now understand first part of direct phone call beingness faster, since made execute asynchronously , there's no overhead of adding list of tasks , making them wait, when shift same technique real programming paradigm, question remains:

for direct call, there's nil emulate task.waitall, exit calling method, if executions not complete, alternative task wrapper.

am getting convoluted results, since direct phone call stopwatch publish time before executions finish , not case task wrapper due waitall

for executing program, need comment / uncomment relevant portions right results

class programme { static void main(string[] args) { programme sumprogram = new program(); list<task> tasklist = new list<task>(); // task stopwatch sw = stopwatch.startnew(); (int = 0; < 100000; i++) { tasklist.add(task.factory.startnew(() => { sumprogram.callsum(i, + 1); })); // task utilize 1 tasklist.add(task.run(() => { sumprogram.callsum(i, + 1); })); // task utilize 1 sumprogram.callsum(i, + 1); } task.waitall(tasklist.toarray()); // task sw.stop(); console.writeline("time elapsed :: " + sw.elapsedmilliseconds); } public async task callsum(int num1, int num2) { func<int> callfunc = (() => { homecoming getsum(num1, num2); }); int result = await task.run<int>(callfunc); //console.writeline("sum result :: " + result); } public int getsum(int num1, int num2) { thread.sleep(10); homecoming (num1 + num2); } }

the big problem code node of options you're using waiting callsum() complete. that, take task that's returned callsum() , wait it. example:

tasklist.add(sumprogram.callsum(i, + 1));

c# .net asynchronous task-parallel-library task

c# - Convert datatable to list with relation -



c# - Convert datatable to list with relation -

i have table(one table) it's illustration - real time table huge.

devisionid employeeid date hr 1130107 3011657 2014-10-11 8 1130107 3011657 2014-10-12 1 1130107 3011660 2014-10-11 8 1130107 3011660 2014-10-12 6

and want convert datatable list of object lists, please show me best way how this.

as illustration this

public class devision { public int id {get;set;} public list<employees> employee {get;set;} devision(int id, list<employees> emp) { id = id; employees = emp; } } public class employees { public int id {get;set;} public list<info> item {get;set;} employees(int id, list<info> info) { id = id; item = info; } } public class info { public datetime date {get;set;} public float hr {get;set;} info(datetime dtime, float hour) { date = dtime; hr = hour; } }

i object linq, , if can not queryable level(but no matter). let's start getting linq :

var mytab = table.asenumerable(); var itemses = mytab.select(

thankx.

this should want:

list<devision> devisions = table.asenumerable() .select(row => new devision( row.field<int>("devisionid"), new employees( row.field<int>("employeeid"), new info(row.field<datetime>("date"), row.field<float>("hour"))))) .tolist();

note constructors have public. also, datarow.field not casting, have provide right type or convert values target types (or alter way table filled).

now have changed question seems want grouping devisionid , employeeid , initialize list<employees> every group. have look:

list<devision> devisions = table.asenumerable() .groupby(row => new { empid = row.field<int>("employeeid"), devid = row.field<int>("devisionid")}) .select(devempgroup => new devision( devempgroup.key.devid, devempgroup .select(row => new employees( devempgroup.key.empid, new info(row.field<datetime>("date"), row.field<float>("hour")))) .tolist())) .tolist();

now property info in employees list<info> should you:

list<devision> devisions = table.asenumerable() .groupby(row => row.field<int>("devisionid")) .select(devgrp => new devision( devgrp.key, devgrp.groupby(row => row.field<int>("employeeid")) .select(g => new employees( g.key, g.select(r => new info(r.field<datetime>("date"), r.field<float>("hour"))) .tolist())) .tolist())) .tolist();

c# linq datatable ienumerable

matlab - fgoalattain, weight goal multiobjective -



matlab - fgoalattain, weight goal multiobjective -

i have multi objective problem in have minimize vector function f=[f1 f2 f3]. code:

tau=4628; b=1.76*10^-4; b0=0; b1=1/tau+b/3; b2=1/tau+b*2/3; b3=1/tau+b; kk=0; x=726.2083 % tried first objective simplicty goal = [2.5]% 0 0] %weight=[ 1 1 1] weight=abs(goal); k0=1; lb=0.0; ub=b3; options=optimset('display','iter'); %vector fun objective vec_fun=@(k1) [k1*x];% abs(k1-kk) abs(k1)]; [x1,fval]=fgoalattain(vec_fun,k0,goal,weight,[],[],[],[],[],[],[],options) k1=x1 if k1==0 k1=b0; elseif k1 >b0 && k1 <= b1 k1=b1; elseif k1 >b1 && k1 <= b2 k1=b2; elseif k1 > b2 && k1 <= b3 k1=b3; else k1=0; end k=k1;

code don't work. homecoming me

x1 =-6.8245e+23 fval = -4.9560e+26 k1 = -6.8245e+23

why fval != goal?

thank you, sorry bad english.

matlab

How can I trigger multiple remote shell scripts in bash to run concurrently and then wait for them to complete? -



How can I trigger multiple remote shell scripts in bash to run concurrently and then wait for them to complete? -

i have bash script runs number of tasks on remote machines via ssh. each script quite long i'd run them concurrently background tasks. need them finish before moving on. know can utilize wait command latter when stick & @ end create background task, stops working.

by stop working, mean scripts don't seem have run, otherwise main script still completes.

ssh root@machine1 'bash -s' < script1 my_parameter ssh root@machine2 'bash -s' < script2 my_parameter ssh root@machine3 'bash -s' < script3 my_parameter wait some_other_task

this works fine me ubuntu 11.04:

#!/bin/bash ssh user@server1 <command.sh & ssh user@server2 <command.sh & ssh user@server3 <command.sh & wait echo end

content of command.sh:

sleep 5 hostname

update:

with commandline arguments gets more complicated. can utilize "here-document" , set set $1 $2 $3.

#!/bin/bash ssh -t root@server1 << eof #!/bin/bash set -- $my_parameter1 $my_parameter2 $my_parameter3 $(cat script1) eof ssh -t root@server2 << eof #!/bin/bash set -- $my_parameter1 $my_parameter2 $my_parameter3 $(cat script2) eof ssh -t root@server3 << eof #!/bin/bash set -- $my_parameter1 $my_parameter2 $my_parameter3 $(cat script3) eof wait echo end

bash shell ssh concurrency

javascript - Cannot create Object of function defined in closure? -



javascript - Cannot create Object of function defined in closure? -

why can't create object function defined in closure?

var outer = function() { var constructor = function() { this.foo = 1; }; homecoming constructor; }; // should be: { foo: 1 }, is: undefined var constructorobject = new outer()(); // works var c = outer(); var constructorobject = new c();

you need wrap outer function phone call in parenthesis so:

var constructorobject = new (outer())(); // ^ ^ parenthesis here console.log(constructorobject); // constructor {foo: 1} console.log(constructorobject.foo); // 1

javascript

memory - Printing whenever a python object is freed? -



memory - Printing whenever a python object is freed? -

i assure several numpy arrays i'm allocating freed.

i'm curious there module allow me track object , print whenever memory de-allocated.

for context i'm asking question because when reach point in programme scheme monitor shows python using 300ishmb. execute 2 commands: first creates list of numpy arrays comes 1gb in size. next command performs vstack on list farther increases memory 1gb. take big numpy array, math reply 1mb (8000 x 128 uint8 ndarray). other arrays no longer needed, should unallocated @ end of function. however, after homecoming function , collect garbage i'm still left python using 1gb of memory. did 700mb come from!?

i'll farther illustrate illustration sudo-code

def myfunc(api): # gets list of 1000 1mb arrays list_ = api.get_arrays() # stacks big 1gb array bigarray = np.vstack(list_) # summarizes big array using 1mb smallarray = api.cluster(bigarray) # shouldn't need del statements del list_ del bigarray homecoming smallarray def main(): # preprocessing stuff , have 300mb in memory # costs 2gb run function, should freed @ end smallarray = myfunc(api) # there 700mb of memory allocated! did come from!?

to debug thinking useful ensure numpy arrays gone. maybe has improve idea, @ to the lowest degree has idea.

python memory memory-management numpy

algorithm - Find set difference between two integer intervals -



algorithm - Find set difference between two integer intervals -

i've faced problem. had find set difference between 2 integer intervals. interval determined 2 borders - high , low. high point isn't included.

well came solution, consider several cases. of sudden it's ~12 cases. listed of them below. looks wierd. there simpler solution?

//a[ a) b[ b) // [ ) if (a._end <= b._start) homecoming lst(a); //a[ b[ a) b) // [ ) if (a._start < b._start && b._start < a._end && b._start < a._end && a._end < b._end) homecoming lst(rng(a.start(), b.start())); //b[ a[ b) a) // [ ) if (b._start < a._start && a._start < b._end && a._start < b._end && b._end < a._end) homecoming lst(rng(b.end(), a.end())); //b[ b) a[ a) // [ ) if (b._end <= a._start) homecoming lst(a); //a[ b[ b) a) // [ ) [ ) if (a._start < b._start && b._start < a._end && a._start < b._end && b._end < a._end) homecoming lst( rng(a.start(), b.start()), rng(b.end(), a.end()));

(i don't see why decided generate such redundant conditions ... b._start < a._end && b._start < a._end ...)

among other things, code made more complicated attempts build entire result within single homecoming statement. if build result incrementally in local variable , homecoming local variable, code simplified.

relying on standard functions min , max instead of embedding min/max logic code create much more compact.

let's build result in local list variable result , append intervals doing result.append().

the difference operation can produce 2 intervals: 1 left of b, right of b. let's calculate them in order

list result; if (a._start < b._start) // left portion exists result.append(rng(a._start, min(a._end, b_start))); if (a._end > b._end) // right portion exists result.append(rng(max(a._start, b._start), a._end)); homecoming result;

i assumed intervals normalized, i.e. a._start <= a._end, seems code relies on assumption.

algorithm

css - Positioning content in :after pseudo-element absolutely relative to an inline elements top edge -



css - Positioning content in :after pseudo-element absolutely relative to an inline elements top edge -

i'm looking css-only way position content in :after pseudo element absolutely relative - possibly multiline - element's top edge. result should resemble this:

usually there's no rocket science involved archieve this, i'd find solution meets next criteria:

do not utilize :before pseudoelement (this needed accomplish other independent thing), do not utilize display: block/inline-block; on inline element (because creates ugly holes in text flow), allow define width of elements percentage of containing element (at to the lowest degree after applying rule of three), do not hardcode top position/margin/padding of :after-pseudo-element in way makes dependent of parent element's position within grandparent element, parent element's height or actual element's height (or create short: don't create dependent of content), do not insert additional html elements, and do not add together js.

i created codepen makes easier grasp i'm going here.

i know possible result violating 1 of restrictions listed above (as demonstrated in codepen), i'm looking elegant solution problem not needed.

after playing around quite while i'd not possible, great if convince me of contrary - or @ to the lowest degree formally proves impossible. lot help in advance.

well, possible solution wanted method this. - first mention, work you'd need define ::after content straight in css, not through data- attribute. (i don't know why, seems parsing problem.) - set position:relative .wrapper. you're going move ::after left-right based on parent (not direct one). - set width: 100% ::after (100% of parent) - set white-space: pre ::after - this important - write content straight using \a (escape character) break word in particular places. - set top: 0 , give negative right position (how far want)

note: might need set word-wrap: break-word on elemenets if additional text overflowing out of wrapper.

basically, addition/modification css:

.wrapper { position: relative; } .accent::before{ position: absolute; width: 100%; content: "unfortunately \a aligned \a lastly line of said span."; white-space: pre; right: -70%; } .content p { word-wrap: break-word; /* in illustration <p> problematic */ }

note: don't know how method responsive designs, never tried way.

tested on ff , chrome. live example

edit: hm, yeah, started ::after accident switched ::before =)

alright, minor modifications css:

- instead of width: 100% set width: auto - instead of top: 0 need manually (sorry) cut down margin-top: -(number)px - don't use top it's gonna set top position based on wrapper itself. - switch right: -(number)% right: -(number)px

css modification:

.accent::after{ width: auto; right: -50px; margin-top: -40px; /* , remove "top" property */ }

live example

another edit cleaner working solution can utilize content: attr(data-meta) (removed white-space: pre , set width wanted percentage size:

.accent::after{ position: absolute; width: 30%; content: attr(data-meta); right: -50px; margin-top: -40px; }

live example

css css3 layout css-position pseudo-element

Understanding the Api in PHP -



Understanding the Api in PHP -

a beginner here.

i have checked forum find out answers not successful, question on 1 line of code. hope no 1 mark question duplicate in learning curve. 2 problems here:

what meaning of piece of code? understand making new object api reserved word? none for? $user = new api('none','none');

i understand api please introduce resource explains api beginners? not understand concept of apis.

your help appreciated.

api not reserved keyword in php

this creating new instance of api, should somewhere in codebase or include path. @ it's constructor find out why parameters passed.

also, beingness beginner not excuse posting duplicate questions ;)

php api

swing - How to remove part of a message java.lang.IllegalArgumentException on Excpetion handling -



swing - How to remove part of a message java.lang.IllegalArgumentException on Excpetion handling -

i'm developping swing application, form on process several validations using exceptions. knowing since java 7 possible utilize mutli-catch statement, used improve code, since stacktrace begins :

"java.lang.exeption :" + handling exception message.

how remove "java.lang.exeption :" of message ?

here illustration of validations , execution.

actionevent:

public void actionperformed(actionevent arg0){ //validation 1 nomegrupovazio(string1); //validation 2 validastring(string2); //validation 3 diferenciarrms(int1, int2, int3, int4); }

valitadions:

private void nomegrupovazio(string nome) { if (nome.isempty()) { throw new illegalargumentexception("preencha o nome grupo!"); } } private void validastring(string s) { pattern pattern = pattern.compile("[0-9]"); matcher matcher = pattern.matcher(s); if (matcher.find()) { throw new illegalargumentexception( "por favor digite apenas caracteres não numéricos nos campos referentes aos nomes"); } } private void diferenciarrms(int rm1, int rm2, int rm3, int rm4) { if (rm4 == 0) { if (rm1 == rm2 || rm1 == rm2 || rm1 == rm3 || rm2 == rm3) { throw new illegalargumentexception( "todos os rm's precisam ser diferentes"); } } else if (rm1 == rm2 || rm1 == rm3 || rm1 == rm4 || rm2 == rm3 || rm2 == rm4 || rm3 == rm4) { throw new illegalargumentexception( "todos os rm's precisam ser diferentes"); }

thanks in advance!

i guess, using exception#tostring() exception message. seek using exception#getmessage() instead.

exception ex = new illegalargumentexception("my error message!"); system.out.println(ex.tostring()); system.out.println(ex.getmessage());

hope helps.

java swing exception-handling java-7

libgdx - Android: UNEXPECTED TOP-LEVEL EXCEPTION -



libgdx - Android: UNEXPECTED TOP-LEVEL EXCEPTION -

i got error while compiling libgdx project gradle.

execution failed task ':android:predexamazondebug'. > com.android.ide.common.internal.loggederrorexception: failed run command: /sdk-path/android/build-tools/21.0.1/dx --dex --output /path/android/build/intermediates/pre-dexed/amazon/debug/core-1.0-47e2423a0159bad5774996683a8ab834009ab7ed.jar /path/core/build/libs/core-1.0.jar error code: 1 output: unexpected top-level exception: com.android.dx.cf.iface.parseexception: bad class file magic (cafebabe) or version (0034.0000) @ com.android.dx.cf.direct.directclassfile.parse0(directclassfile.java:472) @ com.android.dx.cf.direct.directclassfile.parse(directclassfile.java:406) @ com.android.dx.cf.direct.directclassfile.parsetointerfacesifnecessary(directclassfile.java:388) @ com.android.dx.cf.direct.directclassfile.getmagic(directclassfile.java:251) @ com.android.dx.command.dexer.main.processclass(main.java:704) @ com.android.dx.command.dexer.main.processfilebytes(main.java:673) @ com.android.dx.command.dexer.main.access$300(main.java:82) @ com.android.dx.command.dexer.main$1.processfilebytes(main.java:602) @ com.android.dx.cf.direct.classpathopener.processarchive(classpathopener.java:284) @ com.android.dx.cf.direct.classpathopener.processone(classpathopener.java:166) @ com.android.dx.cf.direct.classpathopener.process(classpathopener.java:144) @ com.android.dx.command.dexer.main.processone(main.java:632) @ com.android.dx.command.dexer.main.processallfiles(main.java:510) @ com.android.dx.command.dexer.main.runmonodex(main.java:279) @ com.android.dx.command.dexer.main.run(main.java:245) @ com.android.dx.command.dexer.main.main(main.java:214) @ com.android.dx.command.main.main(main.java:106) ...while parsing org/mars3142/ownclass.class 1 error; aborting

i didn't include core twice android project. double checked, if include external libs, seems, own project failure, can't understand, because never changed something. added android-wear project project. , if go time (with git), not compileable.

edit: if nail run in intellij same build variant (amazondebug) works expected. that's strange.

android libgdx android-gradle

LDAP over SSL with Java -



LDAP over SSL with Java -

the next code works fine:

public static void main(string[] args) { string username = "admin"; string password = "s3cret"; hashtable env = new hashtable(); env.put(context.initial_context_factory, "com.sun.jndi.ldap.ldapctxfactory"); env.put(context.provider_url, "ldap://192.168.10.45:389/dc=softwaredev,dc=local"); //env.put(context.security_protocol, "ssl"); env.put(context.security_authentication, "simple"); env.put(context.security_principal, new string("softwaredev" + "\\" + username)); env.put(context.security_credentials, password); dircontext ctx = null; namingenumeration results = null; seek { ctx = new initialdircontext(env); searchcontrols controls = new searchcontrols(); controls.setsearchscope(searchcontrols.subtree_scope); results = ctx.search("", "(objectclass=person)", controls); while (results.hasmore()) { searchresult searchresult = (searchresult) results.next(); attributes attributes = searchresult.getattributes(); system.out.println(" person mutual name = " + attributes.get("cn")); system.out.println(" person display name = " + attributes.get("displayname")); system.out.println(" person logonhours = " + attributes.get("logonhours")); system.out.println(" person memberof = " + attributes.get("memberof")); } } grab (throwable e) { e.printstacktrace(); } { if (results != null) { seek { results.close(); } grab (exception e) { } } if (ctx != null) { seek { ctx.close(); } grab (exception e) { } } } }

if uncomment next line: env.put(context.security_protocol, "ssl"); enable ssl connection , utilize url:

ldaps://192.168.10.45:636

then programme fails , error certificate.

*javax.naming.communicationexception: simple bind failed: 192.168.10.45:636 [root exception javax.net.ssl.sslhandshakeexception: sun.security.validator.validatorexception: pkix path building failed: sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target] @ com.sun.jndi.ldap.ldapclient.authenticate(unknown source) @ com.sun.jndi.ldap.ldapctx.connect(unknown source) @ com.sun.jndi.ldap.ldapctx.<init>(unknown source) @ com.sun.jndi.ldap.ldapctxfactory.getusingurl(unknown source) @ com.sun.jndi.ldap.ldapctxfactory.getusingurls(unknown source) @ com.sun.jndi.ldap.ldapctxfactory.getldapctxinstance(unknown source) @ com.sun.jndi.ldap.ldapctxfactory.getinitialcontext(unknown source) @ javax.naming.spi.namingmanager.getinitialcontext(unknown source) @ javax.naming.initialcontext.getdefaultinitctx(unknown source) @ javax.naming.initialcontext.init(unknown source) @ javax.naming.initialcontext.<init>(unknown source) @ javax.naming.directory.initialdircontext.<init>(unknown source) @ asd.ldapbasicexample.main(ldapbasicexample.java:25) caused by: javax.net.ssl.sslhandshakeexception: sun.security.validator.validatorexception: pkix path building failed: sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target @ sun.security.ssl.alerts.getsslexception(unknown source) @ sun.security.ssl.sslsocketimpl.fatal(unknown source) @ sun.security.ssl.handshaker.fatalse(unknown source) @ sun.security.ssl.handshaker.fatalse(unknown source) @ sun.security.ssl.clienthandshaker.servercertificate(unknown source) @ sun.security.ssl.clienthandshaker.processmessage(unknown source) @ sun.security.ssl.handshaker.processloop(unknown source) @ sun.security.ssl.handshaker.process_record(unknown source) @ sun.security.ssl.sslsocketimpl.readrecord(unknown source) @ sun.security.ssl.sslsocketimpl.performinitialhandshake(unknown source) @ sun.security.ssl.sslsocketimpl.readdatarecord(unknown source) @ sun.security.ssl.appinputstream.read(unknown source) @ java.io.bufferedinputstream.fill(unknown source) @ java.io.bufferedinputstream.read1(unknown source) @ java.io.bufferedinputstream.read(unknown source) @ com.sun.jndi.ldap.connection.run(unknown source) @ java.lang.thread.run(unknown source) caused by: sun.security.validator.validatorexception: pkix path building failed: sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target @ sun.security.validator.pkixvalidator.dobuild(unknown source) @ sun.security.validator.pkixvalidator.enginevalidate(unknown source) @ sun.security.validator.validator.validate(unknown source) @ sun.security.ssl.x509trustmanagerimpl.validate(unknown source) @ sun.security.ssl.x509trustmanagerimpl.checktrusted(unknown source) @ sun.security.ssl.x509trustmanagerimpl.checkservertrusted(unknown source) ... 13 more caused by: sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target @ sun.security.provider.certpath.suncertpathbuilder.enginebuild(unknown source) @ java.security.cert.certpathbuilder.build(unknown source)*

so, can solve problem?

caused by: sun.security.validator.validatorexception: pkix path building failed: sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target

your client truststore doesn't trust ldap server's certificate. need either signed ca or else export server client truststore. easier , cheaper signed.

java ssl ldap

c++ - position of an QGraphicsItem in scene always null -



c++ - position of an QGraphicsItem in scene always null -

for testing purposes, trying draw several rectangle on scene , add together text inside. rectangle supposes displayed in 1 column do, problem text don't. text stacked on top left of scene. futhermore, pos() , scenepos() homecoming (0,0) every boxes , texts.

here code responsible that. can tells i'm doing wrong?

qhash<qstring,picto> palette::getpics(){ spritesheetmanager ssm("sprite_zone"); qlist<qstring> picnames = ssm.finder->allpic(); //get string displayed qhash<qstring,picto> piclist; for(int = 0; < picnames.size(); i++){ qstring picname = picnames.at(i); qgraphicstextitem *label = new qgraphicstextitem(); label->setplaintext(picname); qgraphicsrectitem *rect = new qgraphicsrectitem(); rect->setrect(0,i*20,50,20); label->setparentitem(rect); label->setpos(0,0); this->additem(rect); qdebug()<< rect->pos(); //always homecoming (0,0) } homecoming piclist; }

i've tried code several variation, can't solve this.

try this:

for(int = 0; < 5; i++){ qstring picname = "sample"; qgraphicstextitem *label = new qgraphicstextitem(); label->setplaintext(picname); qgraphicsrectitem *rect = new qgraphicsrectitem(); rect->setrect(0,i*50,50,20); label->setparentitem(rect); label->moveby(0,i*50);//new //or label->setpos(0,i*50); this->additem(rect); qdebug()<< rect->pos(); }

output of qdebug()<< rect->rect()<< label->scenepos();

qrectf(0,0 50x20) qpointf(0, 0) qrectf(0,50 50x20) qpointf(0, 50) qrectf(0,100 50x20) qpointf(0, 100) qrectf(0,150 50x20) qpointf(0, 150) qrectf(0,200 50x20) qpointf(0, 200)

result:

edit:

calling setrect() on qgraphicsrectitem not alter pos(), changes position of rectangle draws, item's position unchanged. can set rect (0, 0) , phone call setpos() move item want. next code different result on scene absolutely same.

for(int = 0; < 5; i++){ qstring picname = "sample"; qgraphicsrectitem *rect = new qgraphicsrectitem(); qgraphicstextitem *label = new qgraphicstextitem(); label->setplaintext(picname); rect->setrect(0,0,50,20); rect->setpos(0,i*50); //rect->moveby(0,i*50); label->setparentitem(rect); //label->setpos(0,i*50); this->additem(rect); }

in case pos() returns right value

c++ qt qgraphicsitem

jquery - Wait to for loop finish job -



jquery - Wait to for loop finish job -

i seek create table code, not going well.

i have array in witch generate code part of table:

list.push("<tr><td colspan=\"5\">"); (k = 0; k < finallist.length; k++) { list.push(finallist[k]); } list.push("</td></tr>");

on end append table like:

$("#commenttable tbody").append(list);

lets in array finallist have divs images inside. illustration images in multiple divs illustration :

when run code , utilize inspect element code generated like

<tr><td colspan="5"></td></tr> <div><img src="1.jpg" /></div> <div><img src="2.jpg" /></div>

etc...

like work async , working while line list.push("</td></tr>"); finish.

i hope clear. can resolve this?

thanx

your code should work, cycles not start separate threads.

why not simplify , utilize simple string?

var s = "<tr><td colspan=\"5\">"; for(var k=0; k<finallist.length; k++){ s += finallist[k]; } s += "</td></tr>";

or can do

var s = '<tr><td colspan="5">' + finallist.join('') + '</td></tr>';

and then

$("#commenttable tbody").append(s);

jquery

sql - ADO.NET retrieve a user from the database with a query -



sql - ADO.NET retrieve a user from the database with a query -

i have used linq info sql. it's fast , easy utilize i've heard requires more resource server compared normal queries.

so.. i'm trying improve queries now..

what want retrieve user database, query.

is possible this:

user model:

[key] public int userid { get; set; } public string username { get; set; } public string password { get; set; } public string passwordsalt { get; set; } public string money { get; set; }

query:

public user getuser(string username) { string sql = "select * users username = @username"; user user = null; using (sqlconnection connection = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring)) { seek { sqlcommand cmd = new sqlcommand(sql, connection); cmd.parameters.add("@username", sqldbtype.varchar, 12).value = username; connection.open(); user = (user)cmd.executereader(); } grab { } } homecoming user; }

or forced utilize datareader , insert every cell new user model, , homecoming it?

//newbie

update 1:

how proceed if want result genericcollection of user model?

a sqldatareader handle results, kind of cursor. need step through , pick out values, indexed result's column names. seek this:

public user getuser(string username) { string sql = "select * users username = @username"; user user = null; using (sqlconnection connection = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring)) { seek { sqlcommand cmd = new sqlcommand(sql, connection); cmd.parameters.add("@username", sqldbtype.varchar, 12).value = username; connection.open(); sqldatareader dr = cmd.executereader(); if (dr.read()) { // you're pointed @ first result row user = new user { userid = dr["userid"], name = dr["name"], whatever = dr["whatever"] }; } } grab { } } homecoming user; }

also, ado.net recommends using parameters.addwithvalue method. find lot easier because don't have deal types , lengths , forth, , i've never had problems results. so, instead of this:

cmd.parameters.add("@username", sqldbtype.varchar, 12).value = username;

you can utilize this:

cmd.parameters.addwithvalue("@username", username);

sql sql-server asp.net-mvc ado.net

multithreading - Why can't URI object locate method "scheme"? -



multithreading - Why can't URI object locate method "scheme"? -

i trying create asynchronous http request client using next source code:

#!perl utilize uri; utilize ddp; utilize threads; utilize thread::queue; utilize lwp::useragent; utilize constant num_workers => 25; $req_q = thread::queue->new(); $res_q = thread::queue->new(); @urls = ( "http://google.com", "http://web.de" ); @workers; ( 1 .. num_workers ) { force @workers, async { $ua = lwp::useragent->new(); while ( $req = $req_q->dequeue() ) { $res_q->enqueue( $ua->request($req) ); } }; } $url (@urls) { $req_q->enqueue( http::request->new( => $url ) ); } $req_q->enqueue(undef) @workers; ( 1 .. @urls ) { $res = $res_q->dequeue(); p $res; } $_->join() @workers;

unfortunately receive error:

400 can't locate object method "scheme" via bundle "uri::http"

this should uri module issue if utilize uri bundle in other scripts works fine.

i tried upgrade uri uri-1.64 (upgraded 1.60) tested on fedora (x86_64 gnu/linux) perl 5.16 , on ubuntu (i686 athlon i386 gnu/linux) perl 5.14.

e.g

$perl -muri -e'say $inc{"uri.pm"}; uri->version; uri->new("http://www.google.com/")->scheme' $/home/xxxxx/perl5/lib/perl5/uri.pm $1.64 $http

any thought best way troubleshoot?

the original code used thread::queue::any instead of thread::queue since handles objects bit better. however, there 2 mistakes in original code (now fixed).

use thread::queue::any 1.03 qw( ); ... $req_q = thread::queue->new(); $res_q = thread::queue->new();

should be

use thread::queue::any 1.03; # must phone call import. ... $req_q = thread::queue::any->new(); $res_q = thread::queue::any->new();

thread::queue::any work in import shouldn't there, customary practice of not calling import backfired.

these minor changes allow code work.

if wanted go on using thread::queue, looks have load modules of shared objects before phone call use threads; (i think that'll save memory, it's thought no matter what.) uri dynamically loads uri::http, need add together

use uri::http;

or

begin { uri->new('', 'http') }

before use threads;

that passed problem (and another).

multithreading perl http asynchronous

mysql - PHP check if value exists -



mysql - PHP check if value exists -

i’m trying write if code, can't figure out how.

in database table have primary key id. in table have objekt_nr & element_nr. now, before phone call instert need check if objekt_nr element_nr exist. if objekt_nr element_nr exist. update instead of instert. id can unique.

example of table:

id......objekt_nr......element_nr

1.......1...............1

2.......1...............2

3.......1...............3

4.......2...............1

5.......2...............2

php:

if(isset($_post["import"])){ echo '<a href=".php">fortsätt...</a><br />'; echo $path=$_files["file"]["tmp_name"]; //load file phpexcel $objphpexcel = phpexcel_iofactory::load($path); //loop threw file info foreach ($objphpexcel->getworksheetiterator() $worksheet) { $worksheettitle = $worksheet->gettitle(); $highestrow = $worksheet->gethighestrow(); // e.g. 10 $highestcolumn = 'j'; //$worksheet->gethighestcolumn(''); // e.g 'f' $highestcolumnindex = phpexcel_cell::columnindexfromstring($highestcolumn); $nrcolumns = ord($highestcolumn) - 64; //echo file info echo "<br>the worksheet ".$worksheettitle." has "; echo $nrcolumns . ' columns (a-' . $highestcolumn . ') '; echo ' , ' . $highestrow . ' row.'; echo '<br>data: <table border="1"><tr>'; //loop threw colum, rows , cells ($row = 2; $row <= $highestrow; ++ $row) { echo '<tr>'; ($col = 0; $col < $highestcolumnindex; ++ $col) { $cell = $worksheet->getcellbycolumnandrow($col, $row); $val = $cell->getcalculatedvalue(); //$datatype = phpexcel_cell_datatype::datatypeforvalue($val); echo '<td>' . $val . '<br></td>'; } echo '</tr>'; } echo '</table>'; } ($row = 2; $row <= $highestrow; ++ $row) { $val=array(); ($col = 0; $col < $highestcolumnindex; ++ $col) { $cell = $worksheet->getcellbycolumnandrow($col, $row); $val[] = $cell->getcalculatedvalue(); } // prepare query $query = "insert phpexcel( objekt_nr, objekt_rev, element_nr, element_hojd, element_typ, element_langd, element_oppningar, element_vikt, element_ritare, element_status) values ( :objekt_nr, :objekt_rev, :element_nr, :element_hojd, :element_typ, :element_langd, :element_oppningar, :element_vikt, :element_ritare, :element_status )"; // security measures $query_params = array( ':objekt_nr' => $val[0], ':objekt_rev' => $val[1], ':element_nr' => $val[2], ':element_hojd' => $val[3], ':element_typ' => $val[4], ':element_langd' => $val[5], ':element_oppningar' => $val[6], ':element_vikt' => $val[7], ':element_ritare' => $val[8], ':element_status' => $val[9] ); seek { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(pdoexception $ex){ die("failed run query: " . $ex->getmessage()); } //echo $query."\n"; } }

two options here.

1) create "objekt_nr" field primary or unique key , utilize replace instead of insert (http://dev.mysql.com/doc/refman/5.0/en/replace.html). pretty much @hd 's reply in comments.

2) check existing "objekt_nr" , "element_nr" , run appropriate query

$check_duplicate_query = "select count(*) phpexcel objekt_nr = ':objekt_nr' , element_nr = ':element_nr'"; $stmt = $db->prepare($check_duplicate_query); $result = $stmt->execute($query_params); $rows = $stmt->fetch(pdo::fetch_num); if($rows[0] > 0) { //update } else { //insert } $stmt = $db->prepare($query); $result = $stmt->execute($query_params);

edit:

just thought of 3rd option

create field "objekt_element_nr" , set field unique. field gets assigned objekt , element number combination, illustration should unique.

e.g. 1_1, 1_2, 1_3, 2_1, 2_2, etc.

then utilize replace function linked above.

your $query_params like

$query_params = array( ':objekt_nr' => $val[0], ':objekt_rev' => $val[1], ':element_nr' => $val[2], ':objekt_element_nr' => $val[0].'_'.$val[2] ':element_hojd' => $val[3], ':element_typ' => $val[4], ':element_langd' => $val[5], ':element_oppningar' => $val[6], ':element_vikt' => $val[7], ':element_ritare' => $val[8], ':element_status' => $val[9] );

php mysql

cocoa - Notification when the system is idle or not on OS X -



cocoa - Notification when the system is idle or not on OS X -

i know there way scheme idle time iokit framework on os x, want know if there's notifications available.

i can create timer check if idle time more x, , that's fine. doesn't matter if observe idle mode few seconds later.

the problem observe when mac not idle anymore. want app show notification possible, not few seconds later.

is there way have notification that? (ichat seems have one)

this http://developer.apple.com/library/mac/#qa/qa1340/_index.html (from bill lizard comment)

- (void) receivesleepnote: (nsnotification*) note { nslog(@"receivesleepnote: %@", [note name]); } - (void) receivewakenote: (nsnotification*) note { nslog(@"receivewakenote: %@", [note name]); } - (void) filenotifications { //these notifications filed on nsworkspace's notification center, not default // notification center. not receive sleep/wake notifications if file //with default notification center. [[[nsworkspace sharedworkspace] notificationcenter] addobserver: self selector: @selector(receivesleepnote:) name: nsworkspacewillsleepnotification object: null]; [[[nsworkspace sharedworkspace] notificationcenter] addobserver: self selector: @selector(receivewakenote:) name: nsworkspacedidwakenotification object: null]; }

cocoa osx notifications python-idle

django - python-social-auth creates an additional user account without uid and email address -



django - python-social-auth creates an additional user account without uid and email address -

i using python-social-auth allow users log in using social accounts. went admin see accounts , noticed there's business relationship there has randomly generated username. doesn't have email, first name or lastly name associated it. in usersocialauth doesn't have uid associated either. wondering did business relationship appear from?

here current settings:

installed_apps = ( 'social.apps.django_app.default', ) authentication_backends = ( 'social.backends.google.googleoauth2', 'django.contrib.auth.backends.modelbackend', ) template_context_processors = ( 'social.apps.django_app.context_processors.backends', 'social.apps.django_app.context_processors.login_redirect', ) google_extended_permissions = ['email']

i have keys google backend specified too, of course. wondering business relationship coming , should maintain it?

django google-oauth python-social-auth