pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
7,457,298 | 0 | Why is the NTOSKRNL.exe IMAGE_MACHINETYPE header field set to x86 on only certain editions of Windows 7 x64? <p>I am using windows 7 home premium x64. I was wondering why exactly the IMAGE_MACHINETYPE field in the header of ntoskrnl in my system32 directory specifies x86. IDA will even let me disassemble it as native x86.</p> <p>Yet on my windows 7 pro machine, image_machinetype is x64. Am I just missing something.. or why is ntoskrnl 32 bit on a 64 bit OS?</p> |
36,208,800 | 0 | Azure Web App Deploy via FTP Credential not Working <p>I have built a web app in ARM (new Portal) with the SDK, and downloaded the Publishing Profile XML file. Inside it has an FTP element with attributes for FTP user name and password. I can log in with those credentials but not upload files - access denied. I cannot delete the hostingstart.html file either. Getting a "dir" on the FTP site works, so I know my credentials are being accepted.</p> <p>I can see in the Portal GUI that there is an FTP user name, but I do not know its password and it does not match what is in the Publishing Profile XML.</p> <p>I am trying to provision a brand new web app with the SDK and upload local-built content, completely unattended. How can I make this happen?</p> <p>Thanks.</p> |
32,283,319 | 0 | How to get and change a variable in my view controller from SKScene <p>Ok so here is the code</p> <pre><code>class GameViewController: UIViewController, SceneTransitionDelegate, GKGameCenterControllerDelegate, ADBannerViewDelegate { var coolbool:Bool = false ...abunch of unimportant stuff functions and stuff } </code></pre> <p>And here is what I am trying to do from my SKScene</p> <pre><code>func thing1() { let controller = GameViewController() controller.coolbool = true println(controller.coolbool) // Will say that it is true sceneDelegate.transitionToScene(Menu.self) //Menu.self is the skscene that we used to be in and will be in } func thing2() { println(controller.coolbool) // Will say that it is false if (controller.coolbool == true) { //Put rainbows over every sprite and change generator settings } } </code></pre> <p>So basically what happens is that "coolbool" is initialized as being false. Until thing1() is called causing the variable "coolbool " to change. And i confirm its change immediately after, before the transition. However after the transition (to the same scene (I'm trying to make it look different if the bool is true)) if you ask what the value is, it says its false.... even though i just set it to true.</p> <p>Anyway I assume I am doing something wrong, is their a better way to do this??? Incase you want it here is the transition function</p> <pre><code>func transitionToScene(sceneClass:Scene.Type) { playing = false var sizeRect = UIScreen.mainScreen().applicationFrame var width = sizeRect.size.width * UIScreen.mainScreen().scale var height = sizeRect.size.height * UIScreen.mainScreen().scale let skView = self.view as! SKView let scene = sceneClass(size: skView.bounds.size) scene.size = CGSizeMake(width, height) rwidth = width rheight = height swidth = width sheight = height skView.ignoresSiblingOrder = true scene.scaleMode = .AspectFill scene.sceneDelegate = self skView.presentScene(scene) } </code></pre> |
39,982,831 | 0 | <p>To assign the output of a command to a variable, wrap the command in backticks or <code>$()</code>.</p> <pre><code>RESULT=$(cat $LOGFILE | tail -1) </code></pre> <p>Your command performed the environment variable assignment <code>RESULT=cat</code>, and then executed the command <code>$LOGFILE | tail -1</code> in that environment. Since <code>$LOGFILE</code> is not an executable file, you got an error.</p> |
5,562,991 | 0 | <p>I assume you have a problem with the webroot, i.e. public_html/webtest is set as a root of your site and thus anything outside this folder is not accessible for the app.</p> <p>Can you verify this?</p> |
25,071,323 | 0 | <p>You don't. Its a dialog from another app, you can't close it. Which is why the general rule is not to use USSD for anything in Android- not only is it not portable across carriers, but there is no real USSD API- you can just sort of kind of hack some of it together (not to mention that USSD is a hack itself that should die now that web services and data connections exist).</p> |
21,147,959 | 0 | Add .com to end of my string in php <p>What I'm trying to is search my string to see if there is any of the following arrays there</p> <p>if not then we need to add .com to end of it.</p> <p>$kwlines is my string and i have set it to test but this is what I get </p> <blockquote> <p>test.comtest.com.comtest.com.com.comtest.com.com.com.comtest.com.com.com.com.comtest.com.com.com.com.com.comtest.com.com.com.com.com.com.com</p> </blockquote> <pre><code>foreach ($kwlines as $kw) { $owned_urls= array('.com', '.co.uk', '.net','.org', '.gov','.gov.co.uk','.us'); foreach ($owned_urls as $url) { if (strpos($kw, $url) !== TRUE) { $kw .= ".com"; echo "$kw"; } } </code></pre> <p>Could you please help me understand what I do wrong?</p> <p>Thank you</p> |
37,869,545 | 0 | <p>You will need to overwrite the "<strong>tokenServerEncodedUrl</strong>" parameter value in the GoogleCredential object, and "<strong>rootUrl</strong>" parameter value in the Directory object for using your non-standard SSH Tunnel Ports for GoogleAPI client communication.</p> <p>Use the following code snippet to achieve it:</p> <p>GoogleCredential credential = (new com.google.api.client.googleapis.auth.oauth2.GoogleCredential.Builder()).setTransport(httpTransport).setJsonFactory(jsonFactory).<strong>setTokenServerUrl(new GenericUrl("<a href="https://accounts.google.com:ssh-port/o/oauth2/token" rel="nofollow">https://accounts.google.com:ssh-port/o/oauth2/token</a>"))</strong>.setServiceAccountUser(ACCT_USER).setServiceAccountId(ACCT_ID).setServiceAccountScopes(SCOPES).setServiceAccountPrivateKeyFromP12File(p12).build();</p> <p>Directory service = (new com.google.api.services.admin.directory.Directory.Builder(httpTransport, jsonFactory, null)).setHttpRequestInitializer(credential).<strong>setRootUrl("<a href="https://www.googleapis.com:22230/" rel="nofollow">https://www.googleapis.com:22230/</a>")</strong>.setApplicationName(APP_NAME).build();</p> <p>The above code snippet shall overwrite the default service URL values set by the Google API Client libraries (Jar files).</p> |
13,384,205 | 0 | Scrolling Graph <p>I am trying to draw a graph that has a scrollbar,<br> the graph uses time for the x-axis and i'd like to have a limited x-axis (1 minute)<br> so up until 1 minute, the scroll bar's page is the length of the scrollbar,<br> after that the page should be '60 seconds long' and the scrollbar max should be 'elapsed time' long<br> when you drag the scrollbar it tracks along, and pulls up the relevant bit of the graph.<br> the graph should auto-scroll until its dragged away (and auto-scroll once its dragged back to max)</p> <p>this is what i have so far</p> <p>is defined at the top of the wndproc<br> <code>static SCROLLINFO sci = {sizeof(SCROLLINFO),SIF_RANGE|SIF_POS|SIF_PAGE|SIF_TRACKPOS,0,0,0,0,0};</code> </p> <p>in the WM_HSCROLL event:</p> <pre><code>GetScrollInfo((HWND)lParam, SB_CTL, &sci); int pos; pos = sci.nPos; switch(LOWORD(wParam)) { case SB_PAGELEFT: pos -= sci.nPage; break; case SB_LINELEFT: pos -= (sci.nMax/10); break; case SB_PAGERIGHT: pos += sci.nPage; break; case SB_LINERIGHT: pos += (sci.nMax/10); break; case SB_THUMBTRACK: tsTracking = true; pos = sci.nTrackPos; break; case SB_THUMBPOSITION: tsTracking = false; pos = sci.nTrackPos; break; } if (pos < sci.nMin) pos = sci.nMin; if (pos > sci.nMax) pos = sci.nMax; if (pos != sci.nPos) { sci.fMask = SIF_POS; sci.nPos = pos; if(sci.nPos >= (sci.nMax-(sci.nPage*1.2)-1)) //this should detect when the thumb has reached the end of the scrollbar sci.nPos = sci.nMax; SetScrollInfo((HWND)lParam, SB_CTL, &sci, TRUE); PostMessage(hWnd, WM_COMMAND, IDM_DISPLAYRESULTS, 0); } break; </code></pre> <p>in the drawing code called from WM_PAINT<br> (yes i realize i shouldn't be setting the scrollbar's info here, i intend to put it in its proper place once its working properly)</p> <p>at the top of the graph-drawing function:</p> <p><code>static SCROLLINFO sci = {sizeof(SCROLLINFO),SIF_RANGE|SIF_POS|SIF_PAGE|SIF_TRACKPOS,0,0,0,0,0};</code> </p> <p>in the graph-drawing function:</p> <pre><code>__int64 elapsed_time = g_h_maxX-g_h_minX, //the elapsed time windowLengthMS, //the current window length in ms (between 0 and MAX_TIME_WIDTH_MS) start, //the start of the current window end; //the end of the current window static UINT32 windowMaxS = 1; //how long the window max is (used for x sub-divisions) double xTickStep, //x division step yTickStep, //y division step xScale, //x-scale (used to get the time relative to the elapsed time and size of the graph) yScale; //y-scale (used to get the data being plotted relative to its max, and the size of the graph) if(!tsTracking) //a global bool, checking if the scrollbar's thumb is being dragged { GetScrollInfo(get_chwnd(IDCW_HARMONICSRESULTSTIMESHIFTSB),SB_CTL,&sci); //gets the scroll info for the scrollbar int pos = sci.nPos*(double(elapsed_time)/double(sci.nMax - sci.nMin)); //gets the position relative to the new max sci.nMin = g_h_minX; //sets min (should always be the same, done for completeness) sci.nMax = (((g_h_maxX-MAX_TIME_WIDTH_MS)>0)?(g_h_maxX):0); //sets max to either max, or 0 (if max isnt bigger then page length) sci.nPage = MAX_TIME_WIDTH_MS; //sets the page length to the window length sci.nPos = pos; //sets position to its new value if(sci.nPos >= (sci.nMax-(sci.nPage*1.2)-1)) //if position is one "page" from the end sci.nPos = sci.nMax; //set it to max SetScrollInfo(get_chwnd(IDCW_HARMONICSRESULTSTIMESHIFTSB),SB_CTL,&sci,true); } //set scroll info if (elapsed_time > MAX_TIME_WIDTH_MS) //if elapsed time is longer then the max window length { end = ((double)sci.nPos / double(sci.nMax)) * g_h_maxX; //set the end to current (scroll position / scroll max) * latest time -> this should put end relative to the scrollbar start = end-MAX_TIME_WIDTH_MS; //sets start to end - window length if (start < 0) //if start is now less than zero { end = MAX_TIME_WIDTH_MS; //set end to window length start = 0; //set start to 0 } } else //if (elapsed_time <= MAX_TIME_WIDTH_MS) { start = g_h_minX; //start is min end = g_h_maxX; //end is max } windowLengthMS = (end-start); //find the current window length if(_MSTOSECS(windowLengthMS) > windowMaxS) //if the current window length beats one fo the markers windowMaxS = ((windowMaxS < 10)?windowMaxS+1:(windowMaxS==40)?windowMaxS*1.5:windowMaxS*2); //change subdiv scaling xScale = double(graph_width)/double(windowLengthMS); //set x-scale to width / window length yScale = (double)(graph_height)/((double)g_h_maxY - (double)g_h_minY); //set y-scale to height / (maxVal-minVal) int ticks = _MSTOSECS(elapsed_time); //ticks = full seconds elapsed xTickStep = double(graph_width)/double(ticks+1); //tickstep = seconds+1 (accounts for 0) yTickStep = double(graph_height)/double(Y_TICKS); //6 y-ticks, constant. SelectObject(hDC,hThickPen); { //scope to clear variables! double x; //x to store subdiv x-location for(i = ticks; i >= 0; i--) //for each subdiv { if(((windowMaxS>40)?(!(i%3)):(windowMaxS >20)?(!(i%2)):i)) //have if <=20 secs, each second is shown on x, >20 <=40, every second second is shown, >40 seconds, every 3rd second is shown { x = round((_SECSTOMS(i)*xScale)); //find x-pos sprintf(buf,"%d",(i+_MSTOSECS(start))); //print to buffer SetRect(&rc, fr.left+x-5, fr.bottom+5, fr.left+x+xTickStep, fr.bottom+25); //get text rectangle DrawText(hDC, buf, -1, &rc, DT_SINGLELINE | DT_VCENTER | DT_LEFT); //draw text } if (i!=ticks && (windowMaxS>40)?(!(i%6)):(windowMaxS >20)?(!(i%4)):(windowMaxS>10)?(!(i%2)):i)//every <10, each sec gets a subdiv, <20 each second tick gets a subdiv, <40 each 6th tick gets a subdiv { MoveToEx(hDC, GRAPH_XL_OFFSET+x, graph_bottom, NULL); //draw the line LineTo(hDC, GRAPH_XL_OFFSET+x, graph_bottom-graph_height); //draw the line } } } </code></pre> <p>as for globals:<br> <code>g_h_minX</code> is the start time and<br> <code>g_h_maxX</code> is the last result time<br> <code>MAX_TIME_WIDTH_MS</code> is the "window length" in ms -> how long i want the scroll bar page (60 seconds)</p> <p>so the idea is to set <code>end</code> to where the scroll bar is, and get the <code>start</code> by taking the window length from <code>end</code>, and working out which part of the graph we're trying to look at.</p> <p>i've been fiddling with this for the last 2 days and i'm running out of ideas. im sure i'm close, but i cant quite figure it out,</p> <p>edit:<br> updated the code slightly<br> it also seems i forgot to say what the problem was.<br> the scolling code isnt working properly, it autoscrolls when new data comes in,<br> but when i drag the thumb away from the end of the scrollbar, it just snaps to the start, and wont move. on closer inspection, the arrows work, and the "page-right" "page-left" on the right-click menu work, just not the tracking </p> <p>any help would be appreciated.</p> <p>thanks in advance.</p> |
8,275,004 | 0 | <p>Ok, I've got it figured out now! What was happening is it was trying to speak before <code>TTS</code> was initialized. So in a thread I wait for ready to not == 999. Once its either 1 or anything else we'll then take care of speaking. This might not be safe putting it in a while loop but... It's working nonetheless.</p> <pre><code>import java.util.HashMap; import java.util.Locale; import android.app.Service; import android.content.Intent; import android.media.AudioManager; import android.os.IBinder; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; import android.speech.tts.TextToSpeech.OnUtteranceCompletedListener; import android.util.Log; public class TTSService extends Service implements OnInitListener, OnUtteranceCompletedListener { TextToSpeech mTTS; int ready = 999; @Override public void onCreate() { Log.d("", "TTSService Created!"); mTTS = new TextToSpeech(getApplicationContext(), this); new Thread(new Runnable() { @Override public void run() { while(ready == 999) { //wait } if(ready==1){ HashMap<String, String> myHashStream = new HashMap<String, String>(); myHashStream.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_NOTIFICATION)); myHashStream.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "1"); mTTS.setLanguage(Locale.US); //mTTS.setOnUtteranceCompletedListener(this); mTTS.speak("I'm saying some stuff to you!", TextToSpeech.QUEUE_FLUSH, myHashStream); } else { Log.d("", "not ready"); } } }).start(); stopSelf(); } @Override public IBinder onBind(Intent intent) { return null; } @Override public void onDestroy() { mTTS.shutdown(); super.onDestroy(); } @Override public void onInit(int status) { Log.d("", "TTSService onInit: " + String.valueOf(status)); if (status == TextToSpeech.SUCCESS) { ready = 1; } else { ready = 0; Log.d("", "failed to initialize"); } } public void onUtteranceCompleted(String uttId) { Log.d("", "done uttering"); if(uttId == "1") { mTTS.shutdown(); } } } </code></pre> |
14,402,368 | 0 | php check if a value is in a sql database <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in-select">mysql_fetch_array() expects parameter 1 to be resource, boolean given in select</a> </p> </blockquote> <pre><code>//define variable to check the number of rows where the sql query is true to find out if the username or password are already in use $EmailCheck = mysql_query("SELECT `Email` FROM `Customer` WHERE `Email` = '$RegCusEmail'"); $UserCheck = mysql_query("SELECT `Username` FROM `Customer` WHERE `Username` = '$RegCusUser'"); //checks if emails in use if (mysql_num_rows($EmailCheck) != 0) { echo '<p id="error">The Email address you have entered is already in use.<p>'; } //checks if username is in use elseif (mysql_num_rows($UserCheck) != 0) { echo '<p id="error">The username you have entered is already in use.<p>'; } </code></pre> <p>The above code is supposed to search a database for the email and username of the person registering and if they already exist tell the user to use a different one but when I use it I get this error?</p> <blockquote> <pre><code>Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in (file directory) on line 56 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in (file directory) on line 62 </code></pre> </blockquote> |
12,025,886 | 0 | Not sure how to make the correct mySQL query to get data from multiple tables in 1 query <p>I need to get data from multiple tables from a database and I need to use 1 query, but I can't get it to work.</p> <p>I got these table:<br> <b>projects:</b></p> <pre><code>id name start_date end_date project_leader finished 1 project_1 2012-08-01 00:00:00 2012-29-01 00:00:00 2 0 </code></pre> <p><b>users</b></p> <pre><code>id username password email status 1 user_1 pass_1 email_1 1 2 user_2 pass_2 email_2 1 </code></pre> <p><b>user_has_project</b></p> <pre><code>userid projectId 1 1 </code></pre> <p><b>tasks</b></p> <pre><code>id project description end_date user 1 1 test description 1 2012-29-01 00:00:00 1 2 1 test description 2 2012-29-01 00:00:00 1 </code></pre> <p>So what I need to do, is make a query that should give me this result:<br> <b>Result:</b></p> <pre><code>project_id project_name start_date end_date project_leader finished tasks 1 project_1 2012-08-01 00:00:00 2012-29-01 00:00:00 user_2 0 2 </code></pre> <p>I got it to work until the part where I need to count the amount of tasks that a project has. I got this query, but that doesn't work:</p> <pre><code>SELECT projects.id, projects.name, projects.start_date, projects.end_date, projects.finished, users.username AS project_leader, COUNT(tasks.id) AS tasks FROM projects, tasks INNER JOIN user_has_project ON user_has_project.projectId = projects.id INNER JOIN users ON projects.project_leader = users.id WHERE user_has_project.userId = 1 </code></pre> <p>SQL dump, so people can try to test their query for me: </p> <pre><code>-- phpMyAdmin SQL Dump -- version 3.4.5 -- http://www.phpmyadmin.net -- -- Machine: localhost -- Genereertijd: 20 aug 2012 om 19:42 -- Serverversie: 5.5.16 -- PHP-Versie: 5.3.8 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `project-deadline` -- -- -------------------------------------------------------- -- -- Tabelstructuur voor tabel `projects` -- CREATE TABLE IF NOT EXISTS `projects` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) DEFAULT NULL, `start_date` datetime DEFAULT NULL, `end_date` datetime DEFAULT NULL, `project_leader` int(11) DEFAULT NULL, `finished` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Gegevens worden uitgevoerd voor tabel `projects` -- INSERT INTO `projects` (`id`, `name`, `start_date`, `end_date`, `project_leader`, `finished`) VALUES (1, 'Project 1', '2012-08-01 00:00:00', '2012-09-18 00:00:00', 1, 0); -- -------------------------------------------------------- -- -- Tabelstructuur voor tabel `tasks` -- CREATE TABLE IF NOT EXISTS `tasks` ( `id` int(11) NOT NULL AUTO_INCREMENT, `project` int(11) DEFAULT NULL, `description` varchar(100) DEFAULT NULL, `end_date` datetime DEFAULT NULL, `user` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Tabelstructuur voor tabel `users` -- CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `password` varchar(32) NOT NULL, `email` varchar(100) NOT NULL, `status` int(11) NOT NULL, `timezone` varchar(10) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Gegevens worden uitgevoerd voor tabel `users` -- INSERT INTO `users` (`id`, `username`, `password`, `email`, `status`, `timezone`) VALUES (1, 'DijkeMark', '37540da17c71d40c656b97b32c00f692', '[email protected]', 1, 'UP1'); -- -------------------------------------------------------- -- -- Tabelstructuur voor tabel `user_has_project` -- CREATE TABLE IF NOT EXISTS `user_has_project` ( `userId` int(11) NOT NULL, `projectId` int(11) NOT NULL, PRIMARY KEY (`userId`,`projectId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Gegevens worden uitgevoerd voor tabel `user_has_project` -- INSERT INTO `user_has_project` (`userId`, `projectId`) VALUES (1, 1), (1, 6); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; </code></pre> |
17,547,685 | 0 | Declare type object in an oracle package <p>Is there a way to declare type object in a package ?</p> <p>it seems like the one following is not supported in the context the package</p> <pre><code>TYPE xxx AS OBJECT </code></pre> <p>thank you</p> |
18,279,222 | 0 | <p>jQuery selector returns an array of elements wrapped by a jQuery object. Using your code, <code>row</code> would represent a property of the object, which would work for the numeric properties; but would break for all the other properties (see below for why this is bad). </p> <p>Again, the following should not be used, but using your code, you would implement the <code>in</code> looping construct by caching your selector:</p> <pre><code>var $tr = $('#alertsbody > tr'); for (var row in $tr) { // perform any property validation here if (isNaN(row)) continue; // try next property // id validation if ($tr[row].id == myRowId) . . . } </code></pre> <h2>Warning / Better Alternative</h2> <hr> <p>This is a bad idea. This is because you should not loop through the object in this manner, instead you should iterate over the jQuery object using <code>.each()</code>.</p> <pre><code>$tr.each(function(){ if(this.id == myRowId) ... }) </code></pre> <h2>Alternative</h2> <hr> <p>Some alternatives are to skip the loop entirely and select the rows by <code>id</code> eg(<code>$('#myRowId')</code> or <code>$('tr#myRowId')</code><em>though, tr is not necessary as there should only be one id per HTML page</em>) and perform some action. Or, if you already have some looping construct in place or need an alternative checking mechanism, you can use the <code>.is()</code> function:</p> <pre><code>var domElement = document.getElementById('myRowId'); var $jqElement = $('#myRowId'); $tr.each(function(){ var $this = $(this); if( $this.is('#myRowId') ) ... if( $this.is( domElement ) ) ... if( $this.is( $jqElement ) ) }); </code></pre> |
9,005,449 | 0 | <p>I'm pretty sure it had something to do with the version of Ubuntu server I had installed. I couldn't seem to install all these tools properly on that version. So, ultimately, I installed the latest version of Ubuntu server and was able to install all these tools properly. Thanks for the help!</p> |
40,774,484 | 0 | <p>you can do on a other way: </p> <p><strong>Create a Select with this Concats</strong></p> <pre><code>select GROUP_CONCAT( CONCAT(" ('",field1,"','",field2,"')")) as vals from my_table; </code></pre> <p>The Result look like this:</p> <p><strong>Result</strong></p> <pre><code>mysql> select GROUP_CONCAT( -> CONCAT(" ('",field1,"','",field2,"')")) as vals -> from my_table; +---------------------------------------------------------------------------------------------------------+ | vals | +---------------------------------------------------------------------------------------------------------+ | ('O1','AC'), ('O1','PT'), ('O2','PT'), ('O3','MI'), ('O3','PT'), ('O4','EG'), ('O4','PT'), ('O5','PT') | +---------------------------------------------------------------------------------------------------------+ 1 row in set (0,00 sec) mysql> </code></pre> <p>and the you can direct concat this in the insert statement and you only read one row and only write and execute one statement.</p> <p><strong>your Code</strong></p> <pre><code> String selectStatement = "SELECT GROUP_CONCAT(CONCAT(" ('",field1,"','",field2,"')")) as vals FROM dbx.testx where time between ('2016-09-01 00:00:00') and ('2016-09-03 23:59:59');"; ResultSet resultSetForSelect = st.executeQuery(selectStatement); String insertStatement = "INSERT INTO testy(" + "field1," + "field2)" + + String from result + "ON DUPLICATE KEY UPDATE field1 = VALUES(field1);"; <----field1 is a unique key but not primary # execute one time </code></pre> |
6,067,622 | 0 | <p>I think you meant to use setTimeout instead of setInterval; it's continuously running that loop every second which is what's causing the focus to jump back to the first input box.</p> <p>If you want the animation to happen after the slideUp animation is complete, use the callback argument of the slideUp method instead of relying on setTimeout.</p> <p>For example:</p> <pre><code>$("#openc").click(function(){ $("#close-top").slideUp(450,function() { $("#open-me").slideDown(); $("#regkey").focus(); $("#closec").show(); }); $("#openc").hide(); }); </code></pre> |
36,627,761 | 0 | Adding wait method to a JTable <p>Edited - To clarify what my problem was I have decided to edit this. </p> <p>My problem involved the method below:</p> <pre><code>addTransactionButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ AllGUI allGUI = new AllGUI(); allGUI.createAllGUI(); TCRSpecificGUI tcrGUI = new TCRSpecificGUI(); tcrGUI.getNtryName(); dtm.addRow(new Object[]{TCRSpecificGUI.ntryName,AllGUI.bankTransCode,TCRSpecificGUI.endToEndId, AllGUI.transAmount,AllGUI.initiatingPartyId,AllGUI.initiatingPartySchemeName, AllGUI.debtorName,AllGUI.debtorAddress,TCRSpecificGUI.debtorAccountType, TCRSpecificGUI.creditorAccountNumber,TCRSpecificGUI.proprietaryPartyType,AllGUI.debtorAgentName, AllGUI.debtorAgentCity,AllGUI.debtorAgentCountrySubDvsn,AllGUI.creditorAgentClearingSystemId, TCRSpecificGUI.purpose,TCRSpecificGUI.returnRejectReasonCode,TCRSpecificGUI.returnRejectReasonAdditionalInfo, AllGUI.payInstrument,AllGUI.typeOfCheck,AllGUI.passThruData,AllGUI.clearingAccount, AllGUI.jobId,TCRSpecificGUI.nachaTransactionCode,AllGUI.transactionType, TCRSpecificGUI.auxillaryOnUsIndicator,TCRSpecificGUI.batchTypeFromSourceSystem, TCRSpecificGUI.expressMailItem,TCRSpecificGUI.returnOccurance,TCRSpecificGUI.nameOfRMessageFile}); } }); </code></pre> <p>What is occurring there is that a GUI is being called first with the allGUI.createAllGUI() method. This is a JFrame with multiple JTextAreas for the user to fill out. Once the user clicks a confirm button on the first GUI a second one appears with more fields. When a user confirms each of the GUI's all the JTextArea information is saved into Strings and is then written into a JTable as a new row. (As seen above).</p> <p>The problem is that the logic above meant that the program would move to the dtm.addRow step even before the user had completed editing the text fields in the GUI. This means that the first row of the table would be totally blank (as the GUI fields had not yet been saved to strings).</p> <p>In short, the problem is that I needed some way to tell the program "Don't call the addRow code until the user has clicked the confirm button in the allGUI.createALLGUI() method second GUI.</p> <p>I finally found a solution. Since some users decided to mark this question as a "null pointer" duplicate I will just have to post my answer in the body here and then hopefully if the question is reopened I can post as answer.</p> <p>My solution was to move the addRow method into it's own class like this: </p> <pre><code>protected static void writeRow(){ dtm.addRow(new Object[]{TCRSpecificGUI.ntryName,AllGUI.bankTransCode,TCRSpecificGUI.endToEndId, AllGUI.transAmount,AllGUI.initiatingPartyId,AllGUI.initiatingPartySchemeName, AllGUI.debtorName,AllGUI.debtorAddress,TCRSpecificGUI.debtorAccountType, TCRSpecificGUI.creditorAccountNumber,TCRSpecificGUI.proprietaryPartyType,AllGUI.debtorAgentName, AllGUI.debtorAgentCity,AllGUI.debtorAgentCountrySubDvsn,AllGUI.creditorAgentClearingSystemId, TCRSpecificGUI.purpose,TCRSpecificGUI.returnRejectReasonCode,TCRSpecificGUI.returnRejectReasonAdditionalInfo, AllGUI.payInstrument,AllGUI.typeOfCheck,AllGUI.passThruData,AllGUI.clearingAccount, AllGUI.jobId,TCRSpecificGUI.nachaTransactionCode,AllGUI.transactionType, TCRSpecificGUI.auxillaryOnUsIndicator,TCRSpecificGUI.batchTypeFromSourceSystem, TCRSpecificGUI.expressMailItem,TCRSpecificGUI.returnOccurance,TCRSpecificGUI.nameOfRMessageFile}); } </code></pre> <p>leaving the original code like so:</p> <pre><code>addTransactionButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ AllGUI allGUI = new AllGUI(); allGUI.createAllGUI(); TCRSpecificGUI tcrGUI = new TCRSpecificGUI(); tcrGUI.getNtryName(); } }); </code></pre> <p>Finally in the last stage of my GUI where the user fills out the JTextFields I added this:</p> <pre><code>confirmButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ endToEndId=endToEndIdText.getText(); if(checkingButton.isSelected()){ debtorAccountType="Checking"; }else{ debtorAccountType="Savings"; } creditorAccountNumber=creditorAccountNumberCombo.getSelectedItem().toString(); proprietaryPartyType=proprietaryPartyTypeText.getText(); purpose=purposeText.getText(); returnRejectReasonCode=returnRejectReasonCodeText.getText(); returnRejectReasonAdditionalInfo=returnRejectReasonAdditionalInfoText.getText(); nachaTransactionCode=nachaTransactionCodeText.getText(); if(yesAuxillaryButton.isSelected()){ auxillaryOnUsIndicator="YES"; }else{ auxillaryOnUsIndicator="NO"; } batchTypeFromSourceSystem=batchTypeFromSourceSystemText.getText(); if(yesExpressButton.isSelected()){ expressMailItem="YES"; }else{ expressMailItem="NO"; } returnOccurance=returnOccuranceText.getText(); nameOfRMessageFile=nameOfRMessageFileText.getText(); Component component = (Component)ae.getSource(); Window window = SwingUtilities.windowForComponent(component); window.dispose(); TCRMainGUI.writeRow(); } }); </code></pre> <p>Note at the very bottom this line of code:</p> <pre><code>TCRMainGUI.writeRow(); </code></pre> <p>That calls the method to write a new row. </p> <p>So I now have a logic that 1. When a user clicks the create transaction button on the main JTable screen the first GUI class is opened. 2. Once the user fills out the fields and clicks confirm the values are saved to Strings and the next GUI opens. 3. Once the user fills out the fields on the second GUI and clicks confirm the values are saved and the method to add a row is called - The Strings are now populated so the row will be written with the values. </p> |
14,886,233 | 0 | Utilise the Bootstrap Carousel "slide" event and the .next class <p>So I've got a little problem (similar to this one I posted the other day: <a href="http://bit.ly/11JpbdY">http://bit.ly/11JpbdY</a>) with using SlabText on a piece of content that is hidden on load. This time, I'm trying to get slabText to update the display of some content that is in a slider (using Twitter Bootstrap's Carousel plugin).</p> <p>Following Twitter's documentation (<a href="http://twitter.github.com/bootstrap/javascript.html#carousel">http://twitter.github.com/bootstrap/javascript.html#carousel</a>) for Bootstrap's Carousel plugin, I'm trying to use <code>slide</code> event so that I re-call SlabText to make it display correctly.</p> <p>Using developer tools I can see that Carousel adds a <code>.next</code> class as it processes the slide of one <code>.item</code> element to the next. This is then removed before the <code>.active</code> class is transferred.</p> <p>I can access the "slide" event without any issue, but trying to get hold of the <code>.next</code> element is proving troublesome. <strong>Here is a JSFiddle of my code thus far: <a href="http://jsfiddle.net/peHDQ/">http://jsfiddle.net/peHDQ/</a></strong></p> <p><strong>To put my question simply; how should I correctly use the <code>slide</code> event to trigger a function?</strong></p> <p>Please let me know if any additional information would be useful.</p> <hr> <p><strong>Further notes:</strong></p> <p>As I've been unable to get hold of the <code>.next</code> class, I'm attempting to do this with some jQuery. Here is my code thus far:</p> <pre><code>$('.carousel').carousel({ interval: 5000 }).on('slide', function (e) { $(this).find('.active').next().find('.slab').slabText(); }); </code></pre> <p>From what I understand this should be grabbing each <code>.slab</code> element and triggering the SlabText plugin.... alas I get an error:</p> <p><em>"Uncaught TypeError: Object [object Object] has no method 'slabtext' "</em></p> <p><strong>Can anyone advise what I am doing wrong here...?</strong> I've used the exact same process to add a class and it works fine (as per this JSFiddle: <a href="http://jsfiddle.net/peHDQ/2/">http://jsfiddle.net/peHDQ/2/</a>)</p> |
29,960,351 | 0 | <p>I have one suggestion for the database design.</p> <p>i have made a few modification in Response Table and Create a new Table.</p> <ul> <li>USER Table (User_ID [PK],USER_NAME,another Extra fields)</li> <li>TEST Table (Test_ID [PK],some other fields for test details)</li> <li>Quest_Set Table (Set_ID ,Que_ID,Question,some other fields if required)</li> <li>RESPONSE Table (Res_id ,User_ID [FK],Test_ID [FK], Set_ID , Que_ID, Ans_1 , Ans_2 , Flag)</li> </ul> <p>Please review it and let me know if you have any confusions.</p> <p>Regards.</p> <p>Please look the New_Response Table </p> <p>(Response_id, user_id, test_id,Trans_id,Ans1,Ans2,Flag)</p> |
13,591,787 | 0 | <p>If you want to refresh the select menu with <code>data-role</code> slider you have to use:</p> <pre><code>$("#txtgender2").val(data.data.gender).slider("refresh"); </code></pre> <p>instead of:</p> <pre><code>$("#txtgender2").val(data.data.gender).selectmenu("refresh"); </code></pre> |
17,888,725 | 0 | Display li horizontally with wide li elements <p>I'm trying to display a li element side by side so that I can turn it into a content slider. Because the li elements are so wide they will not display inline. I know that I can expand the ul width to the width needed however I need that to me a mask with over-flow hidden so that it will be a slider. </p> <p><a href="http://jsfiddle.net/deaYn/" rel="nofollow">Here's a fiddle</a> of my original code.</p> <p><strong>HTML:</strong></p> <pre><code><div class="slider"> <ul> <li> <div class="video"><iframe src="http://player.vimeo.com/video/70965217?title=0&amp;byline=0&amp;portrait=0" width="692" height="389" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> </div> <div class="videotext"> <div class="videotexttitle"> <p>Student Stories</p> </div> <div class="videotextcopy"> <p>At autsdf la veleniet lam fuga.Et modit quiae volesti onetumquib us est laut is aute ndant andia dolupti abor sectate aspernat dempor aut qui aut volorerchit, si officat emquissit eatem. At aut la veleniet lam fuga.Et modit quiae volesti onetumquib us est laut is aute ndant andia dolupti abor sectate aspernat dempor aut qui aut volorerchit, si officat emquissit eatem. </p> </div> </div> <div class="clear"></div> </li> <li> <div class="video"><iframe src="http://player.vimeo.com/video/70965217?title=0&amp;byline=0&amp;portrait=0" width="692" height="389" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> </div> <div class="videotext"> <div class="videotexttitle"> <p>Student Stories</p> </div> <div class="videotextcopy"> <p>At autsdf la veleniet lam fuga.Et modit quiae volesti onetumquib us est laut is aute ndant andia dolupti abor sectate aspernat dempor aut qui aut volorerchit, si officat emquissit eatem. At aut la veleniet lam fuga.Et modit quiae volesti onetumquib us est laut is aute ndant andia dolupti abor sectate aspernat dempor aut qui aut volorerchit, si officat emquissit eatem. </p> </div> </div> <div class="clear"></div> </ul> </code></pre> <p></p> <p><strong>CSS</strong></p> <pre><code>.slider { width: 1099px; height: 423px; overflow: visible; position: relative; /* for overflow: hidden to work in IE7 */ } .slider > ul { position: relative; margin: 0; padding: 0; } .slider > ul > li { float: left; width: 1099px; height: 423px; } iframe.actvideo{ padding:16px; } .video{ float:left; background: url('images/videoround.png'); width:724px; height:423px; } .videotext{ float:right; width:301px; } </code></pre> |
2,028,091 | 0 | <p>Any reason you can't statically link at least the standard libraries in? You should have a working program and the benefits of the standard libraries without external dependencies.</p> <p>Also, does your toolchain/IDE provide differentiate between "standalone application" and "linux application"? The IDE for the AVR32 has that distinction and is able to generate either a program that runs within the embedded linux environment or a standalone program that basically becomes the OS.</p> |
4,957,448 | 0 | Access this in jquery each function <p>How can I acces my object variables within a $.each function?</p> <pre><code>function MyClass() { this.mySetting = 'Hallo'; this.arr = [{caption: 'Bla', type: 'int'}, {caption: 'Blurr', type: 'float'}]; } MyClass.prototype.doSomething = function() { $.each(this.arr, function() { //this here is an element of arr. //...but how can I access mySetting?? }); } </code></pre> |
32,155,249 | 0 | <p>I would say the answer is: you can't. (or at least: you shouldn't). This is not what Webpack is supposed to do. Webpack is a bundler, and it should not be used for other tasks (in this case: copying static files is another task). You should use a tool like Grunt og Gulp to do such tasks. It is very common to integrate <a href="https://github.com/webpack/grunt-webpack">webpack as a grunt task</a> or as a <a href="http://webpack.github.io/docs/usage-with-gulp.html">gulp task</a>. They both have other tasks useful for copying files like you described. <a href="https://github.com/gruntjs/grunt-contrib-copy">grunt-contrib-copy</a> or <a href="https://www.npmjs.com/package/gulp-copy">gulp-copy</a>.</p> <p>For other assets (not the index.html), you can just bundle them in with webpack (that is exactly what webpack is for). <code>var image = require('assets/my_image.png');</code> But I assume your <code>index.html</code> needs to not be a part of the bundle, and therefore it is not a job for the bundler.</p> |
10,270,603 | 0 | <p>You need to indent inside the <code>for loop</code> block</p> <pre><code>for i in range(len(Adapters)): print Adapters[i] </code></pre> <p>A better way would be:</p> <pre><code>for item in Adapters: print item </code></pre> |
16,507,561 | 0 | <p>You need to <em>return</em> the month value. You also need to write the function properly:</p> <pre><code>function getMonthName(n) { var months = ["Jan", "Feb", ... ]; // omitted for brevity return months[n - 1]; } </code></pre> <p>with usage:</p> <pre><code>for (var i=0; i < arrayLength; i++) { var month = data[1]; var name = getMonthName(month); alert(name); } </code></pre> <p>NB: the result will be <code>undefined</code> if the supplied month is out of range.</p> |
12,638,694 | 0 | <p>Assuming that you're not limited by some older JS implementation, you can use <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty" rel="nofollow">Object.defineProperty</a>.</p> |
40,575,409 | 0 | How to configure node at XMPP Publish Subscribe to deliver message to offline subscriber? <p>Publisher sent message_1 when subscriber online, and subscriber got it.</p> <p>Publisher sent message_2 when subscriber offline.</p> <p>Publisher sent message_3 when subscriber offline. Subscriber login, and just get message_3(last published item).</p> <p>How can i get message_2 and message_3 when subscriber login(online)? if i use retrive message, i will get all message(1,2,3) and that will no efficient bandwith.</p> <p>Please help me, i was stuck.</p> |
18,948,450 | 0 | Filter a list and requesting data via ajax <p>im new to javascript and phonegap and im sitting here the whole day and try to solve this problem.</p> <p>I have a list and i want to filter some data. And before i filter it, i want to download some data from a server and add it to the list. ( the list is local and if someone uses the search function, new data should pop up too).</p> <p>The idea is that i create the list with jquery and use the listviewbeforefilter-event to download the data from a server and add it to the list. Then jquery should filter the list.</p> <p>It works fine when i search filter for 2 chars.</p> <p>But this doesnt work as expected when i search for more than 2 chars. I receive the correct data from the server and it will be added to my list but the there is no more filtering in my original list. So i see my original list + the loaded data. Also the console.log("second") is shown first and then console.log("first). Somehow jquery/phonegap skips the .then part and then comes back to it.</p> <p>I tried to put the 3 lines ($ul.html( content );$ul.listview( "refresh" );$ul.trigger( "updatelayout");) below the second console.log and then the filter of my local data works but the data from the server wont be shown.</p> <p>I hope someone can help me with this weird problem.</p> <p>Heres my code for the listviewbeforefilter-event:</p> <pre><code> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> <title>Listview Autocomplete - jQuery Mobile Demos</title> <link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css" /> <script src="cordova.js"></script> <script src="js/jquery-2.0.3.min.js"></script> <script src="js/jquery.mobile-1.3.2.min.js"></script> <script> $( document ).on( "pageinit", "#myPage", function() { $( "#autocomplete" ).on( "listviewbeforefilter", function ( e, data ) { // this is a second list which is a backup. It is needed because after each search the original list is flooded with old entries. var content = document.getElementById("autocomplete2").innerHTML; var requestdata = ""; var $ul = $( this ); $input = $( data.input ), value = $input.val(); // ajax call returns cities with at least 3 characters if ( value && value.length > 2 ) { $.ajax({ url: "http://gd.geobytes.com/AutoCompleteCity", dataType: "jsonp", crossDomain: true, data: { q: $input.val() } }) // The response is saved in html which i append to the original content .then( function ( response ) { var html = ""; console.log("first"); $.each( response, function ( i, val ) { html += "<li>" + val + "</li>"; }); content = content + html; $ul.html( content ); $ul.listview( "refresh" ); $ul.trigger( "updatelayout"); }); console.log("second"); } }); }); </script> </code></pre> <p>and that is the body with the list:</p> <pre><code> </head> <body> <div data-role="page" id="myPage"> <div data-role="header" data-theme="f"> <h1>Listview </h1> </div><!-- /header --> <div data-role="content"> <div class="content-primary"> <ul id = "autocomplete" data-role="listview" data-filter="true" data-filter-placeholder="Search people..." data-filter-theme="d"data-theme="d" data-divider-theme="d"> <li data-role="list-divider">A</li> <li><a href="index.html">Adam Kinkaid</a></li> <li><a href="index.html">Alex Wickerham</a></li> <li><a href="index.html">Avery Johnson</a></li> </ul> </div><!--/content-primary --> </div><!-- /content --> <script type="text/javascript" charset="utf-8"> $(function(){ $( "#autocomplete2" ).hide(); }); </script> <ul id = "autocomplete2" data-role="listview" data-filter-theme="d"data-theme="d" data-divider-theme="d"> <li data-role="list-divider">A</li> <li><a href="index.html">Adam Kinkaid</a></li> <li><a href="index.html">Alex Wickerham</a></li> <li><a href="index.html">Avery Johnson</a></li> </ul> </div><!-- /page --> </body> </html> </code></pre> |
10,913,752 | 0 | <p>I solve the problem with this code.and we shold to use interface "IPlugin" in a seperate class library and use in other project.</p> <pre><code> Assembly objAssembly = Assembly.LoadFrom("Company.dll"); Type objAssemblyType = objAssembly.GetType(); foreach (Type type in objAssembly.GetTypes()) { if (type.IsClass == true) { var classInstance = objAssembly.CreateInstance(type.ToString()) as IPlugin; lblFullName.Text = classInstance.FullName("Mr. "); } } </code></pre> |
11,907,347 | 0 | <p>You want something like <code>/^[#][^#]*$/</code></p> |
19,005,331 | 0 | <p>The <a href="http://www.tcl.tk/man/tcl8.6/TclCmd/flush.htm" rel="nofollow"><code>flush</code></a> command directs Tcl to ensure all its buffered output for a channel is written to the underlying operating system immediately. You hardly ever need to use <code>flush</code> explicitly; the main exception is when you are prompting the user for input without using a new line:</p> <pre><code>puts -nonewline "Please enter your name: " flush stdout set name [gets stdin] </code></pre> <p>However, if you are having problems with flushing for other reasons, you actually need to use <a href="http://www.tcl.tk/man/tcl8.6/TclCmd/fconfigure.htm" rel="nofollow"><code>fconfigure</code></a> to change the default output buffer management strategy:</p> <pre><code># Turn off output buffering fconfigure $channel -buffering none </code></pre> <p>Every channel supports three buffering strategies:</p> <ul> <li><code>none</code> — no buffering at all.</li> <li><code>full</code> — buffer until a full output buffer is built up (the output buffer size is controllable but you hardly ever need to touch it) and then write that whole buffer at once.</li> <li><code>line</code> — buffer until a full line of output can be written at once.</li> </ul> <p>Most channels default to <code>full</code> as that gives the best performance when writing bulk data, but the <code>stdout</code> channel defaults to <code>line</code> when writing to a terminal, and the <code>stderr</code> channel <em>always</em> defaults to <code>none</code> (as it is used for writing messages when the system is very poorly and might crash, among other things).</p> |
3,345,017 | 0 | <p>The problem is that your selector matches all .popup_msg, not only the one you need. Use the find() method to get the correct popup in the $('.t').click function:</p> <pre><code>jQuery('.t').click(function(e) { var popup_msg = jQuery(this).find('.popup_msg'); var height = popup_msg.height(); var width = popup_msg.width(); leftVal=e.pageX-(width/1.5)+"px"; topVal=e.pageY-(height/13)+"px"; popup_msg.css({left:leftVal,top:topVal}).show(); }); </code></pre> <p>Note: I haven't tested this code, it might not be 100% correct but hopefully you get what I mean.</p> |
17,094,573 | 0 | How to exit debug session on Borland C++ Builder 6? <p>While mid debugging, what's the proper way to force exit debug mode. I didn't see the usual red square "stop" button like visual studio or eclipse.</p> |
37,021,861 | 0 | <p>Try this:</p> <pre><code>/** * * Convert a bengali numeral to its arabic equivalent numeral. * * @param bengaliNumeral bengali numeral to be converted * * @return the equivalent Arabic numeral * @see #bengaliToInt */ public static char bengaliToArabic(char bengaliNumeral) { return (char) (bengaliNumeral - '০' + '0'); } public static int bengaliToInt(char bengaliNumeral) { return Character.getNumericValue(bengaliNumeral); } </code></pre> <p><a href="http://ideone.com/qJ8ddX" rel="nofollow">DEMO</a></p> <h3>SAMPLE CODE</h3> <pre><code>System.out.format("bengaliToArabic('১') == %s // char\n", bengaliToArabic('১')); System.out.format("bengaliToInt('১') == %s // int\n", bengaliToInt('১')); </code></pre> <h3>OUTPUT</h3> <pre><code>bengaliToArabic('১') == 1 // char bengaliToInt('১') == 1 // int </code></pre> |
40,822,974 | 0 | Function not defined/ not working <p>I'm making a quiz, and I was just trying to check if the submit button was working. It isn't here is the code. What did I do wrong?</p> <p>HtmL</p> <pre><code><button type="button" onClick="checkAllAnswers" id="checkAllAnswers">button</button> </code></pre> <p>JS</p> <pre><code>function checkAllAnswers(){ var thingtocheck = 5; if (thingtocheck === 5){ alert("Check button is working"); } </code></pre> <p>Seems right to me...</p> |
10,088,217 | 0 | <p>You don't need to use <code>eval</code> at all to create a cell array of function handles using a <code>for</code> or <code>parfor</code> loop. Then all you need to do is to call each function handle stored in <code>functions</code> cell array.</p> <pre><code>functions = cell(1, 10); parfor i = 1:10 functions{i} = str2func([ 'function', num2str(i) ]); end parfor i = 1:10 result = functions{i}(); fprintf('%d ', result); end </code></pre> |
7,307,775 | 0 | How does WCF actually work? <p>I have created a C# application that I want to split into server and client side. The client side should have only a UI, and the server side should manage logic and database.</p> <p>But, I'm not sure about something: my application should be used by many users at the same time. If I move my application to a server, will WCF create another instance of the application for every user that logs in or there's only one instance of the application for all users?</p> <p>If the second scenario is true, then how do I create separate application instances for every user that want to use my service? I want to keep my application logic on the server, to make users share the same database, but also to make every single instance independent (so several users can use the WCF service with different data). Someting like PHP does: same code, new instance of code for every user, shared database.</p> |
4,191,324 | 0 | How do you make sure that you always have a releasable build? <p>How do you make sure that you always have a releasable build?</p> <p>I'm on a Scrum team that is running into the following problem: At the end of the Sprint, the team presents its finished user stories to the Product Owner. The PO will typically accept several user stories but reject one or two. At this point, the team no longer has a releasable build because the build consists of both the releasable stories and the unreleasable stories and there is no simple way to tear out the unreleasable stories. In addition, we do not want to just delete the code associated with the unreleasable stories because typically we just need to add a few bug fixes.</p> <p>How should we solve this problem? My guess is that there is some way to branch the build in such a way that either (a) each user story is on its own branch and the user story branches can be merged or (b) there is a way of annotating the code associated with each user story and creating a build that only has the working user story. But I don't know how to do either (a) or (b). I'm also open to the possibility that there are much easier solutions.</p> <p>I want to stress that the problem is not that the build is broken. The build is not broken -- there are just some user stories in the build that cannot be released.</p> <p>We are currently using svn but are willing to switch to another source control system if this would solve the problem.</p> <p>In addition to answers, I'm also interested in any books or references which address this question.</p> |
26,946,564 | 0 | <p>With <a href="http://www.rebol.com/docs/words/wbind.html" rel="nofollow">bind</a>, that Binds words to a specified context (in this case local context of function), and <a href="http://www.rebol.com/docs/words/wcompose.html" rel="nofollow">compose</a> function, I get: </p> <pre><code>cascade: func [ times template start ] [ use [?1] [ ?1: start template: compose [?1: (template)] loop times bind template '?1 ?1 ] ] cascade 8 [?1 * 2] 1 == 256 cascade 3 [add 4 ?1] 5 == 17 val: 4 cascade 3 [add val ?1] 5 == 17 cascade2: func [ times template1 start1 template2 start2 /local **temp** ] [ use [?1 ?2] [ ; to bind only ?1 and ?2 and to avoid variable capture ?1: start1 ?2: start2 loop times bind compose [**temp**: (template1) ?2: (template2) ?1: **temp**] '?1 ?1 ] ] cascade2 5 [?1 * ?2] 1 [?2 + 1] 1 == 120 cascade2 5 [?1 + ?2] 1 [?1] 0 == 8 </code></pre> |
22,694,513 | 0 | jQuery css height not applying <p>For some reason the height is not being set in this piece of code</p> <pre><code>jQuery(document).ready(function() { jQuery('#main-content').css({'height': ((jQuery(window).height()))+'px'}) jQuery('#nav-icons a').click(function(){ jQuery('#nav-icons a').removeClass("active-icon"); jQuery(this).addClass( "active-icon" ); var toLoad = jQuery(this).attr('href')+' #main-content'; var toLoadSlider = jQuery(this).attr('href')+' #homepage-slider'; jQuery('#main-content , #homepage-slider').fadeOut(1000, loadContent); function loadContent() { jQuery('#homepage-slider').empty().load(toLoadSlider) jQuery('#main-content').empty().load(toLoad,'',showNewContent()) } function showNewContent() { jQuery('#main-content , #homepage-slider').css({'height': ((jQuery(window).height()))+'px'}).hide().fadeIn(2000).removeAttr('id class'); } return false; </code></pre> <p>interestingly, the exact same line of code in the showNewContent() does set the height.</p> |
36,072,028 | 0 | <p>The following works for me:</p> <pre><code> try (InputStream stream = Test.class.getResourceAsStream("/Test.xml")) { StreamSource source = new StreamSource(stream); final XML xml = new XMLDocument(source); } </code></pre> <p>With the input file's hex dump:</p> <pre><code>FF FE 3C 00 3F 00 78 00 6D 00 6C 00 20 00 76 00 65 00 72 00 73 00 69 00 6F 00 6E 00 3D 00 27 00 31 00 2E 00 30 00 27 00 20 00 65 00 6E 00 63 00 6F 00 64 00 69 00 6E 00 67 00 3D 00 27 00 55 00 54 00 46 00 2D 00 31 00 36 00 27 00 3F 00 3E 00 3C 00 58 00 20 00 69 00 64 00 3D 00 22 00 31 00 22 00 2F 00 3E 00 </code></pre> <p>As far as I can tell, in your example you are converting the contents of the file to a string. But this is problematic because you actually throw away the encoding when you convert bytes to string. When the SAX parser converts the string to a byte array, it decides it will be UTF-8, but the prolog states that it is UTF-16 and so you have a problem.</p> <p>Instead, when I use the StreamSource, it just automatically detects the fact that the file is encoded in UTF-16 LE from the BOM.</p> <p>If you are not using java-7 or up and cannot use try-with-resources, then use the stream.close() as before.</p> |
36,761,022 | 0 | <p>Try if this works Not tested, a wild guess</p> <pre><code>void restartButtonClickFunction(object obj) { foreach (var window in Application.Current.Windows) { if (window is GameWindow) { ((Window)window).Close(); } } GameWindow gamewindow = new GameWindow(); gamewindow.Show(); } </code></pre> |
9,730,440 | 0 | <p>Use an ArrayList instead of a table. Removes the displayed question from the ArrayList when it has been displayed.</p> |
11,245,839 | 0 | How to post uiimage to soap Srevice in binary formate <p>I want to post uiimage into soap service and input image is into binary formate</p> <pre><code>"<ExpenseDetailReceipt>%@</ExpenseDetailReceipt>" </code></pre> <p>and send this appdelegate.imgBMeal data</p> <pre><code>appdelegate.imgBMeal=UIImagePNGRepresentation(appdelegate.imgMeal); </code></pre> <p>as image but there is some problem and I get please send data in correct formate </p> <p>please help me how to do this</p> |
3,205,166 | 0 | <p>You're setting CSS properties incorrectly with jquery. You can read <a href="http://api.jquery.com/css/" rel="nofollow noreferrer">here</a> how to reference the names of the properties (camelcased, with no hyphen).</p> <pre><code>$("#element").css({"backgroundImage":"url(/images/image.jpg)",....etc}) </code></pre> |
30,818,476 | 0 | <p>The <code>animate</code> functions has its own callback function. Use it like this:</p> <pre><code>$("#pin01").animate({left: '650px'}, 500, function() { $("#pin02").animate({left: '350px'}); }); </code></pre> <p>The 500, is the delay, after the completion of the first animation, you can set it to be 0 if you do not want any delay. And the delay is given in <code>ms</code> (milliseconds).</p> |
31,500,093 | 0 | <p>Basically this code relies on a little trick: if you seed the SHA1PRNG for the SUN provider and Bouncy Castle provider before it is used then it will always generate the same stream of random bytes. This is not always the case for every provider though; other providers simply mix in the seed. In other words, they may use a pre-seeded PRNG. In that case the <code>getRawKey</code> method generates different keys for the encrypt and decrypt, which will result in a failure to decrypt.</p> <p>Basically this horrible code snippet abuses the SHA1PRNG as a Key Derivation Fucntion or KDF. You should use a true KDF such as PBKDF2 if the input is a password or HKDF if the input is a key.</p> <p>That code snippet should be removed. It has been copied from Android snippets, but I cannot find that site anymore.</p> |
39,929,877 | 0 | Swift performSegueWithIdentifier shows black screen <p>I have read through a lot of different posts regarding this issue, but none of the solutions seemed to work for me. </p> <p>I started a new app and I placed the initial ViewController inside a navigation controller. I created a second view and linked them together on the storyboard with a segue. The segue works successfully, and I can see the data I am transferring in a print statement from the second screen, but the screen shows black.</p> <p>WelcomeScreen:</p> <pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "segueToTraits"{ if let gender = self.selectedGender{ let traitVC = segue.destinationViewController as? TraitViewController traitVC!.gender = gender } } } func sendGenderToTraitsView(gender : String?){ performSegueWithIdentifier("segueToTraits", sender: self) } @IBAction func button1(sender: UIButton) { selectedGender = boyGender self.sendGenderToTraitsView(selectedGender) } @IBAction func button2(sender: UIButton) { selectedGender = girlGender self.sendGenderToTraitsView(selectedGender) } </code></pre> <p>Storyboard: <a href="http://i.stack.imgur.com/8SPTf.png" rel="nofollow">Link to image of my storyboard</a> My segue is set as follows: <a href="http://i.stack.imgur.com/sO6dx.png" rel="nofollow">Link to image of my segue information</a></p> <p>Also, my viewControllers are named WelcomeViewController and TraitViewController. They have storyboard id's of welcomeVC and traitsVC.</p> <p>Any help would be incredibly appreciated. Let me know if you need any other information.</p> |
27,468,770 | 0 | Call click function only for TH with class <p>I have table</p> <pre><code><table id="dataTable"> <thead> <tr> <th>TH 1</th> <th>TH 2</th> <th class="sortable">TH 3</th> <th>TH 4</th> <th>TH 5</th> <th class="sortable">TH 6</th> <th>TH 7</th> <th>TH 8</th> </tr> </thead> <tbody> <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> <td>Data 4</td> <td>Data 5</td> <td>Data 6</td> <td>Data 7</td> <td>Data 8</td> </tr> </tbody> </table> </code></pre> <p>I need solution for add class into TD only under TH with class "sortable" but only If I click only to TH with class sortable.</p> <p>Now I use Jquery code </p> <pre><code>$("#dataTable th").click(function () { if ($("th").hasClass("sortable") { // has specialclass var colIndex = $(this).parent().children().index($(this)); $('tr').find('td.td-sorting').removeClass('td-sorting'); $('tr').find('td:eq(' + colIndex + ')').addClass('td-sorting'); } }); </code></pre> <p>This part of code works fine:</p> <pre><code>var colIndex = $(this).parent().children().index($(this)); $('tr').find('td.td-sorting').removeClass('td-sorting'); $('tr').find('td:eq(' + colIndex + ')').addClass('td-sorting'); } </code></pre> <p>But not works call function only for TH with class "sortable"</p> |
13,354,820 | 0 | <p>PayPal has a great mobile experience and it will automatically switch to that if using a mobile device. How do you have PayPal integrated now? Are you just using a standard button? How long ago did you create it?</p> <p>If you take a look at www.givemobiley.org you'll see a good example of PayPal in a mobile experience. I developed that with jQuery Mobile, and I used the Express Checkout API with PayPal.</p> <p>If you load the demo on your computer you'll see the experience you expect there, and if you load it on your mobile device you'll see the experience you'd expect there.</p> |
14,490,919 | 0 | <p>It has nothing to do with the inner function being named or not.</p> <p>In the first screenshot you're inspecting the <code>out</code> variable, which references a function returned but <code>outer</code>. That function has <code>x</code> in its closure scope.</p> <p>In the second screenshot you're inspecting the <code>outer</code> variable, which references a named global function. In that code snippet you don't have any variable to reference the result or <code>outer(3)</code>. If you assign that to a variable just like you do in the first example <code>var out = outer(3)</code> and put a breakpoint after that assignment, you'll be able to see <code>out</code>'s closure scope. Alternatively, you can inspect that by adding a "watch expression" of <code>outer(3)</code> in the debugger without the need to modify your code.</p> |
6,624,390 | 0 | <p>You probably want:</p> <pre><code>Request.QueryString("myget") </code></pre> <p>for properties on the querystring.</p> <p>Request.Form() would get you posted params</p> <p>and Request.Params() will get params from both.</p> |
31,627,620 | 0 | <p>In fragment we have to read imageview in oncreateview</p> <pre><code>@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.my_frag_layout2, container); img = (ImageView)view.findViewById(R.id.imgview); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent,0); } }); return view; } </code></pre> |
32,213,060 | 0 | <p>Provide the path to your input file as the first command line argument. </p> <p>Note: array indices might be off because I simply took your regex match variables and shifted them down by one (i.e., I didn't test this code).</p> <pre><code>use strict; use warnings; use Text::CSV; my $csv = Text::CSV->new({ binary => 1 }) or die Text::CSV->error_diag; open(my $fh, '<', $ARGV[0]) or die $!; while (my $row = $csv->getline($fh)) { print "REPLACE INTO student (ID, SIS_ID, STUDENT_NUM, USER_ID, OTHER_USER_ID) VALUES (REPLACE(uuid(), '-', ''), '$row->[23]', '$row->[25]', '$row->[1]', '$row->[26]');\n"; } $csv->eof or $csv->error_diag; close($fh); </code></pre> |
37,084,952 | 0 | <p>After_save always is called when save anything, use with moderation, and when it is called execute the method set_pennies but dont nothing, I too think that the self.update_column or update_all do what you want.</p> |
28,863,440 | 1 | Text from file to array with conditions in Python <pre><code> file = open("smth.txt","r") pom = list() string = "" for lines in file: for letter in line: if letter in "0123456789": pom.append(int(letter)) if letter == "T" : pom.append(True) elif letter.isalpha() == True: string += letter pom.append(string) file.close() print(pom) </code></pre> <p>Idea of code should be simple from a line from .txt is: 2,abc,True. The result should be [2, 'abc', True] so numbers convert to int, letters into str, and "True" into True. I have problem with that True, now the result is [2, True, 'abcrue'] what condition should be used on "True" ?</p> |
16,043,469 | 0 | <p>You can just update the object</p> <pre><code>string filmID = comboBox1.SelectedValue.ToString(); Scenario newScenario = new Scenario(); foreach (Scenario scenario in myDatabase.Scenario .Where(scn => scn.filmID.ToString().Equals(filmId)) { scenario.SceneWriter.Add(newScenewriter);before } myDatabase.SaveChanges(); </code></pre> |
18,107,366 | 0 | <p>From the Apple iOS 6.0 release notes:</p> <p>"In general, Auto Layout considers the top, left, bottom, and right edges of a view to be the visible edges. That is, if you pin a view to the left edge of its superview, you’re really pinning it to the minimum x-value of the superview’s bounds. Changing the bounds origin of the superview does not change the position of the view.</p> <p>The UIScrollView class scrolls its content by changing the origin of its bounds. To make this work with Auto Layout, the top, left, bottom, and right edges within a scroll view now mean the edges of its content view."</p> <p>You can find the <a href="http://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/index.html" rel="nofollow">full notes here</a> and find the answer to your question in the section that I quoted from. They give code examples on how to use UIScrollView in a mixed Auto Layout environment.</p> |
4,831,604 | 0 | <p>While @Gnostus is correct about the prototype placement, you have an issue because you're making an asynchronous request, but are attempting to use the response immediately after sending the request.</p> <p>In other words, the code <em>after</em> your <code>loadMore()</code> call runs <em>before</em> the response is received.</p> <p>Change your prototype to accept a <code>function</code> to be used in the callback. </p> <pre><code> // accept a function to call upon success ---------------v MyLib.prototype.loadMore = function (id, loadingDivId, url, fn) { if (this.current > -1) { this.current++; $(loadingDivId).html("<h3>Loading more records please wait...</h3>"); $.get(url + this.current, function (data) { if (data != '') { $(id).append(data); $(loadingDivId).empty(); } else { this.current = -1; // ------------v------call the function fn(); $(loadingDivId).html("<h3><i>-- No more results -- </i></h3>"); } }); } } </code></pre> <p>Then pass in the functionality that relies on the response.</p> <pre><code>$('#loadMore').click(function () { if (lib.current > -1) { // pass in your function -----------------------------v lib.loadMore("#results", "#loading", '/home/search/', function() { // This if() statement could be removed, since it will // always be "true" in the callback. // Just do the $("#loadMore").hide(); if (lib.current == -1) { $("#loadMore").hide(); } }); } return false; }); </code></pre> <p>Or if this will be standard functionality, you could add the function to the <code>prototype</code> of <code>MyLib</code>, and just have it accept the relevant arguments. Then your <code>loadMore</code> can simply call it from <code>this</code>.</p> |
4,062,751 | 0 | Ext-js: How to resize / close browser window? <p>Does Ext-js come with functionality to manipulate the browser window?</p> <p>Specifically, I want to resize and close the current browser window.</p> <p>(Browser window, the browser's native window, as opposed to Ext-js' widgets).</p> <p>It it possible or must I resort to plain old javascript?</p> |
11,596,647 | 0 | <p>Give an id to the div surrounding the birthday tags:</p> <pre><code><div id="required"> Birthday: <select name="birthday_day" class="required"> <option value="">Day</option> <option value="1" >1</option> <option value="2" >2</option> </select> <select name="birthday_month" class="required"> <option value="">Month</option> <option value="1" >January</option> </select> <select name="birthday_year" class="required"> <option value="">Year</option> <option value="1900" >1900</option> </select> </div> </code></pre> <p>Use the code below to apply a red border if any of the select tags are not selected:</p> <pre><code>$('#doRegister').click(function(){ var a = $('select[name="birthday_day"]').val(); var b = $('select[name="birthday_month"]').val(); var c = $('select[name="birthday_year"]').val(); if(a == '' || b == '' || c == '') { $('div#required').css('border', '1px solid f60f60'); } else { $('div#required').css('border', 'none'); } }); </code></pre> <p>This,of course, avoids the use of the validator plugin that you're using</p> |
34,362,574 | 0 | How to pass mule logger category dynamically <p>I am scenario where the loggers in a mule sub-flow should write to the same log file where the parent\main flow logs. The parent flow which invokes the sub-flow will be different but the log should write into the respective log file defined for the parent flow.</p> <p>What I would be requiring here is a feature where I could dynamically pass the category value in a mule logger. I tried passing a flowVars using the mule expression in the logger category but It seems not effective (PFB).</p> <pre><code><set-variable variableName="flow" value="com.cisco.flow1" doc:name="Variable"/><logger message="Inside the service --- ${sys:mule.home}${sys:file.separator}logs${sys:file.separator}log4j-research.log" level="INFO" doc:name="Logger" category="#[flowVars.flow]"/> </code></pre> <p>Could anyone suggest a way to address the above requirement?</p> <p>Mule Version: 3.7.0</p> <p>Regards Arun</p> |
23,911,059 | 0 | <p>The percent sign <code>%</code> has special meaning in Makefiles.</p> <p>In order to perform the Windows batch-file substitution, you need to escape it like this:</p> <pre><code>echo %%PATH%% </code></pre> <p>This seems to work too:</p> <pre><code>"echo %%PATH%%" </code></pre> <hr> <p>Another option is to perform the substitution on the Make side, but that's a different thing:</p> <pre><code>echo $(PATH) </code></pre> |
37,821,379 | 0 | <p>The code you are referring to is proprietary to your application's code. There is no standard for what these mean - it's up to your application to know what they mean. What are they? It's an <a href="http://docwiki.embarcadero.com/RADStudio/Berlin/en/Simple_Types_(Delphi)#Enumerated_Types" rel="nofollow">enum (or enumerated) type definition</a>. But only the author(s) of this code knows the original intention. Usually, such types are documented somewhere for future developers to understand.</p> <p>If such documentation is unavailable, I suggest doing a global search of your code to find the usage of each, and observe how they're being used in the context of the code around it. I also suggest documenting things, at least as code comments, as you go along. I've even seen big libraries such as Indy raise question in the code's comments. </p> |
16,907,074 | 0 | <p>You are trying to add expression in <code>THEN</code> section of <code>CASE</code> while statement is expected. Instead of using <code>CASE</code> try to move conditions to <code>WHERE</code> section:</p> <pre><code>SELECT element FROM elementTable WHERE (date > '2013' AND element NOT IN ('e1', 'e2', 'e3')) OR (date > '2012' AND date <= '2013' AND element NOT IN ('e2', 'e3')) OR (date > '2011' AND date <= '2012' AND element NOT IN ('e3')) OR date <= '2011' </code></pre> |
21,844,722 | 0 | spoj http://www.spoj.com/problems/JULKA/ <pre><code> //explain below for loop what is actually being done in this loop// for(i=k-1, j=a=f=0; i>=0; i--) { b = (a*10 + temp[i]-'0') / 2; //explain a = (a*10 + temp[i]-'0') % 2;//explain if(b) f = 1;//explain if(f) klaudia[j++] = b+'0';//explain } if(!j) j++;//explain klaudia[j] = 0;//explain for(i=len1-1, j=len2-1, k=c=0; i>=0; i--, j--, k++) { a = total[i]-'0';//explain b = j>=0? diff[j]-'0' : 0;//explain if(a < b+c) { temp[k] = (10+a-b-c) + '0';//explain c = 1;//explain } else { temp[k] = a-b-c + '0';//explain c = 0;//explain } } temp[k] = 0;//explain </code></pre> <p>explain what is being done in both the for loop above why we are dividing and modulating by 2. what is the signifinace of adding 0 </p> |
6,463,842 | 0 | <p>You can look into this msdn article it has a sample example as well</p> <p><a href="http://msdn.microsoft.com/en-us/library/ee728598(v=VS.98).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ee728598(v=VS.98).aspx</a></p> |
40,237,318 | 0 | <p>I know it's probably late... but here's your answer: <code>android.support.v7.app.AlertDialog</code> in AppCompat support library use <a href="https://github.com/android/platform_frameworks_support/blob/master/v7/appcompat/res/layout/select_dialog_singlechoice_material.xml" rel="nofollow">this</a> layout by default (unless you provide your own adapter) for singleChoiceDialog:</p> <pre><code><CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/listPreferredItemHeightSmall" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="?attr/textColorAlertDialogListItem" android:gravity="center_vertical" android:paddingLeft="@dimen/abc_select_dialog_padding_start_material" android:paddingRight="?attr/dialogPreferredPadding" android:paddingStart="@dimen/abc_select_dialog_padding_start_material" android:paddingEnd="?attr/dialogPreferredPadding" android:drawableLeft="?android:attr/listChoiceIndicatorSingle" android:drawableStart="?android:attr/listChoiceIndicatorSingle" android:drawablePadding="20dp" android:ellipsize="marquee" /> </code></pre> <p>The attribute used to set this up in the theme is <code>singleChoiceItemLayout</code> so you can override it with your own layout to get whatever UI you want.</p> <p>If you just want to change the text color just define the attribute <code>textColorAlertDialogListItem</code> as you can see from the layout it's the one used for <code>android:textColor</code>.</p> <p>In general when I need something like this i go and look at the source code since it is available. The support libraries source code can be found <a href="https://github.com/android/platform_frameworks_support" rel="nofollow">here</a>, while most of the framework source code can be find <a href="https://github.com/android/platform_frameworks_base" rel="nofollow">here</a>.</p> |
26,438,756 | 0 | <p>Symfony's profiler can't scan to code for all stopwatch instances and put that into the timeline. You have to use the preconfigured stopwatch provided by the profiler instead:</p> <pre><code>public function testAction() { $stopwatch = $this->get('debug.stopwatch'); $stopwatch->start('testController'); // ... $event = $stopwatch->stop('testController'); return $response; } </code></pre> <p>However, your controller is already on the timeline...</p> |
24,426,554 | 0 | <p><code>keySet()</code> does not create a new <code>Set</code>. </p> <p>It simply offers a view of the keys in your map. It actually provides only a few operations which are iteration (with remove), size, emptiness, clear and contains. You cannot add an element to it otherwise it will throw an <code>UnsupportedOperationException</code>.</p> |
19,762,983 | 0 | gcc extension __attribute__ meanings <p>when I look some code, I find the following snap.</p> <pre><code>void ph_library_init_register(struct ph_library_init_entry *ent); #define PH_LIBRARY_INIT_PRI(initfn, finifn, pri) \ static __attribute__((constructor)) \ void ph_defs_gen_symbol(ph__lib__init__)(void) { \ static struct ph_library_init_entry ent = { \ __FILE__, __LINE__, pri, initfn, finifn, 0 \ }; \ ph_library_init_register(&ent); \ } </code></pre> <p>my question is: 1. what is <strong>stribute</strong> means? 2. when does the code run?</p> |
4,618,736 | 0 | <p>Fixed it by parameterising my command, binding to a new property on my viewmodel and moving Command into the style:</p> <pre><code> <ToggleButton Margin="0,3" Grid.Row="3" Grid.ColumnSpan="2" IsThreeState="False" IsChecked="{Binding DataContext.IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"> <ToggleButton.Style> <Style TargetType="{x:Type ToggleButton}"> <Setter Property="Content" Value="Select All"/> <Setter Property="Command" Value="{Binding DataContext.SelectAllCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"/> <Style.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="Content" Value="Select None"/> </Trigger> </Style.Triggers> </Style> </ToggleButton.Style> </ToggleButton> </code></pre> <p>Don't you just love WPF sometimes!</p> |
35,115,561 | 0 | How to change the dimensions of a div depending of a number extern to that div? jquery/css <p>I want to change the dimensions of a <code>div</code> depending of wich number contain another <code>div</code>. For example if i have the number 0 the div has to be <code>width: 20px; height 0px;</code>, if i have the number 50 the div has to be <code>width: 20px; height 50px;</code>, if i have the number 100 the <code>div</code> has to be <code>width: 20px; height 100px;</code>.</p> <p>How can I do it in css or jquery?</p> <p>I hope you understand. Thank you.</p> |
33,743,219 | 0 | <p>This is also working</p> <pre><code><LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:weightSum="5"> <Button style="?android:attr/buttonStyleSmall" android:layout_width="0sp" android:layout_weight="1" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:text="&lt;&lt;" android:id="@+id/button2" /> <TextView android:layout_width="0sp" android:layout_weight="3" android:layout_height="wrap_content" android:id="@+id/TodayDataTextView" android:text="Today Data" android:textAlignment="center" android:layout_gravity="center" android:gravity="center" android:textColor="#0000ff" android:background="#00000000" android:layout_margin="5dp" android:textSize="20dp" android:textStyle="bold|italic" /> <Button style="?android:attr/buttonStyleSmall" android:layout_width="0sp" android:layout_weight="1" android:layout_height="wrap_content" android:layout_marginRight="15dp" android:text=">>" android:id="@+id/button" /> </LinearLayout> </code></pre> |
21,841,302 | 0 | <p>you're probably looking for "FOR XML" T-SQL clause</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms178107.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms178107.aspx</a></p> <blockquote> <p>A SELECT query returns results as a rowset. You can optionally retrieve formal results of a SQL query as XML by specifying the FOR XML clause in the query. The FOR XML clause can be used in top-level queries and in sub queries. The top-level FOR XML clause can be used only in the SELECT statement. In sub queries, FOR XML can be used in the INSERT, UPDATE, and DELETE statements. It can also be used in assignment statements.</p> </blockquote> <p>take a look on this site too</p> <p><a href="http://blogs.msdn.com/b/saurabh_singh/archive/2010/05/11/export-sql-table-records-to-xml-form.aspx" rel="nofollow">http://blogs.msdn.com/b/saurabh_singh/archive/2010/05/11/export-sql-table-records-to-xml-form.aspx</a></p> |
26,656,545 | 0 | What does it mean when a function arguments follow "pass-by-sharing"? <p>This is in specific relation to Julia, where they mention this in the docs. I noticed the following happen in my Julia code: I can use values of global variables in the julia functions without even passing them to a function. Can someone explain what is happening?</p> |
30,342,024 | 0 | <p>If possible, update to Gradle 2.4. It's significantly faster (claiming 20-40%).</p> |
29,667,596 | 0 | After high traffic Cassandra WriteTimeoutException <p>I'm experimenting with cassandra to use it for storing tracking data. I process get requests (300 req/sec) with tracking information through django with uwsgi on nginx. The django application writes to cassandra (single cluster with 3 RF) directly. For this im taking the cassandra-driver (2.5.0).</p> <p>After restarting all relevant services the whole thing works for about two hours. Then the server goes down and produces a server error 500.</p> <p>Currently i don't know where the bottleneck is. Syslog show normal I/O activity on my system also CPU is just used by 32%.</p> <p>I'm working primarily with counters. My tables look like this:</p> <pre><code>CREATE TABLE rollup_hour_counter ( name text, player_id text, hour timestamp, "count" counter, PRIMARY KEY ((name, player_id), hour) ) </code></pre> <p>My code to write into cassandra looks like this:</p> <pre><code>rows = session.execute('UPDATE rollup_hour_counter ' 'SET count = count + 1' 'WHERE player_id=\'%s\' AND hour=\'%s:00:00\' AND name = \'name\'' % (player_uuid, date_now_hour)) </code></pre> <p>I did some research on the errors in the log files. </p> <p>uwsgi logs show:</p> <blockquote> <p>Thu Apr 16 07:44:04 2015 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 296] during GET /t/i/7bcdd5e185fd4608b0d3c3451f5ec56a/ (146.58.126.229)</p> </blockquote> <p>cassandra log shows:</p> <blockquote> <p>WARN [SharedPool-Worker-12] 2015-04-16 07:44:50,424 AbstractTracingAwareExecutorService.java:169 - Uncaught exception on thread Thread[SharedPool-Worker-12,5,main]: {} java.lang.RuntimeException: org.apache.cassandra.exceptions.WriteTimeoutException: Operation timed out - received only 0 responses. at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2174) ~[apache-cassandra-2.1.4.jar:2.1.4] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) ~[na:1.7.0_76] at org.apache.cassandra.concurrent.AbstractTracingAwareExecutorService$FutureTask.run(AbstractTracingAwareExecutorService.java:164) ~[apache-cassandra-2.1.4.jar:2.1.4] at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:105) [apache-cassandra-2.1.4.jar:2.1.4] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_76] Caused by: org.apache.cassandra.exceptions.WriteTimeoutException: Operation timed out - received only 0 responses. at org.apache.cassandra.db.CounterMutation.grabCounterLocks(CounterMutation.java:146) ~[apache-cassandra-2.1.4.jar:2.1.4] at org.apache.cassandra.db.CounterMutation.apply(CounterMutation.java:122) ~[apache-cassandra-2.1.4.jar:2.1.4] at org.apache.cassandra.db.CounterMutation.apply(CounterMutation.java:122) ~[apache-cassandra-2.1.4.jar:2.1.4] at org.apache.cassandra.service.StorageProxy$8.runMayThrow(StorageProxy.java:1147) ~[apache-cassandra-2.1.4.jar:2.1.4] at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2171) ~[apache-cassandra-2.1.4.jar:2.1.4] ... 4 common frames omitted</p> </blockquote> <p>nginx logs show: </p> <blockquote> <p>2015/04/16 07:43:57 [error] 2111#0: *268738 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 82.115.124.102, server: server.someservice.com, request: "GET [...] HTTP/1.1", upstream: "uwsgi://unix:///tmp/track.sock", host: "server2.someotherservice.com", referrer: "[..]"</p> </blockquote> <p>So first I thought that the uwsgi processes and sockets were responsible. I added some worker processes increased buffer size but no help.</p> <p>Second i tuned some cassandra settings but no help:</p> <p>My cassandra settings look like this:</p> <pre><code>num_tokens: 256 hinted_handoff_enabled: true max_hint_window_in_ms: 10800000 # 3 hours hinted_handoff_throttle_in_kb: 1024 max_hints_delivery_threads: 2 batchlog_replay_throttle_in_kb: 1024 authenticator: AllowAllAuthenticator authorizer: AllowAllAuthorizer permissions_validity_in_ms: 2000 partitioner: org.apache.cassandra.dht.Murmur3Partitioner data_file_directories: - /var/lib/cassandra/data commitlog_directory: /var/lib/cassandra/commitlog disk_failure_policy: stop commit_failure_policy: stop key_cache_size_in_mb: key_cache_save_period: 14400 row_cache_size_in_mb: 0 row_cache_save_period: 0 counter_cache_size_in_mb: counter_cache_save_period: 7200 saved_caches_directory: /var/lib/cassandra/saved_caches commitlog_sync: periodic commitlog_sync_period_in_ms: 10000 commitlog_segment_size_in_mb: 32 seed_provider: - class_name: org.apache.cassandra.locator.SimpleSeedProvider parameters: # seeds is actually a comma-delimited list of addresses. # Ex: "<ip1>,<ip2>,<ip3>" - seeds: "127.0.0.1" concurrent_reads: 96 concurrent_writes: 96 concurrent_counter_writes: 96 file_cache_size_in_mb: 1512 memtable_allocation_type: heap_buffers memtable_flush_writers: 96 index_summary_capacity_in_mb: index_summary_resize_interval_in_minutes: 60 trickle_fsync: false trickle_fsync_interval_in_kb: 10240 storage_port: 7000 ssl_storage_port: 7001 listen_address: localhost start_native_transport: true native_transport_port: 9042 start_rpc: true rpc_address: localhost rpc_port: 9160 rpc_keepalive: true rpc_server_type: sync rpc_min_threads: 60 rpc_max_threads: 96 thrift_framed_transport_size_in_mb: 15 memtable_flush_after_mins: 60 incremental_backups: false snapshot_before_compaction: false auto_snapshot: true tombstone_warn_threshold: 1000 tombstone_failure_threshold: 100000 column_index_size_in_kb: 64 batch_size_warn_threshold_in_kb: 5 compaction_throughput_mb_per_sec: 16 sstable_preemptive_open_interval_in_mb: 50 read_request_timeout_in_ms: 5000 range_request_timeout_in_ms: 10000 write_request_timeout_in_ms: 2000 counter_write_request_timeout_in_ms: 5000 cas_contention_timeout_in_ms: 1000 truncate_request_timeout_in_ms: 60000 request_timeout_in_ms: 10000 cross_node_timeout: false endpoint_snitch: SimpleSnitch dynamic_snitch_update_interval_in_ms: 100 dynamic_snitch_reset_interval_in_ms: 600000 dynamic_snitch_badness_threshold: 0.1 request_scheduler: org.apache.cassandra.scheduler.NoScheduler server_encryption_options: internode_encryption: none keystore: conf/.keystore keystore_password: cassandra truststore: conf/.truststore truststore_password: cassandra # More advanced defaults below: # protocol: TLS # algorithm: SunX509 # store_type: JKS # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] # require_client_auth: false client_encryption_options: enabled: false keystore: conf/.keystore keystore_password: cassandra # require_client_auth: false # Set trustore and truststore_password if require_client_auth is true # truststore: conf/.truststore # truststore_password: cassandra # More advanced defaults below: # protocol: TLS # algorithm: SunX509 # store_type: JKS # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] internode_compression: all inter_dc_tcp_nodelay: false </code></pre> <p>Does someone have an idea where the bottleneck is?</p> |
36,229,727 | 0 | <p>see below, happy coding ! :)</p> <p>In plunker you can set <code><base href="/" /></code>, you have to script that: </p> <pre><code><script> document.write('<base href="' + document.location + '" />'); </script> </code></pre> <p>You forgot some script required by ui-bootstrap :</p> <pre><code><script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-animate.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-route.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-touch.js"></script> </code></pre> <p>And you forgot to load ui.bootstrap in your module :</p> <pre><code>angular.module('modalService', ['ui.bootstrap']).service('modalService', ['$modal', function(){...}) </code></pre> <p><a href="http://plnkr.co/edit/4BiF2SlhOZDrFgMzj31z?p=preview" rel="nofollow">http://plnkr.co/edit/4BiF2SlhOZDrFgMzj31z?p=preview</a></p> |
16,759,554 | 0 | <p>As some other answers already said, there's no need to use a regular expression here. A simple <code>split</code> and some filtering will do nicely:</p> <pre><code>lines = data.split("\n") #assuming data contains your input string sld, tld = [[x.split("=")[1] for x in lines if x[:3] == t] for t in ("SLD", "TLD")] result = [x+y for x, y in zip(sld, tld)] </code></pre> |
19,710,209 | 0 | <p>That's the "evaluate the branch" part of the algorithm, except you'll first use this Bhattacharyya distance on one dimensional vectors, then two dimensional vectors, etc.</p> |
37,214,471 | 0 | <p>Right click on your solution and select Properties. In the "Startup Project" select "Multiple startup projects" and set "Action" of your projects to "Start" </p> |
37,572,947 | 0 | Angular2 DecimalPipe with input type="number" <p>On one hand I have in my component:</p> <pre><code>public test:number = 1000; </code></pre> <p>On another hand, I have created a piece of view this way:</p> <pre><code><input type="number" [ngModel]="test | number:'1.0-1'" /> </code></pre> <p>As soon as the property "test" is less than 1000, the input displays the value. Whenever it reaches 1000 and more, this value is not displayed anymore in the input.</p> <p>Here is a plunker: <a href="http://plnkr.co/edit/pFThNc1JNxfsnzJK9nCV" rel="nofollow">http://plnkr.co/edit/pFThNc1JNxfsnzJK9nCV</a></p> <p>Is there something I missed? Or am I doing something wrong?</p> |
27,359,787 | 0 | <p>Another approach is to use <code>union all</code> with aggregation:</p> <pre><code>SELECT y1, cnt1, y2, cnt2 FROM ((SELECT EXTRACT(YEAR FROM Tab_1.DATE_STMP) as y1, COUNT(*) as cnt1, NULL as y2, NULL as cnt2 FROM EMP_1 Tab_1 GROUP BY EXTRACT(YEAR FROM Tab_1.DATE_STMP) EMP_2@LINK Tab_2 ) UNION ALL (SELECT NULL, NULL, EXTRACT(YEAR FROM Tab_2.DATE_STMP) as y2, COUNT(*) as cnt2 FROM EMP_1 Tab_2 GROUP BY EXTRACT(YEAR FROM Tab_2.DATE_STMP) ) ) GROUP BY COALESCE(y1, y2) </code></pre> |
23,116,555 | 0 | Classes of javax.faces.bean are gonna be deprecated - a notification issued by NetBeans IDE 8.0 <p>I'm using NetBeans IDE <a href="https://netbeans.org/downloads/8.0/" rel="nofollow noreferrer">8.0</a>. The IDE issues a notification as shown in the following snap shot.</p> <blockquote> <p>Classes of javax.faces.bean are gonna be deprecated</p> </blockquote> <p><a href="https://i.stack.imgur.com/2i9eO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2i9eO.png" alt="enter image description here"></a></p> <p>Is there any reason for this notification, may be the classes from the specified package are going to be deprecated shortly?</p> <p>My application uses,</p> <ul> <li>Mojarra 2.2.6</li> <li>PrimeFaces 4.0</li> <li>PrimeFaces Extension 1.1.0</li> <li>GlassFish Server 4.0</li> <li>OmniFaces 1.6.3</li> </ul> <p>and other related components.</p> |
1,088,716 | 0 | <p>There is a schema describing such graph: see <a href="http://graphml.graphdrawing.org/primer/graphml-primer.html" rel="nofollow noreferrer">GraphML</a></p> <p>Example:</p> <pre><code><?xml version="1.0" encoding="UTF-8"?> <graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> <graph id="G" edgedefault="undirected"> <node id="n0"/> <node id="n1"/> <node id="n2"/> <node id="n3"/> <node id="n4"/> <node id="n5"/> <node id="n6"/> <node id="n7"/> <node id="n8"/> <node id="n9"/> <node id="n10"/> <edge source="n0" target="n2"/> <edge source="n1" target="n2"/> <edge source="n2" target="n3"/> <edge source="n3" target="n5"/> <edge source="n3" target="n4"/> <edge source="n4" target="n6"/> <edge source="n6" target="n5"/> <edge source="n5" target="n7"/> <edge source="n6" target="n8"/> <edge source="n8" target="n7"/> <edge source="n8" target="n9"/> <edge source="n8" target="n10"/> </graph> </graphml> </code></pre> |
3,377,030 | 0 | <p>It was the most terrible "error" I ever had. :-D Everytime I typed something in my textbox I refreshed a webview. That refreshing made this sound.</p> |
12,182,074 | 0 | Same or different xml namespaces? <p>In my project, there are lots of XML files of various sort, like XSDs, WSDLs, parameter maps etc. They all receive a generated namespace by the IDE, but the namespaces are not unique (across projects - elements with the same name get the same namespace) nor descriptive (or confusing - they all begin with "http://www.ibm.com/...", even though they define my own entities, not those of IBM). Namespace refactoring is necessary, then.</p> <p>My doubts are the following:</p> <p>1) Should every element have its own namespace, or should related elements share their namespaces? For instance, </p> <ul> <li>Should SOAP request and response messages belong to the same namespace, or should they have their own namespace?</li> <li>Should WSDL and related XSD use the same target namespace, or different?</li> </ul> <p>For example:</p> <pre><code>http://www.xarx.com/xmlns/TheProject/Administration/wsdl/StartProcess http://www.xarx.com/xmlns/TheProject/Administration/xsd/StartProcessRequest http://www.xarx.com/xmlns/TheProject/Administration/xsd/StartProcessResponse </code></pre> <p>or everything into</p> <pre><code>http://www.xarx.com/xmlns/TheProject/Administration </code></pre> <p>2) All generated namespaces that will be publicly visible must be corrected, sure. But what about the ones that are internal to the project - is their refactoring a waste of time? They might appear in the administration console or in logs, and wrong namespaces there could be misleading.</p> |
10,050,262 | 0 | <p><strong>Real problem in short:</strong> Circular library dependency between <code>arch</code> and <code>synergy</code>. Also, <code>base</code> actually wasn't linked to <code>common</code> library (in the CMakeLists.txt for <code>base</code>).</p> <p>Interestingly, this was caused by a configuration problem in the CMakeLists.txt files for the libraries. This had nothing to do with the CMakeLists.txt for the new <code>synergyd</code> application I had added.</p> <p>The problem was that I did not link the libraries to each other where new calls were added to classes in other libraries. However, it seems that there is now a problem with circular linking.</p> <p>For example, I could have added...</p> <pre><code>if (UNIX) target_link_libraries(arch synergy) endif() </code></pre> <p>... to CMakeLists.txt in the <code>arch</code> library, as <code>arch</code> now calls something in the <code>synergy</code> library. But this is invalid, since <code>synergy</code> already calls something in <code>arch</code>.</p> <p>Apparently this doesn't matter on Windows.</p> <p>I'm not quite sure though what caused this to start happening, as it's all old code that has been compiling fine before, and still does in other applications. I suspect most likely something to do with the recent removal of boiler plate from CArch, rather than something that CDaemonApp is doing (or maybe even a combination of both).</p> <h1>Update</h1> <p>Just in case anyone cares ;-) -- I think it is something to do with the relation between the lousy circular library dependency between <code>arch</code> and <code>synergy</code>, combined with the fact that <code>CDaemonApp.cpp</code> wasn't including <code>CApp.h</code> -- meaning that it was included at some other point, causing the weird undefined reference errors.</p> <p>To solve this properly, I have removed the circular dependency, which appeared to be the core of the problem.</p> <h1>Update 2</h1> <p>The code now fully compiles, hurrah! </p> <p>I was still seeing one last error (the topic of this question):</p> <pre><code>[ 90%] Building CXX object src/cmd/synergyd/CMakeFiles/synergyd.dir/synergyd.o Linking CXX executable ../../../../../bin/debug/synergyd ../../../../../lib/debug/libbase.a(CLog.o): In function `CLog::insert(ILogOutputter*, bool)': /home/nick/Projects/synergy/branches/1.4/src/lib/base/CLog.cpp:213: undefined reference to `kAppVersion' collect2: ld returned 1 exit status make[2]: *** [../../bin/debug/synergyd] Error 1 make[1]: *** [src/cmd/synergyd/CMakeFiles/synergyd.dir/all] Error 2 make: *** [all] Error 2 </code></pre> <p>This was simply caused by the <code>base</code> library not linking to the <code>common</code> library. Adding the following code to the CMakeLists.txt file for base fixed this:</p> <pre><code>if (UNIX) target_link_libraries(base common) endif() </code></pre> <p>Still not sure exactly why this started happening, just glad it's fixed.</p> <h1>Update 3</h1> <p>And here's the commit: <a href="http://code.google.com/p/synergy-plus/source/detail?r=1354" rel="nofollow">r1354</a></p> |
28,374,919 | 0 | <p>Of course super.awakeFromNib() ! Surprisingly my code works fine although when I println(self.image), I still get nil, println(image) non-nil ! Perhaps self.image is released soon it is used to display the image. Anyway it works ! Thank you for the answer</p> |
28,456,280 | 0 | <p>I was just having this issue with my own program. I turned out that the value I was searching for was not in my reference table. I fixed my reference table, and then the error went away. </p> |
34,317,571 | 0 | how to work around with fusion table styles limited to 5 <p>I have a fusion table. I use the following javascript code to toggle 2 styles.</p> <pre><code>fusionTableLayer.setOptions({ styles: styles1 }); fusionTableLayer.setOptions({ styles: styles2 }); </code></pre> <p>Problem is my style2 has more than 7 styles. But because of the limitation of fusiontable, the 6th and 7th styles doesn't work. How can work around this?</p> <pre><code>stylesIMD = [{ where: 'myVar <= 5', polygonOptions: { fillColor: '#27FF24', } }, { where: 'myVar > 5 AND myVar <= 10', polygonOptions: { fillColor: '#7BFB1E', } }, { where: 'myVar > 10 AND myVar <= 20', polygonOptions: { fillColor: '#D1F71A', } }, { where: 'myVar > 20 AND myVar <= 30', polygonOptions: { fillColor: '#F4C015', } }, { where: 'myVar > 30 AND myVar <= 40', polygonOptions: { fillColor: '#F06110', } }, { where: 'myVar > 40 AND myVar <= 50', polygonOptions: { fillColor: '#ED0B15', } }, { where: 'myVar > 50', polygonOptions: { // fillColor: '#5C0517', strokeWeight: strokeWeight } }]; </code></pre> |
29,083,447 | 0 | <blockquote> <p>Is there any way to do this for a standard FTP server?</p> </blockquote> <p>No. You can tell the server the position where it should start with the <code>REST</code> (restart) command, but you cannot tell it how much data it should send. All you can do is close the data channel after you've received the amount of data you want. The FTP server will probably complain about this because it received a RST (writing against a closed socket) but in most cases this should not cause problems.</p> |
33,493,114 | 0 | <p>Try this,</p> <p>on your blade something link below.</p> <pre><code> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <div class="form-group {{ $errors->has('name') ? 'has-error' : '' }} control-required"> {!! Form::label('title', 'Title') !!}<span class="mand_star"> *</span> {!! Form::text('title', isset($news->title) ? $news->title : \Input::old('title'), [ 'class' => 'form-control', 'placeholder' => 'News Title', 'required' => 'required' ]) !!} <span class="error_span"> {{ $errors->first('title') }}</span> </div> </div> </code></pre> <p>On your controller something like.</p> <pre><code>if ($validation->fails()) { return redirect()->route('your route path')->withErrors($validation)->withInput(); } </code></pre> <p>it works for all individual input fields also fills old data in that field.</p> <p>hope it helps.</p> |
25,694,195 | 0 | <p>You can use </p> <pre><code>window.history.go(-2) //Go two pages back </code></pre> <p>or the same method twice </p> <pre><code>history.back(); //Go one page back history.back(); //Go another one page back </code></pre> |
18,092,495 | 0 | <p>Short answer: Your form, lets call it X, needs to post back to A. A can then sign the request and then forward all of this onto B. </p> <p>If you do NOT post back to A, then how does B know that the request came from A? A has no clue what the client, who we will call Zed, sends? A only sent form X to Zed and is no longer involved in the conversation otherwise. </p> <p>Zed, can post anything in X they want to back to A. Zed may be malicious, or Zed may be the victim of a CSRF. However, your question is only that B knows that the request is coming from A. A can validate the input and take appropriate action. If A chooses to accept input form X and sign the request and send to B, B will then know that the request came from A.</p> <p>This idea is similar to what <a href="http://oauth.net/core/1.0a/" rel="nofollow">OAuth 1.0a</a> does. </p> <p>Take all form variables in X and create a URL encoded string with the keys sorted by alpha-numeric sorting. </p> <pre><code>$str = "keyA=<val1>&keyB=<val2>&keyB123=<val3>"; </code></pre> <p>Then hash and sign this. <a href="http://php.net/manual/en/function.hash-hmac.php" rel="nofollow">HMAC-SHA1 is once such algorithm</a> to do this. For the key, you need to generate some random string of characters and numbers. Both A and B should know this value and you should keep it VERY PRIVATE. You can then generate the signature to add to your request to B. </p> <pre><code>$signature = hash_hmac("sha1", $str, $key); </code></pre> <p>B can verify the signature for form X by performing the same steps that you did to create the original <code>$str</code>.</p> |
36,994,942 | 1 | Cron execution of python script not working like expected <p>I have a python script which is executed by cron, it's purpose is to manage messages from users to other users. These messages are stored inside a mongodb database. The script crawls through the messages, looks for the target name, fetches it's _id from the db and stores the message data inside the users message array. After that the message is deleted from the message collection.</p> <p>If I execute the python script manuallly everything works fine, but if Cron runs it the user will not be updated but the message will be deleted.</p> <p>The mongodb server is 2.4.10, I know it's old but it's the latest verion which runs on a raspberry pi 2, afaik. The python version is 2.7.x</p> <pre><code># ... # find all messages in messages collection cursorMsg = db.messages.find({}) # iterate over every key in cursor for keyMsg in cursorMsg: body = keyMsg["body"] about = keyMsg["about"] created_at = keyMsg["created_at"] sender_id = keyMsg["sender_id"] cursorUsrSender = db.users.find({"_id": str(sender_id)}) sender_name = keyMsg["sender_name"] sender_id = keyMsg["sender_id"] to = keyMsg["to"] _id = str(keyMsg["_id"]) # find the user for the message cursorUsrTarget = db.users.find({"username": to}) for keyUsrTarget in cursorUsrTarget: print(keyUsrTarget) usr_target_id = str(keyUsrTarget["_id"]) print(type(keyUsrTarget["messages"])) new_message = { "_id": _id, "created_at": created_at, "about": about, "body": body, "sender_id": sender_id, "sender_name": sender_name, "target_id": usr_target_id } # save the message keyUsrTarget["messages"].append(new_message) db.users.save(keyUsrTarget) # delete the message from message collection db.messages.remove({"_id": keyMsg["_id"]}) </code></pre> <p>Is there a way to wait for the response of the save command or any other way to execute the delete command after a successful save?</p> <p>Dump:</p> <blockquote> <p>{u'username': u'test', u'hash': u'$2a$10$Irwx.S5gwpOOB/gAxHPAv.Fpge9i6H.mEIh.RrAwfLp.qboZwm2sq', u'firstName': u'test', u'lastName': u'test', u'schiffe': [{u'kriegsschiffe': {u'galleone': u'0', u'karacken': u'0'}}, {u'handelsschiffe': {u'koggen': u'0', u'schoner': u'0'}}], u'messages': [], u'fresh_account': u'false', u'test': u'0', u'islands': [{u'buildings': {u'resource_stores': [{u'capacity': u'1', u'level': u'1', u'max_capacity': u'1000', u'attack': u'100', u'health': u'100', u'type': u'Holzspeicher'}, {u'capacity': u'1', u'level': u'1', u'max_capacity': u'1000', u'attack': u'100', u'health': u'100', u'type': u'Steinspeicher'}, {u'capacity': u'1', u'level': u'1', u'max_capacity': u'1000', u'attack': u'100', u'health': u'100', u'type': u'Eisenspeicher'}, {u'capacity': u'1', u'level': u'1', u'max_capacity': u'1000', u'attack': u'100', u'health': u'100', u'type': u'Nahrungsspeicher'}], u'main_buildings': [{u'type': u'Hauptgeb\xe4ude', u'attack': u'100', u'health': u'100', u'level': u'1'}, {u'type': u'S\xe4gewerk', u'attack': u'100', u'health': u'100', u'level': u'1'}, {u'type': u'Steinbruch', u'attack': u'100', u'health': u'100', u'level': u'1'}, {u'type': u'Schmelzofen', u'attack': u'100', u'health': u'100', u'level': u'1'}, {u'type': u'M\xfchle', u'attack': u'100', u'health': u'100', u'level': u'1'}, {u'type': u'Hafen', u'attack': u'100', u'health': u'100', u'level': u'1'}, {u'type': u'Forschungsgeb\xe4ude', u'attack': u'100', u'health': u'100', u'level': u'1'}, {u'type': u'Handelsdepot', u'attack': u'100', u'health': u'100', u'level': u'1'}, {u'type': u'Fort', u'attack': u'100', u'health': u'100', u'level': u'1'}]}, u'island_name': u'Insel 19', u'coordinates': {u'y': 450, u'x': 250}, u'ocean': 0, u'shape': 67, u'owner': u'test', u'_id': u'57246661e844a270258159f1'}], u'_id': ObjectId('57283a079d3a22c819ca8600')} Message send to user. Message deleted from collection.</p> </blockquote> <p>crontab</p> <pre><code>*/1 * * * * pi ( python /home/py/menage_messages.py >> /home/log/messages.log ) </code></pre> |
30,667,202 | 0 | Convert code of Matlab to Simulink <p>I make one code in matlab to resolve and plot one diferential equation, but my problem now is how to make in simulink:</p> <p>The code of matlab is:</p> <pre><code>function dy = eqdif1(t,y) %y''+4y=sin^2(2x) % with initial values y(pi) = 0,y’(pi) = 0 % y(1)=y y(2)=y' dy = [y(2); (sin(2*t).^2 - 4*y(1))]; clc,clear yp = [0 0]; %initial values options = odeset('RelTol', 1e-4); [t,y]= ode23('eqdif1',[pi pi*3],yp,options); ya=-(1/6)*cos(2.*t)+ (1/4)*(cos(2.*t)).^2-(1/12)*(cos(2.*t)).^4+ (1/12)*(sin(2.*t)).^4; %analitical solution figure plot(t,y(:,1),'-',t,y(:,2),'--',t,ya,'-.') title(['y'''' + 4y = sin^2(2x)']) </code></pre> <p>Anybody can help me, with one example or explication of simulink</p> <p>Thank you</p> |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.