id
stringlengths
5
27
question
stringlengths
19
69.9k
title
stringlengths
1
150
tags
stringlengths
1
118
accepted_answer
stringlengths
4
29.9k
_codereview.8352
This is my first attempt at a jQuery plugin. If someone could help me make sure that the code is clean, efficient, and formated correctly I would really appreciate it.BackgroundSo the reason I wrote this plugin is because I cannot find an easy to use code that has already been written. Plus, many people who work with a Learning Management System could utilize this without any effort on their part. All the communication with the LMS happens within the plugin, so they don't have to really learn the process of AICC communication. The only requirement to use this plugin is, the developer will have to know what AICC variables the LMS uses. These variables are set in stone by LMS and will not change per user ... everyone will have to use the same variables.LMS ProcessStep 1. User starts the course (a $.get() method is used to see if any information was previously stored. If so, load the information.)Step 2. As the user traverses the course you post information to the LMS and store the pages already viewed so you can have them start where they left off if they leave.(AKA Bookmarking)Step 3. After the user finishes the course you $.post() the information to the LMS and mark the course as passed.So the process is pretty straight forward, the only thing is the callback from the server is in straight text and that cannot be changed, so you are stuck using the format the LMS returns.What I am looking forWhat I would like is for everyone to look at the plug and see if its the best it could be and if not offer some type off feedback. This plugin works very good, but is it efficient?Here is my code, I will show the plugin code first then the HTMLjquery.aicc.js(function($){ $.extend({ aicc:function(p) { var _sid = getUrlVar('AICC_SID'); var _url = getUrlVar('AICC_URL'); var _action =(p['action']=='set')?setAICC(p['score'],p['time'],p['credit'],p['location'],p['status']):(p['action']=='get')?getAICC():false; function getUrlVar(urlVar) { var match = RegExp('[?&]' + urlVar + '=([^&]*)').exec(window.location.search); return unescape(match && decodeURIComponent(match[1].replace(/\+/g, ' '))); } function setAICC(s,t,c,l,ls,c) { $.post(_url,{command:PutParam,version:2.2,session_id:_sid, aicc_data:[CORE]\nlesson_location=+l+\ncredit=+c+\nscore=+s+\ntime=+t+\nlesson_status=+ls},function(r) { p['response'].call(this,json(r)); }) .error(function(a,b,c){p['response'].call(this,c);}); } function getAICC() { $.get(_url,{command:GetParam,version:2.2,session_id:_sid},function(r) { p['response'].call(this,json(r)); }) .error(function(a,b,c){p['response'].call(this,c);}); } function json(str) { var obj = {}; str.replace(/([^=]+)=(.*)\n/g,function(_,name,value){obj[name]=value;}); return obj; } }}); })(jQuery);index.html<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN https://www.w3.org/TR/html4/transitional.dtd><html><head><meta http-equiv=Content-Type content=text/html; charset=iso-8859-1><title>jQuery Plugin Testing Portal</title><script language=javascript src=https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js></script><script language=javascript src=library/jquery.aicc.js></script><script type=text/javascript>$(function(){/* sets aicc information */$('#setBtn').click(function(){ $.aicc( { action:'set', score:'83', time:'00:00:00', credit:'C', location:'page_1', status:'Incomplete', response:function(r) { alert(r['ERROR']); alert(r['ERROR_TEXT']); alert(r['VERSION']); } });});/* gets ALL aicc information (returns in JSON format */$('#getBtn').click(function(){ $.aicc( { action:'get', response:function(r) { alert(r['ERROR']); alert(r['ERROR_TEXT']); alert(r['VERSION']); alert(r['AICC_DATA']); alert(r['STUDENT_ID']); alert(r['STUDENT_NAME']); alert(r['SCORE']); alert(r['TIME']); alert(r['CREDIT']); alert(r['LESSON_LOCATION']); alert(r['LESSON_STATUS']); } });});});</script></head><body><button id=setBtn>Set AICC</button><button id=getBtn>Get AICC</button></body></html>Note: When the user is logged into the LMS and is taking the course, there are variables in the URL that the plugin grabs:http://www.lms.com/?AICC_SID=C0000000M00000S&AICC_URL=https%3a%2f%2fwww%2elms%2ecom%2fplateau%2fPwsAiccHere is the callback from the LMS on the $.post() and $.get(). (This is all text with each line ending with \n.)ERROR=0ERROR_TEXT=SuccessfulVERSION=2.2AICC_DATA=[CORE]STUDENT_ID=0123456STUDENT_NAME=Doe, John RSCORE=83TIME=02:35:37CREDIT=CLESSON_LOCATION=page_1LESSON_STATUS=INCOMPLETE[Core_Lesson][Objectives_Status]
Learning Management System/AICC project
javascript;jquery;html
I don't immediately see any efficiency issues with your code. It's simple and concise.But I do notice that you don't follow all the best practices for plugin authoring described here:http://docs.jquery.com/Plugins/AuthoringI guess you'll do something else than alerting ten times in production? ;)
_softwareengineering.200324
How can I convert this requirement into one requirement:For columns where there are just numbers, numeric sorting will be used. For columns that have numbers and letters, alpha-numeric sorting will be used. For Date columns, time sorting will be used. All sorting will have ascending and descending properties.
Requirements Analysis Communication
documentation
null
_unix.280274
I want to power on the computer and have a Bash script to open all my programs in different Gnome work spaces.For example:Open text editor and CLI in the first work space.Open web browser A in second work space.Open web browser B in third work space.Open two file managers in fourth work space.How to achieve that? Any alternative?Not wishing to hibernate my computer to keep the session, wish to shut down or restart often, and start fresh.
Manage Gnome GUI via Bash?
bash;fedora;gnome
This isn't via bash, but the GNOME Shell extension Auto Move Windows lets you define rules so that programs are automatically opened on predefined workspaces.If that doesn't do you what you need, you could consider extending the extension (source here; it's in Javascript) to better fit your specific need.
_codereview.32425
This time I'm not here to ask for help with my code, but to ask you to judge my code. Where can I improve? What should I do better? Where did I do things wrong? This is a quiz that I had to do as an assignment today. I'm not a professional. I'm still studying, and at the moment, I'm doing an internship.<? session_start(); ?><html><head> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js></script> <!--<script type=text/javascript src=quiz.js /> --></head><body> <div class=domande> <p>Sei ...?</p> <div class=option value=yes name=domanda0><button>YES</button></div> <div class=option value=no name=domanda0><button>NO</button></div> </div> <div class=domande> <p>Sai ...?</p> <div class=option value=yes name=domanda1><button>YES</button></div> <div class=option value=no name=domanda1><button>NO</button></div> </div> <div class=domande> <p>Ricerchi...?</p> <div class=option value=yes name=domanda1_1><button>YES</button></div> <div class=option value=no name=domanda1_1><button>NO</button></div> </div> <div class=domande> <p>Finita la spesa, tieni sempre gli scontrini?</p> <div class=option value=yes name=domanda1_2><button>YES</button></div> <div class=option value=no name=domanda1_2><button>NO</button></div> </div> <!-- domanda 2 --> <div class=domande> <p>Hai gi pensato ..?</p> <div class=option value=yes name=domanda2><button>YES</button></div> <div class=option value=no name=domanda2><button>NO</button></div> </div> <div class=domande> <p>Cerchi di...?</p> <div class=option value=yes name=domanda2_1><button>YES</button></div> <div class=option value=no name=domanda2_1><button>NO</button></div> </div> <div class=domande> <p>La tua ...?</p> <div class=option value=yes name=domanda2_2><button>YES</button></div> <div class=option value=no name=domanda2_2><button>NO</button></div> </div><script> var risposte = new Object(); var $domande = $('.domande'); $domande.hide(); var totDomande = $('.domande').size(); var domandaOn = 0; var risultato = ; var countRisposte = 0; $($domande.get(domandaOn)).fadeIn(); console.log(domandaOn); $('.option').click(function(){ countRisposte = countRisposte+1; console.log(countRisposte); var risposta = ($(this).attr('value')); var domanda = ($(this).attr('name')); if(risposta == yes){ risultato += 1; } if(risposta == no){ risultato += 0; } $($domande.get(domandaOn)).fadeOut(function(){ if(domandaOn == 0){ if(risposta == yes){ domandaOn = 4; }else if(risposta == no){ domandaOn = 1; } } if((domandaOn == 4 || domandaOn == 1) && countRisposte >1){ if(risposta == yes){ domandaOn = domandaOn+2; }else{ domandaOn = domandaOn+1; } } if((domandaOn == 2 || domandaOn == 5) && countRisposte <3){ domandaOn = domandaOn+1; } if((domandaOn == 3 || domandaOn == 6) && countRisposte > 2){ console.log(domandaOn); var resFinale = ; console.log(risultato into 6: +risultato); switch (risultato) { case 000: resFinale = result1; break; case 001: resFinale = result2; break; case 010: resFinale = result3; break; case 011: resFinale = result4; break; case 100: resFinale = result5; break; case 101: resFinale = result6; break; case 110: resFinale = result7; break; case 111: resFinale = result8; break; } console.log(resFinale); alert(risultato : +resFinale); }else{ $($domande.get(domandaOn)).fadeIn(); } }); });</script></body></html>
What do you think about my questionnaire?
javascript;jquery;html
For your convenience, here's a jsFiddle of your original code.User ExperienceThe user cannot easily amend an accidentally incorrect response, because the question fades away as soon as one clicks YES or NO. Usually, such user-unfriendliness is not desirable.LanguageI'm personally fine with you coding in Italian. However, I find this flavour of inglesiano disturbing. For example, countRisposte, domandaOn, resFinale are all weird mixtures of languages. Another programmer maintaining code like that would be likely to make a spelling mistake because of such odd words.PHPYou called session_start(), so it looks like you are using PHP. In that case, why not also use PHP to render your questions with less redundancy?<?php $domande = array( 'domanda0' => Sei ...?, 'domanda1' => Sai ...?, 'domanda1_1' => Ricerchi...?, 'domanda1_2' => Finita la spesa, tieni sempre gli scontrini?, 'domanda2' => Hai gi pensato ..?, 'domanda2_1' => Cerchi di...?, 'domanda2_2' => La tua ...?, ); foreach ($domande as $nome => $domanda) {?> <div class=domande id=<?php echo $nome ?>> <p><?php echo htmlspecialchars($domanda); ?></p> <div class=option name=<?php echo $nome; ?> value=yes><button>YES</button></div> <div class=option name=<?php echo $nome; ?> value=no><button>NO</button></div> </div><?php }?>Also, always use PHP long tags (<?php ... ?>); short tags (<? ... ?>) are officially discouraged in the PHP manual.Note that I added the id attribute to the outer <div>. I'll use that later in the solution below.JavaScript inclusionIf you omit the http: from the URL, like this:<script src=//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js></script>then your page will work equally well whether it is served using HTTP or HTTPS.Calculation of risultato and resFinaleThe way you assemble risultatoif (risposta == yes) { risultato += 1; }if (risposta == no) { risultato += 0; } seems rather fragile to me, because you would only arrive at the correct result if those statements are executed in the expected sequence.You use a long switch block to convert risultato to resFinale. It might be clearer and shorter as:// Map risultato to resFinale.// risultato = 000 -> resFinale = result1// risultato = 001 -> resFinale = result2// (etc.)// risultato = 111 -> resFinale = result8if (/^[01][01][01]$/.test(risultato)) { resFinale = 'result' + (1 + parseInt(risultato, 2));} but see the solution below for an even better approach.Question DependenciesThe code related to domandaOn is very hard to follow. The magic values you use for domandaOn don't correspond to the names of the questions, but to their index in the DOM. The whole mechanism is fragile. (Have fun modifying the code if you ever need to insert or remove questions!)What is particularly bad is that your if-blocks are not mutually exclusive. For example, if domandaOn == 4 and risposta == 'no' (i.e., you answer NO to Hai gi pensato ..?, also known as domanda2), you first assign domandaOn = domandaOn+1, which cascades to another assignment domandaOn = domandaOn+1 because domandaOn == 5 and countRisposte == 2. I'm pretty sure it's a bug, because your Ricerchi...? and Cerchi di...? questions are unreachable. In any case, it's nasty code that should be rethought rather than fixed.Usage of variablesYou never use risposte and totDomande.The outer parentheses are superfluous:var risposta = ($(this).attr('value'));var domanda = ($(this).attr('name'));Interestingly, while you use risposta, you never use domanda. The code could be a lot more robust and understandable if you used domanda.SolutionPutting all these ideas together and more, I would write the JavaScript code this way:// Answers to each question add these values to resFinalevar valore = { 'domanda0' : { no: 0, yes: 4 }, 'domanda1' : { no: 0, yes: 2 }, 'domanda1_1' : { no: 0, yes: 1 }, 'domanda1_2' : { no: 0, yes: 1 }, 'domanda2' : { no: 0, yes: 2 }, 'domanda2_1' : { no: 0, yes: 1 }, 'domanda2_2' : { no: 0, yes: 1 },};// The next question to present after each responsevar FINE = null;var domandeSeguenti = { 'domanda0' : { no: 'domanda1', yes: 'domanda2' }, 'domanda1' : { no: 'domanda1_1', yes: 'domanda1_2' }, 'domanda1_1' : { no: FINE, yes: FINE }, 'domanda1_2' : { no: FINE, yes: FINE }, 'domanda2' : { no: 'domanda2_1', yes: 'domanda2_2' }, 'domanda2_1' : { no: FINE, yes: FINE }, 'domanda2_2' : { no: FINE, yes: FINE },};// Show just the first question$('.domande').hide();$('#domanda0').fadeIn();var risultato = 1;$('.option').click(function(){ var risposta = $(this).attr('value'); var domanda = $(this).attr('name'); risultato += valore[domanda][risposta]; $('#' + domanda).fadeOut(function(){ var domandaSeguente = domandeSeguenti[domanda][risposta]; if (domandaSeguente == FINE) { var resFinale = 'result' + risultato; alert(risultato : + resFinale); } else { $('#' + domandaSeguente).fadeIn(); } });});I've fixed your unreachable-questions bug in the way I think you intended, so it does not behave like the original. Here's a jsFiddle of my solution.I would go one step further and rename domanda0, domanda1, etc. to something more descriptive, but I have refrained from doing so in this solution because it would be hard to compare it against the original code.SummaryThe code is complex, and needs to be simplified. Instead of hard-coding all the logic, you want to generalize, such that the application is data-driven. That way, the questionnaire is largely defined by the data structures, and the code is elegant.
_webapps.40564
Gmail has amazing functionality, which enables to use it effectively with vim-like shortcuts. I'm wondering whether there are shortcuts for Google search page as well. Do you know which shortcuts could I use in Google search in order to use it more effectively?
Is it possible to navigate in Google using only shortcuts?
google search;keyboard shortcuts
null
_cs.53739
Both convolution and linear block codes can be used for error correction. The main benefits I gathered from using convolutional codes is that, it's easy to implement and does better (than linear codes) in cases where you have higher error probability rates and noisy channels. Information bits are spread along the sequence. Lastly, these codes have memory.However, linear block codes, especially the newer ones such as polar code, can actually achieve the channel capacity. And, in block codes, information bits are followed by parity bits and code information in blocks. Lastly, they are memory less. How exactly can a noisy channel contain memory? I've read some articles, but would like some more clarification. Right now, I am under the impression that, if we find that an error occurs, with much higher frequency, on the 4th bit, for example, then we shall have some redundancy bit at that location, so no real information is lost. So that when we decode, we simply ignore the 4th bit. Am I right in my understanding?
Convolutional and Linear block codes
communication protocols;error correcting codes
A memoryless channel is one where the probability of an error at a particular bit is independent of what happened at all prior bit positions. A channel can have memory if errors are correlated across bit positions.For instance, consider the following simple binary channel: if there was no error in the prior position, then there is a probability of 0.1 that this position and the next 7 positions are all flipped (have an error); otherwise (with probability 0.9) this position is not flipped (no error). This would be an example of a channel with memory, because the probability of error for a particular bit depends upon the location of previous errors. Slightly more generally, bursty errors are an example of a channel with errors.Note that the question of whether the channel has memory is independent from whether the code has memory. You can use a memoryless code with a channel that has memory; or use a code with memory with a memoryless channel.
_cstheory.36757
Consider the following classic elementary problem:Given a string of parens like ')((()()(()', find a maximum-length balanced subsequence: ')((()()(()' = '(()())'.Dynamic programming and only a bit of thinking yield a linear time solution. (Try it, it's easy!) I got interested in a generalization:Given a string of parens and associated costs, find a balanced subsequence with maximum total cost.Or formulated differently, minimize the total cost of unmatched items.As for my question: what's the fastest known solution? Is there any literature on this fairly elementary problem? I tried to look, but couldn't find the right keywords.Note that computing any order statistic of an unordered list (like eg finding the median) can be reduced to this problem with a very simple transformation. That means that any solution for the maximum-cost balanced subsequence will have to be at least as complicated as the simplest median-finding schemes. (This is mostly a hint that nature gives us that, if we are trying to find a deterministic linear time solution, it's gotta be at least as complicated as the median-of-medians algorithm.)
Maximum-cost balanced subsequence
randomized algorithms;matching
null
_unix.67870
I'm currently using bash on Ubuntu, and I work a lot with a directory saved at /home/me/path/to/project_dir. It is a nuisance to change to the directory every time I open bash. So I'd like to save the path to a variable, say projdir, so that I can just do cd projdir. If my working directory changes, I should be able to change the path by overwriting the variable. I want to be able to update the variable easily, preferably with one command, without messing with .bashrc.One important thing is that this variable should persist even if I restart bash. How do I do this? I'd still like to see my home directory when I start up bash, so changing the default starting directory to project_dir is not an option.
Creating a variable to a directory that persists until deletion
bash
Have a look at CDPATH in man bash maybe that is already enough.Otherwise define some alias in .bashrc. I would suggest:alias setp='pwd >~/.projectdir'alias gop='cd $(cat ~/.projectdir)'
_unix.361042
I have created a bash script that runs automated EBS backups on AWS. It is kicked off via a cronjob:0 2 * * * /bin/bash /root/backup_snapshots.sh > backup.log 2>&1This works perfectly, but next thing I want to do is to add an exit code for whether or not the script runs successfully ( So I can configure a Nagios check on it). There is a few things I am going to be doing:Create the backup.log in /var/log/backup/ directory.Configure logrotate to rotate it daily, to make this check easier todetect.But one question I have is, is it possible to have cron write an exit code to the backup.log file I created? Or should I go with this type of implementation:Create crontab entry with a script that can kick off the actual script AND have an exit code like this:#!/bin/bash/root/backup_snapshots.sh 2> /dev/nullif [ $? -eq 0 ]then echo PASSelse echo FAIL >&2fiI want to make this as simple as possible so if cron can do it, awesome! If not, would the next best thing would be to create a bash script that executes backup_snapshots.sh and run via cron?
Adding an exit code to log file
cron;stdout;aws
#!/bin/bashexec 1>/var/log/backup/backup_sbapshots.log 2>&1if /root/backup_snapshots.shthen echo PASSelse echo FAILfiMake your cron script as shown which will put the cronjob run status in the backup log file. Note that there's no mention anywhere of the $? variable as the if statement does it own it's own.
_softwareengineering.310338
I'm looking for a name or design pattern on an ACL Based permission system (at least, I think it has some features of ACL).The caseAn admin is allowed to create Managers. These managers will be granted several permissions based on what the admin submits when creating the manager (note that the permissions per manager can differ). If allowed by the admin, a manager is able to create their own employee's. Only the permissions of the employee's can never extend the permissions of the managers and the permissions of the managers can never exceed the permissions of the admin.What is this kind of permission system called? Are there any standard definitions or examples of this? Or is this a novel approach to user security?
What kind of security enforces a tree of permissions on it's users?
permissions;access control
This is typically recognized as a roles access control approach, apparently NIST has written quite a bit on it and titled it RBAC - Roles Based Access Control. Moreover, they have given a standard name to the particular flavor of roles access control you described: They call it Hierarchal RBAC.Here's a NIST PDF which goes into great detail on it's conception of RBAC with much written regarding Hierarchal RBAC. To quote a little (emphasis mine):The Hierarchical RBAC component adds relations for supporting role hierarchies. A hierarchy is mathematically a partial order defining a seniority relation between roles, whereby senor roles acquire the permissions of their juniors and junior roles acquire users of their seniors. In addition, Hierarchical RBAC goes beyond simple user and permission role assignment by introducing the concept of a roles set of authorized users and authorized permissions. A third model component, Static Separation of Duty Relations, adds exclusivity relations among roles with respect to user assignments. Because of the potential for inconsistencies with respect to static separation of duty relations and inheritance relations of a role hierarchy, the SSD relations model component defines relations in both the presence and absence of role hierarchies. The fourth model component, Dynamic Separation of Duty Relations, defines exclusivity relations with respect to roles that are activated as part of a users session.
_cstheory.8548
In paper Short signatures from the Weil pairing by Boneh, Lynn and Shacham, I was going through the security proof just like any other signature.But the technique used in this paper is quite unique. Rather than using the normal challenger and adversary interaction, they have divided the proof into 6 games where each game is extended sequentially from the previous games. I am not sure why they have used this approach instead of the normal game. Does this kind of security proof aid in reducing the probability easier or have they just given it from an easy to read and understand point of view?Thanks!
On the Proof Technique of Boneh-Lynn-Shacham Gap Signatures
reference request;cr.crypto security
null
_codereview.128672
Problem:Write a program that, given a word, computes the scrabble score for that word.Code:import java.util.regex.Pattern;import java.util.Optional;import java.util.Map;import java.util.HashMap;public class Scrabble { private static final Pattern WHITE_SPACE = Pattern.compile(\\s+); private static final Map<String, Integer> SCRABBLE_SCORE_MAP = initMap(); private final String phrase; private int score; public Scrabble(String phrase) { this.phrase = Optional.ofNullable(phrase).orElse() .replaceAll(WHITE_SPACE.toString(), ).toLowerCase(); score = calculate(); } public int getScore() { return score; } private int calculate() { int score = 0; if (phrase.isEmpty()) { return score; } for (char chr : phrase.toCharArray()) { for (String key : SCRABBLE_SCORE_MAP.keySet()) { if (key.indexOf(chr) != -1) { score += SCRABBLE_SCORE_MAP.get(key); } } } return score; } private static Map<String, Integer> initMap() { Map<String, Integer> map = new HashMap<>(); map.put(aeioulnrst, 1); map.put(dg, 2); map.put(bcmp, 3); map.put(fhvwy, 4); map.put(k, 5); map.put(jx, 8); map.put(qz, 10); return map; }}Test Suite:import org.junit.Test;import org.junit.runner.RunWith;import org.junit.runners.Parameterized;import java.util.Arrays;import java.util.Collection;import static org.junit.Assert.assertEquals;@RunWith(Parameterized.class)public class ScrabbleScoreTest { private String input; private int expectedOutput; @Parameterized.Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][]{ {, 0}, { \t\n, 0}, {null, 0}, {a, 1}, {f, 4}, {street, 6}, {quirky, 22}, {OXYPHENBUTAZONE, 41}, {alacrity, 13}, }); } public ScrabbleScoreTest(String input, int expectedOutput) { this.input = input; this.expectedOutput = expectedOutput; } @Test public void test() { Scrabble scrabble = new Scrabble(input); assertEquals(expectedOutput, scrabble.getScore()); }}Design Discussion:Instead of doing same calculation again and again I cached the score.HashMap seem a fine choice to me since I needed to map letters to score.Question:Apart from OOP and encapsulation is there any scope for improvement in efficiency?Ref:http://exercism.io/exercises/java/scrabble-score/readme
Let's play Scrabble
java;performance;object oriented;programming challenge;unit testing
Some suggestions:Make the score map a HashMap < Character, Integer > so every single rated char is mapped to one integer.Do not use Regexes to remove invalid characters. Simply ignore them.Move the phrase out of the constructor. Make your calculate() method accept the phrase instead to allow re-use of the same Scrabble object.So in the end you can simplify the score evaluation a lot:public int calculate(String input) { int score = 0; for (char c: input.toCharArray()) { score += SCRABBLE_SCORE_MAP.getOrDefault(c, 0); }} In theory, this should run more performant since there are no Regex transformations, you are not cycling through the whole Map and you are not cycling through the whole String to get the score of a character.
_scicomp.8127
I want to solve the following equations:$\frac{{\partial n_D(T)}}{\partial t } = \nabla. (D\nabla n_D(T) -vn_D(T) )=0$where $D$ is the diffusion constant, $v$ is the velocity and $n_D(T$ is the concentration.$-\nabla .\kappa_{th} \nabla T =\sigma |\nabla\psi|^2$ where $T $is the temperature, $\sigma (n_D, T)$ conductivity, $\kappa(n_D, T)$ thermal conductivity.I am using dilute species and Joule heating modules to solve these equations. I can't couple them together. The coupling was done by copying the solution and then changing initial values of variables Solved for for in the dependent variables option of the solver 1. After solving thing I don't get any electric field or potential in solution. Could you please advise me ?
Coupling Equations in COMSOL
comsol
null
_unix.338177
Following the lessons learned here, I tried to add an icon to SoulSeek, the file sharing network. The problem is, different from RStudio which has a png file in one of its directories, SoulSeek runs from a single file.However, when running from a link (created with the Make Link option in the context menu of the binary file), the running app has its default icon (a blue ghostly figure, visible in the launcher bar and when I press Alt+Tab).On the other hand, the soulseek.desktop file I've created in /usr/share/applications/, though launching the app from the Super key (it didn't before), launches it with no icon at all.These are the contents of soulseek.desktop:[Desktop Entry]Type=ApplicationEncoding=UTF-8Name=SoulSeekComment=Free file sharing networkExec=/home/rodrigo/Downloads/SoulseekQt-2016-1-17-64bitIcon=/home/rodrigo/Downloads/SoulseekQt-2016-1-17-64bitTerminal=falseIf I remove the Icon key, I get the default binary icon. How to include the blue ghost default app icon, that seems encoded inside the binary?
Desktop icon without image in Gnome (Debian Jessie)
debian;gnome shell;icons;freedesktop
The Icon= key should contains the path to the .png file or just the name of the file (without the .png) if the file is installed in /usr/share/icons/hicolor/<file size>.Not the path to the executableSee: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.1.htmlEdit: If the icons are bundled in the QT executable, you indeed will have to extract the icons before. Apparently it's possible to do so with https://github.com/gcochard/png-extractor, not tested though.
_codereview.93438
I have a method that I am using to remove accents from certain characters. The problem is the massive slew of characters I am expected to work with. I have to, basically, remove accents from all Latin characters that fit within the 26 English Latin characters. (A through Z.) Performance is a very large requirement. It has to be lightning fast, as I have to run this on every character within a string, and process many large strings at a time.Currently, I use a gigantic switch statement to detect what character it is, and return the appropriate A through Z naked character, while preserving case.As of now, my switch looks something like the following:switch (input){ case '': // 0192 case '': // 0193 case '': // 0194 case '': // 0195 case '': // 0196 case '': // 0197 case '': // 0256 case '': // 0258 case '': // 0260 return 'A'; case '': // 0199 case '': // 0262 case '': // 0264 case '': // 0266 case '': // 0268 return 'C'; case '': // 0270 case '': // 0272 return 'D'; // Other upper case characters case '': // 0224 case '': // 0225 case '': // 0226 case '': // 0227 case '': // 0228 case '': // 0229 case '': // 0257 case '': // 0259 case '': // 0261 return 'a'; case '': // 0231 case '': // 0263 case '': // 0265 case '': // 0267 case '': // 0269 return 'c'; case '': // 0271 case '': // 0273 return 'D'; // Other lower case characters default: return input;}As you can probably imagine, this method is over 200 lines, and this is the only thing it does.private char RemoveAccent(char input){ switch (input) { // You saw all the case statements }}Literally, that is it. My questions come down to the following, and this is more of a question of performance/better ways of handling the situation.I know I can take a Regex and do the same thing very easily. It's what I used in the beginning as a shortcut. The problem, is that the regex is phenomenally slow. Essentially, what I was doing is looping over the 26 alphas, and then using the regex [ALPHACHARACTER], and replacing it with ALPHACHARACTER.This method, however, was horrendous in performance. Over a set of input x, with data logic y, it was a whopping 1500ms.Now, when I exclude this method from the logic, it performed at about 110ms. This is with the same input x and logic y, mind you. The only difference is that this method had a body of return input;.So, I went to the switch method, which is very high in performance, and very low in maintainability. (The Calculate Code Metrics in Visual Studio puts it at a 41 for this method.) This one performed at 120ms with the exact same remaining logic 'y' and input 'x' as the Regex option. This allows me to exclude all other logic as being the issue.The only other option I can think of, is to use an if statement on character ranges to at least make it more maintainable. The question on it is performance.if ((input >= '' && input <= '') || (input >= '' && input <= '' && input % 2 == 0)) return 'A';else if ((input == '') || (input >= '' && input <= '' && input % 2 == 0)) return 'C';else if (input >= '' && input <= '' && input % 2 == 0) return 'D';// Other upper case characterselse if ((input >= '' && input <= '') || (input >= '' && input <= '' && input % 2 == 1)) return 'A';else if ((input == '') || (input >= '' && input <= '' && input % 2 == 1)) return 'C';else if (input >= '' && input <= '' && input % 2 == 1) return 'D';// Other lower case charactersreturn input;Also, this is not all of the inputs. The 200 lines I mentioned earlier doesn't even cover a quarter of the characters I have to support. The thing is, I find the switch more readable, personally.My questions are:Is there a significantly more readable way, to write this, without significantly losing performance?Is my switch statement the way to go if I favour performance over maintainability?Should I stick with it regardless of what metrics Visual Studio might mention if it's more readable/understandable to me, and already has acceptable performance?Is there something already in .NET to do what I am that might perform faster?The only reason I ask these things, is that I feel like I'm doing something wrong, like I'm missing something in the way I approach this.Personally, I think that since I find it readable, and it's already fast enough, there's no point to change it. The only problem is that I still have a lot of options to add to it, so it will only grow in size. The management of it could get a bit out of hand.
Removing accents from certain characters
c#;performance;strings;.net;unicode
This appears to be a duplicate of this question. The link suggests using .NET's String.Normalize. If it's too slow, you could simply create an associative array (e.g., a Dictionary that maps char->char) for constant-time lookup. This is going to be large, too, but I would think it's probably easier to maintain.
_webapps.76000
There used to be a Remove from playlist link to remove any video from the currently playing playlist, as in this screenshot:However this link seems to be gone now. Is there any other way to remove a video from a playlist?I'm on Firefox/Linux.
How to remove a video from the currently playing playlist?
youtube;youtube playlist
null
_codereview.1927
I am making a simple transposition cipher. I am testing the program with the word computer with the secret key 5,2,8,3,7,1,4,6, where the encrypt method will put the 5th letter 'u' in the first position, 2nd letter 'o' in 2nd position, 8th letter 'r' in 3rd position...So the output would be:original: computerencrypted:uormecptdecrypted:computer Right now my decrypt method is of O(n^2). How can I make this faster?Where char[] y would be uormecpt. The z[j] - 1 is the offset as my iterator starts from 0, but my key starts at 1.public static char[] decrypt(char[] y, int[] z){ char[] decrypted = new char[y.length]; for (int i = 0; i < y.length; i++) { for (int j = 0; j < y.length; j++) { if (i == z[j]-1) decrypted[i] = y[j]; } } return decrypted;}
How can I make my decrypt method more efficient?
java;algorithm
If you can assume that every index in the encrypted message is included in the key, You can loop over the key and encrypted message together, placing each letter into the correct decrypted message slot directly:public static char[] decrypt(char[] encrypted, int[] key){ char[] decrypted = new char[encrypted.length]; for (int i = 0; i < encrypted.length; i++) { decrypted[key[i]] = encrypted[i]; } return decrypted;}
_webapps.25782
Is there an URL to retrieve the list of Wikipedia bots?Those are users with the bot flag.It could be HTML/XML or anything, but not the whole Wikipedia dump.No such method in the API.Note: not all bots contain bot in their name, see for instance CommonsDelinker.
URL to get the list of Wikipedia bots
wikipedia;bot
There is such method in the API, it's allusers, which has a parameter augroup that you can use to get a list of all users in a specific group.For example:http://en.wikipedia.org/w/api.php?format=xml&action=query&list=allusers&augroup=bot&aulimit=maxThis will give you the first 500 bots. If you want to get all of them, you have to use query-continue.
_codereview.151617
I am working with two web applications, one is webform-based Site1 and other is an MVC application Site2.TODO:Pass a complex object from Site1 to Site2. In response get View from Site2 to Site1 and display it: function test() { $.ajax( { type: 'POST', contentType: application/json; charset=utf-8, url: '../Chart/Mypage.aspx/GetInformation', async: false, success: function (response) { alert(response.d); var authHeader = window.btoa(Ankita:Ankita); var r = {Id:50345520,FirstName:Matthew,LastName:McCauley,MiddleName:,Suffix:null,NPI:1083043491,Address:614 Esplanade St.,City:Piscataway,State:NJ,ZIP:08854,Country:United States,SubscriberFirstName:null,SubscriberLastName:null,SubscriberMiddleName:null,SubscriberSSN:null,SubscriberDOB:null,SubscriberGender:null,SubscriberSuffix:null,SubscriberAddress:null,SubscriberCity:null,SubscriberState:null,SubscriberZIP:null,SubscriberCountry:null,VisitDate:null} $.ajax({ type: 'POST', contentType: 'application/json; charset=utf-8', url: 'http://localhost:52099/Controller/Index', data: r, headers: { Authorization: authHeader}, dataType: 'jsonp', success: function (response) { alert(done); // $(#popupdivmodal).find('div.body').html('').html(response); callFunction(response); }, error: function(e){ alert(e); } }); }, error: function () { alert(Error); } }); return false; } function callFunction(data){ $('#popupdivmodal').html(data.message); }<asp:Button ID=Scriptbtn runat=server CssClass=button Text=SureScript OnClientClick=test();></asp:Button> At Controller side [HttpGet] [BasicAuthentication(Ankita, Ankita, BasicRealm = Test)] public ActionResult Index([System.Web.Http.FromUri]ClientInformation client) { return new JsonpResult(new { message = this.RenderRazorViewToString(Index, client) }); } public class JsonpResult : ActionResult{ private readonly object _obj; public JsonpResult(object obj) { _obj = obj; } public override void ExecuteResult(ControllerContext context) { var serializer = new JavaScriptSerializer(); var callbackname = context.HttpContext.Request[callback]; var jsonp = string.Format({0}({1}), callbackname, serializer.Serialize(_obj)); var response = context.HttpContext.Response; response.ContentType = application/json; response.Write(jsonp); }}public static class RazorViewToString{ public static string RenderRazorViewToString(this Controller controller, string viewName, object model) { controller.ViewData.Model = model; using (var sw = new StringWriter()) { var viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName); var viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw); viewResult.View.Render(viewContext, sw); viewResult.ViewEngine.ReleaseView(controller.ControllerContext, viewResult.View); return sw.GetStringBuilder().ToString(); } }}By doing this I am getting a client object to the MVC app but via querystring. Is there any other way to achieve this, as querystring has its own limitation for length?
Passing a complex object across cross domain
c#;json;ajax;asp.net mvc
null
_unix.241082
For making documentation/tutorial videos, I need to highlight the mouse, for example with a yellow translucent corona around it:The marker should be active when clicking and moving, but if it's on all the time, that's just as fine.It can obscure the view on what is behind it to some degree but it may not disable being able to click what is behind it or take focus away from windows.Compiz seems like a thing of the past, find-cursor isn't tied to any actions (clicks/movements) and blocks interaction (while it's drawing, you can't click through it) and key-mon doesn't draw correctly, disables interaction as well and is generally buggy when it comes to the mouse highlighter, at least with a tiling window manager.I'm using Arch Linux and awesome wm.Thanks!
Highlight mouse for screencasts without disturbing workflow
mouse;cursor;screencasting
null
_webmaster.49405
I am using iPage shared hosting. I want to access my emails at URLs like mail.xyz.com where I can directly login to my email. Right now it is going to the iPage website and logs in from there.Can you please let me know how to set this up.
How do I set a subdomain like mail.v2techlabs.com where I can directly access my email
email;shared hosting
It sounds like you're trying to setup access to a web application for email, commonly referred to as Webmail, for your domain. The subdomain mail.abccompany.com is often used as the name of mail servers, which sends out or receives email. More often the subdomain used to access Webmail is simply: webmail.abccompany.com, and a CNAME record in the domain's DNS tables is created for that.Most web hosting packages that include email offer Webmail access, and if the web hosting company you're referring to is ipage.com, then it appears they do as well: iPage Features However, since you're using shared hosting, you likely won't have access to install or configure server applications like Webmail yourself, and therefore will be limited to what they provide. Therefore, I would suggest contacting their tech support to confirm if you can forward your Webmail access to a subdomain and to assist you further.Otherwise, if this is critical to you, I would suggest finding a different web hosting company that offers that (those using control panels like cPanel or Plesk would), or looking into VPS and dedicated servers, where you have much more control over server applications and configurations.
_computergraphics.2346
I'm a newbie to OpenGL and I was following a series by thebennybox on Youtube. Specifically his series on modern opengl programming. I thought I would try to implement his Mesh wrapper using the vector in C++ rather than using arrays of data and passing that to OpenGL. It works, but I cant' seem to render multiple meshes?Am I making an obvious mistake somewhere?This is I do to setup my mesh:glGenVertexArrays(1, &vao);glBindVertexArray(vao);glGenBuffers(BUFFER_COUNT, vbo);// vertices bufferglBindBuffer(GL_ARRAY_BUFFER, vbo[BUFFER_POSITION]);glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(positions.front()), &positions.front(), GL_STATIC_DRAW);glEnableVertexAttribArray(0);glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);// texture bufferglBindBuffer(GL_ARRAY_BUFFER, vbo[BUFFER_TEXCOORD]);glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(texes.front()), &texes.front(), GL_STATIC_DRAW);glEnableVertexAttribArray(1);glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0);// index bufferglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo[BUFFER_INDEX]);glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(indices.front()), &indices.front(), GL_STATIC_DRAW);glBindVertexArray(0);Then to render it I bind the VAO and draw the elements:glBindVertexArray(vao);glDrawElementsBaseVertex(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0, 0);glBindVertexArray(0);And finally I can send it some data:std::vector<Vertex> vertices = { Vertex(glm::vec3(0, 0, 0), glm::vec2(0, 0)), Vertex(glm::vec3(0, 1, 0), glm::vec2(1, 0)), Vertex(glm::vec3(0, 1, 1), glm::vec2(1, 1)), Vertex(glm::vec3(0, 0, 1), glm::vec2(0, 1)),};std::vector<unsigned int> indices = { 0, 1, 2, 2, 3, 0};shape = new Mesh(vertices, indices);The weird thing is that this works perfectly, but as soon as I try render another mesh it wont render the previous mesh. The weird thing is that say I had mesh A and mesh B. I can render mesh A, then I setup mesh B, and even if I don't render it, nothing renders at all. Not even mesh A. I assume this is due to the state-based-ness of OpenGL.
Can't render multiple VAO's?
opengl
null
_cs.47881
Consider a directed graph with nodes {1,2,3...n} and include an edge (i,j) whenever i<j.According to me, it should be n(n-1)/2 but the book says it's nC2(combinations).
Total number of edges in the graph
graphs
Did you try working out what n choose 2 evaluates to?
_unix.168408
As far as I know the device drivers are located in the Linux kernel. For example let's say a GNU/Linux distro A has the same kernel version as a GNU/Linux distro B. Does that mean that they have the same hardware support?
Do different distros (but same kernel ver) have same hardware support
linux;hardware;distros
The short answer is no. The driver support for the same kernel version is configurable at compile time and also allows for module loading. The actual devices supported in a distro therefore depend on the included compiled in device drivers, compiled loadable modules for devices and actual installed modules. There are also devices not included in the kernel per se that a distro might ship.I have not run into problems lately, but when I started with Linux at home I went with SuSE, although they had the same, or similar, kernel versions as RedHat, SuSE included ISDN drivers and packages out of the box (that was back 1998).
_unix.374329
I have created a script that would do certain tasks that will take quite a while. The script is ran when a device is mounted with usbmount but it turns out there is a timeout limit.systemd-udevd: timeout: killing '/usr/share/usbmount/usbmount add' systemd-udevd: '/usr/share/usbmount/usbmount add' terminated by signal 9 (Killed)There is a similar question that I found which suggests using at. However, with that I couldn't figure out how I can pass the ${UM_MOUNTPOINT} variable to my script. Any help is appreciated, thanks.
Timing out in scripts with usbmount
bash;shell script;scripting;udev
I just realized that at accepts commands from stdin, so I piped my command with the arguments to it:echo command '${UM_MOUNTPOINT}' | at nowThis solved the problem.
_webmaster.90033
I have multiple web shops (34). I want a menu with a list of links to all of them on each site. Should I use rel=nofollow? Or should I use rel=nofollow on each page except the homepage (against link spam) or no rel=nofollow at all?It looks like this on each web shop on top of the page (hidden behind a button):<ul> <li><a href=first-shop.com>first-shop.com</a></li> <li><a href=second-shop.com>second-shop.com</a></li> <li><a href=third-shop.com>third-shop.com</a></li> <li><a href=fourth-shop.com>fourth-shop.com</a></li> <li><a href=fifth-shop.com>fifth-shop.com</a></li> [...] <li><a href=last-shop.com>last-shop.com</a></li></ul>
Is it OK to have lots of external links to other domains that I own?
seo;html
You have created what is known as a network of sites: multiple domains that all inter-link to each other. To some extent, you are right to be worried. Network of sites have been used to spam search engines in the past. Google often penalizes networks of sites as link schemes.Google's Matt Cutts has a video where he address the question of whether one person can legitimately own many inter-linked domain names.Three sites is not a lot so, it's probably not going to be a huge issue but, 30 sites or 300 sites is absolutely the sort of thing where your competitor or an average user, who is landing on the page is going to be like, Why are all these different sites cross-linking and what do they really have to do with each other?Now, ideally, it might be something like a men's clothing page and a woman's clothing site and a children clothing site. And if they're relevant that's a perfect reason to link those three together. So, if it's under the same corporate umbrella, you know, whether there's a good reason to do it, I don't see that there's any problem at all and it is a relatively small number of websites to be linking. But, bear in mind as you grow and as you grow, if you have a ton of links down at the bottom of your site, a lot of regular users will get turned off by that. And a lot of competitors would be like, Oh, why is this person cross-linking every single site? So, a good rule of thumb is sort of asked a regular person off the street, and if they sort of look at it a little bit strangely, then you'll know that you've probably gone just a little bit too far.Using nofollow on those links would break apart your network of sites. As far as Google is concerned, each site would be its own separate site not linked to the others.On the other hand, you won't be penalized if:The sites are clearly relatedYou use the same brand across all of themYou don't try to hide your you identity or affiliation with all the sitesYou don't use keyword rich anchor text between the sitesYou link in a way that is not overwhelming to users (for example hidden behind a button, or only on a related sites page)This StackExchange website has links to a ton of other related StackExchange sites in the footer. Their footer links are the type that Matt Cutts called out as being spammy looking and not meant for users. Because the StackExchange sites are high quality and the links are relevant, they get away with it anyway.
_unix.82194
I would like to mount a CIFS network filesystem with samba on my Arch Linux system. I would like to mount this filesystem whenever I log in (either through ssh, a TTY, or through KDM). I can get pretty close to what I want by adding the network share to /etc/fstab. The biggest problem is that this requires either hard coding my password into /etc/fstab or creating a credentials file with my username and password. It seems unsafe to me to keep my username and password in a plain text file even if I set the permissions to 600. Is there a proper way to securely automount a network share? Can I do this with PAM (my username and password are the same on both machines) and if so how?
Proper way to mount samba share
samba
It turns out that pam_mount is the way to go. You add the network share to /etc/security/pam_mount.conf.xml<volume user=yourUserName fstype=auto path=//path/to/the/network/share mountpoint=/path/to/the/mount/point options=username=yourUserName /><mkmountpoint enable=1 remove=true />It should be theoretically possible to use the %(USER), %(USERUID), and %(USERGID) variables to make it a general mount, but I couldn't get that part to work on Arch Linux. You also need to configure your system to use pam_mount. You need to modify both /etc/pam.d/system-auth and your corresponding login-manager. For KDM it is /etc/pam.d/kde. The modifications basically involve adding optional pam_mount.so to every section of both files, but the exact details are tricky since the ordering matters. I followed the Arch Wiki.With this setup and the same username/password on the server and my machine I can auto mount without saving a credentials file anywhere.
_softwareengineering.195666
Background:I have a updator feature in my program which will downloads updates to a directory specified be the user. Then user can install these updates whenever he/she wants by just opening them. These updates are nothing but a compressed archive file which is associated to be opened by my app.Problem:Now, I want when the user install the updates, my program should ensure that they are original updates created by me and are not modified by someone else. How can I ensure that? I have heard about Winrar authenticity verification. but I'm unsure whether it is good or not?Edit: User have two ways to install the updates.A) User download the updates from the server. An update file will get saved on user PC. User will open the update file to install it.B) This is for user who don't have internet connectivity on his PC User download the update on a cyber cafe, copy it to his own PC and then install them.Since in option B, user don't have internet connectivity in his PC, so my program can not check the base value on update server.
How to authenticate an archive
authentication;software updates;verification
A hash can be provided along with the archive, and used to ensure that the entire patch contains what is expected. This is generally known as a checksum, (even if the term isn't 100% correct) and is commonly seen on some software sites as a means of verifying the result of a download. Typically, something like SHA-1 is used for the actual hash, since MD5 is known to have collisions. Of course, the hash itself could be provided by someone with malicious intent, so it alone cannot be trusted.Enter public / private key cryptography. You would keep the private key secret, and use it to sign your patches. The public key would be embedded in your client software, so that it can verify that the patch comes from someone who has the correct private key (presumably only you). You can read a bit more about digital signatures, which is typically built around the RSA algorithm.Caveat: of course, if the client install was modified (cracked), someone could have installed their own public key in it. This means they could create their own patches and sign and install them. Since you're not fully in control of the client environment, there isn't anything you can do to stop this (short of always-online, and even then...).Edit: I'd also add a word of caution against home-brew solutions. It's all to easy to think something like, Hey, I'll just come up with a clever little way to signal that the archive is genuine, like it must have a file whose name is the total file size of everything in the archive!. In this case, this algorithm would be the secret. Unfortunately, it's going to be in your client code, and it'd take a skilled programmer a few minutes of disassembly and trawling through your code to figure it out. Please use tested algorithms like RSA!Edit 2: Any commercial, off the shelf solutions are also fine (perhaps even preferred, since there's less chance of implementing it incorrectly), as long as they work along the lines I've outlined above. I'd investigate each solution carefully, and make a decision.
_unix.311838
Let's say I run tracepath to an IP address. And let's say that the first 8 hops print correctly, but after the 8th hop (let's call the 8th hop w.x.y.z), I always get 'no reply's. Now, which hop is dropping the packets:Is the hop which comes after w.x.y.z (that is, the hop which w.x.y.z forwards the packets to) dropping the packets?Or is w.x.y.z not forwarding the packets at all, hence, the packets are being dropped at w.x.y.z?
No reply after a specific hop in tracepath. Which hop is dropping the packets?
networking;traceroute
null
_webmaster.4488
I'm working on a website which will use images in several different applications, from action buttons to avatars to larger detail images. What factors should I take into consideration to decide whether these images should be jpgs, gifs, or pngs?
How do I know what image type to use?
website design;images;png;jpeg;gif
JPG for photos or high color differencesPNG for images with gradual transparency (fade from 1 color to clear)GIF for images with small color palettesObviously give each image a try and see what comes out to the smallest file size. The smaller the size the better. Also don't worry about transparency in IE6 for your PNG's, grandma isn't as concerned how your site looks just that she can see pictures of you on it.
_softwareengineering.133809
I know sessions are in PHP, ASP, ASP.NET and probably in many other languages. In most cases session solve a problem which the language itself fails to solve. I am wonderingWho created sessions and when were they first introduced?Was it a feature of a particular language first?Is the use of sessions limited to web browsers only? Or are they used in desktop applications as well?
What is the origin of sessions, by whom and when were they created?
web development;history
null
_unix.296642
I want to make kernel oom_killer run and provide the related log entries in dmesg.I set the following settingsecho 1 > /proc/sys/vm/overcommit_memoryand tried to fill up the RAM to it's max, so that OOM_killer will come in picture and will kill the memory-hungry process. Though, it's killing the application but I can not see relevant message in dmesg ?How can I see messages like:[11686.040460] flasherav invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0[11686.040467] flasherav cpuset=/ mems_allowed=0[11686.040472] Pid: 2859, comm: flasherav Not tainted 3.0.0-12-generic #20-Ubuntu[11686.040476] Call Trace:[11686.040488] [<c10e1c15>] dump_header.isra.7+0x85/0xc0[11686.040493] [<c10e1e6c>] oom_kill_process+0x5c/0x80[11686.040498] [<c10e225f>] out_of_memory+0xbf/0x1d0[11686.040503] [<c10e6123>] __alloc_pages_nodemask+0x6c3/0x6e0[11686.040509] [<c10e78d3>] ? __do_page_cache_readahead+0xe3/0x170[11686.040514] [<c10e0fc8>] filemap_fault+0x218/0x390[11686.040519] [<c1001c24>] ? __switch_to+0x94/0x1a0[11686.040525] [<c10fb5ee>] __do_fault+0x3e/0x4b0[11686.040530] [<c1069971>] ? enqueue_hrtimer+0x21/0x80[11686.040535] [<c10fec2c>] handle_pte_fault+0xec/0x220[11686.040540] [<c10fee68>] handle_mm_fault+0x108/0x210[11686.040546] [<c152fa00>] ? vmalloc_fault+0xee/0xee[11686.040551] [<c152fb5b>] do_page_fault+0x15b/0x4a0[11686.040555] [<c1069a90>] ? update_rmtp+0x80/0x80[11686.040560] [<c106a7b6>] ? hrtimer_start_range_ns+0x26/0x30[11686.040565] [<c106aeaf>] ? sys_nanosleep+0x4f/0x60[11686.040569] [<c152fa00>] ? vmalloc_fault+0xee/0xee[11686.040574] [<c152cfcf>] error_code+0x67/0x6c[11686.040580] [<c1520000>] ? reserve_backup_gdb.isra.11+0x26d/0x2c0[11686.043598] [ 2657] 999 2657 6624 128 1 0 0 telepathy-indic[11686.043602] [ 2659] 999 2659 2246 112 0 0 0 mission-control[11686.043607] [ 2662] 999 2662 5431 346 1 0 0 gdu-notificatio[11686.043612] [ 2664] 0 2664 3716 2392 0 0 0 mount.ntfs[11686.043617] [ 2679] 999 2679 12453 197 1 0 0 zeitgeist-datah[11686.043621] [ 2685] 999 2685 5196 1581 1 0 0 zeitgeist-daemo[11686.043626] [ 2934] 999 2934 16305 710 0 0 0 gnome-terminal[11686.043631] [ 2938] 999 2938 553 0 0 0 0 gnome-pty-helpe[11686.043636] [ 2939] 999 2939 1814 406 0 0 0 bash[11686.043641] Out of memory: Kill process 2603 (flasherav) score 761 or sacrifice child[11686.043647] Killed process 2603 (flasherav) total-vm:1498536kB, anon-rss:721784kB, file-rss:4228kBUPDATE: I modified the grub.cfg to remove loglevel=0 from kernel line. But still no ring bell
Why does the OOM-killer not log details to be visible through dmesg?
linux;kernel;out of memory
null
_codereview.165410
I've been tasked with resolving all dependencies to a project. Because it couldn't be simple (it never is, right?), the requirements include a few different dependency management tools. For a first version those are:MavenOSGIBecause those dependencies (and their sources) need to be analyzed for licenses, I have to download the actual files (and preferrably sources) of those items.What that means is that I have to support following functionality:Download jars in the wide interwebs from basically arbitrary urls as detailed in the maven / osgi protocol.Keep track of artifact name, version and the actual URL that we resolved to. In the best case (aka. in the future) the program should already put a preliminary license onto the artifact.Write out the results into a csv and shut down the program.To support this I devised the following main routine, which takes care of coordinating all processes involved in this mess.public class Main { private static final String MAVEN_SHORT = m; private static final String MAVEN_LONG = maven; private static final String OSGI_SHORT = o; private static final String OSGI_LONG = osgi; private static final String THREADS_SHORT = t; private static final String THREADS_LONG = threads; private static final Executor consumer = Executors.newSingleThreadExecutor(); private static final int DEFAULT_THREAD_COUNT = 8; private static Executor workers; private static final PriorityBlockingQueue<ResolutionTask> taskQueue = new PriorityBlockingQueue<>(); public static void main(String[] args) { CommandLineParser cli = new DefaultParser(); Options opts = new Options(); // TODO Option.Builder? opts.addOption(Option.builder(THREADS_SHORT).longOpt(THREADS_LONG).hasArg(true).desc(The number of threads to use for resolution).build()); opts.addOption(MAVEN_SHORT, MAVEN_LONG, true, A maven-dependency declaration xml to analyze); opts.addOption(OSGI_SHORT, OSGI_LONG, true, An osgi-target descriptor xml to analyze); List<DependencyResult> depResults = new ArrayList<>(args.length / 2); try { CommandLine commandLine = cli.parse(opts, args); int threads = 0; for (Iterator<Option> options = commandLine.iterator(); options.hasNext(); ) { Option currentOption = options.next(); switch (currentOption.getOpt()) { case THREADS_SHORT: threads = Integer.parseInt(currentOption.getValue()); break; case MAVEN_SHORT: taskQueue.put(new MavenResolutionTask(taskQueue, currentOption.getValue())); break; case OSGI_SHORT: taskQueue.put(new OsgiResolutionTask(taskQueue, currentOption.getValue())); break; } } if (threads == 0) { threads = DEFAULT_THREAD_COUNT; } workers = Executors.newFixedThreadPool(threads, runnable -> { Thread result = new Thread(runnable, WorkerQueue Thread); result.setDaemon(true); return result; }); ResolutionTask finalizer = new ResultProcessingTask(depResults); taskQueue.put(finalizer); consumer.execute(() -> { List<CompletableFuture<DependencyResult>> currentCompletables = new ArrayList<>(); for (Iterator<ResolutionTask> taskIterator = taskQueue.iterator(); taskIterator.hasNext(); ) { ResolutionTask task = taskIterator.next(); if (task == finalizer) { CompletableFuture<Void> cleanup; // TODO is synchronized necessary?? synchronized (currentCompletables) { cleanup = CompletableFuture.allOf(currentCompletables.toArray(new CompletableFuture<?>[0])); currentCompletables.clear(); } cleanup.join(); if (taskQueue.isEmpty()) { try { finalizer.call(); } catch (Exception e) { e.printStackTrace(System.err); } } else { taskQueue.put(finalizer); } } else { CompletableFuture<DependencyResult> completable = new CompletableFuture<>(); workers.execute(() -> { try { DependencyResult res = task.call(); completable.complete(res); } catch (Exception e) { completable.completeExceptionally(e); } }); // TODO is synchronized necessary?? synchronized (currentCompletables) { currentCompletables.add(completable); } } } }); } catch (ParseException e) { // Something really went wrong. e.printStackTrace(System.out); } }}For the sake of completeness:MavenResolutionTask, OsgiResolutionTask and ResultProcessingTask all extend the abstract class ResolutionTask, which is defined as follows:public abstract class ResolutionTask implements Callable<DependencyResult>, Comparable<ResolutionTask> { protected static final int HIGH_PRIORITY = 10; protected static final int MEDIUM_PRIORITY = 5; protected static final int LAST_EXECUTE = Integer.MIN_VALUE; protected final int priority; protected ResolutionTask(int priority) { this.priority = priority; } @Override public int compareTo(ResolutionTask resolutionTask) { return priority - resolutionTask.priority; }}I'm looking for a review especially on how I solved the synchronization and termination problem. While there is a logical execution graph, I disliked the standard termination detection mechanisms (such as the Dijkstra-Scholten-Algorithm), since the execution graph could possibly be quite large.I'm aware there's some todo comments that need adressing, as well as some major readability issues, but those are not worth tackling if the algorithm doesn't work quite as I intended, nor should I be tackling them when a simpler solution to this exists.
Recur-ratively resolve dependencies and summarize all results
java;algorithm;concurrency
null
_unix.252921
Actually I followed this article and installed Postfix and configured it. But its not sending mail to the entered email address. with the following command I tried to send email. echo This is the body of the email | mail -s This is the subject line [email protected] I missed to do?.
How can I send mail from localhost by using postifx
email
null
_unix.273140
I want to change the value from 1521 to 1525 in FROM_HOST only in file gexhosts.cat:FROM_HOST db201521TO_HOST db201521Is there a way to do that or some work around?I would really prefer if we could use sed as I am using sed for many other activities of mine.
SED Search and Replace on Linux
linux;sed;regular expression;perl;replace
You can do:sed '/^FROM_HOST/ s/1521$/1525/' gexhosts.catTo edit the file in place:sed -i.bak '/^FROM_HOST/ s/1521$/1525/' gexhosts.catThe original file will be backed up as gexhosts.cat.bak and the modified file will be gexhosts.cat.If you don't want to keep a back up:sed -i '/^FROM_HOST/ s/1521$/1525/' gexhosts.cat
_cs.14025
I'm studying for the computer science GRE, and as an exercise I need to provide a recursive algorithm to compute Fibonacci numbers and show its correctness by mathematical induction.Here is my recursive version of an algorithm to compute Fibonacci numbers:Fibonacci(n): if n = 0 then // base case return 0 elseif n = 1 then // base case return 1 else return Fibonacci(n - 1) + Fibonacci(n - 2) endifHow can I prove the correctness of this algorithm by induction?
Prove correctness of recursive Fibonacci algorithm, using proof by induction
algorithms;algorithm analysis;correctness proof;induction
null
_softwareengineering.104355
I've done some searching around on how to interpret morse code inputted by a human. I haven't found any existing libraries or applications that do this, but I found some academic papers on how it can be done.Before embarking on the journey of trying to interpret the academic language and advanced topics I have to know if it is okay for me to use these papers? What kind of license do they have? One I'm thinking of specifically is A Morse-code recognition system with LMS and matching algorithms for persons with disabilities. but also others floating around. The paper mentioned appears to cost money to read, but then what? Can it have been patented? What rules apply here?
License on papers published at universities?
patents;licensing
If the patent had been applied for before the paper was written, it would probably say in the paper. But it might have been patented AFTER the paper was written, so you'd best look up the authors at the USPTO website.I am not a lawyer, but I don't think there is any license at all on algorithms that are published in academic papers. There would be a license on software that was produced by an academic institution, but that's a different thing.However, what Academia just about always cares about more than licensing is getting proper credit for their discoveries. Thus you should credit that paper's authors and their institution in your app's About Box (if it has one), in the online help if it's a command-line program, or on your app's website if it's a web app. Also credit them in your documentation.Finally email the authors to tell them that you are using their algorithm. The chances are pretty good that they didn't expect to make money from it, but the fact that their invention is being put to good use in industry will help them get grants, advanced in rank (say from associate professor to full professor) or maybe even get tenure.I have seen an academic source code license that more or less says you can do what you want with the code provided the original authors get visible credit for their work. To do otherwise would be just like using their paper's results in your own paper without providing a citation, which is a form of plagiarism.
_unix.43003
I used to have a co-worker who was really good at UNIX.He showed me how to use Vi key bindings to edit my shell commands. He placed the command in a file that ran every time I logged in.Since then, I've moved to a different project. Unfortunately I don't remember how to set this up.Is there anyone here who knows how to use Vi key bindings to edit commands in the terminal? How can I make that setting permanent?
Using VI keys to edit shell commands in UNIX
shell;vim;terminal;vi
You're talking about the greatest feature ever!You can use vi commands to edit shell commands (and command history) by adding this to your .bashrc file:set -o viYou can also run that command from the command line to affect only your current session.If you don't use bash, substitue the appropriate rc file for your shell.This allows you to use vi commands to edit any command...You can also use j and k to move through your history (after pressing ESC).You can also use / (after hitting ESC) to search for old commands.In other words, to find that super-long cp command you did ten minutes ago:ESC/cpENTERThen you can cycle through all the matching commands in your history with n and N.All this makes me 10 trillion times more productive at the command line!
_softwareengineering.215527
We are a small, very specialized, benefits administration firm with an extremely useful, robust collection of software, some written in COBOL but most in BASIC. Two full-time consultants have ably maintained and improved this system over more than 30 years. Needless to say they will soon retire. (One of them has been desperate to retire for several years but is loyal to a fault and so hangs on despite her husband's insistence that golf should take priority.)We started down the path of converting to a system developed by one of only three firms in the country that offer the type of software we use. We now feel that although this this firm is theoretically capable of completing the conversion process, they don't have the resources to do so timely, and we have come to believe that they will be unable to offer the kind of service we need to run our business. (There's nothing like being able to set one's own priorities and having the authority to allocate one's resources as one sees fit.)Hardware is not a problem--we are able to emulate very effectively on modern servers. If COBOL and BASIC were modern languages, we'd be willing to take the risk that we could find replacements for our current consultants going forward. It seems like there ought to be a business model for an IT support firm that concentrates on legacy platforms like this and provides the programming and software development talent to support a system like ours, removing from our backs the risks of finding the right programming talent and the job of convincing younger programmers that they can have a productive, rewarding career, in part in an old, non-sexy language like BASIC.In short, as non-IT managers, how can we best manage this transition?
How should a non-IT manager secure the long-term maintenance and development of essential legacy software?
legacy
null
_unix.307015
The fourth column in the output of free is named shared. On most outputs I can see in internet, the shared memory is zero. But that's not the case on my computer:$ free -h total used free shared buff/cache availableMem: 7,7G 3,8G 1,1G 611M 2,8G 3,0GSwap: 3,8G 0B 3,8GHere is also an excerpt of the output of ps_mem.py: Private + Shared = RAM used Program--------------------------------- 21.4 MiB + 1.0 MiB = 22.4 MiB bash (9) 29.2 MiB + 5.3 MiB = 34.5 MiB Xorg 35.9 MiB + 858.5 KiB = 36.7 MiB tor 42.9 MiB + 9.6 MiB = 52.5 MiB urxvt (16)121.0 MiB + 24.9 MiB = 145.8 MiB okular (2)151.8 MiB + 2.8 MiB = 154.6 MiB soffice.bin 3.7 GiB + 209.3 MiB = 4.0 GiB chromium (39)--------------------------------- 4.6 GiB=================================What is the meaning of a shared memory?Main answer in the Question 14102 says: shared: a concept that no longer exists. It's left in the output for backward compatibility. Looks insufficient to me. A non-existent concept does not take 600+ MB of RAM.
What is the meaning of `shared` memory in the `free` shell command?
memory;ram
null
_computergraphics.3723
I have a human body 'surface' mesh data.: triangular mesh (vertices, face)What I want to get from this is 'exact-down-sampled' version of the current mesh.Which means.. the processed output mesh should have the vertices that all belong to the input mesh and the mesh data should be in the triangular mesh form..I know there are some surface mesh simplification algorithms, such as poisson surface reconstruction algorithm. But as far as I know, they don't preserve the positions of the input mesh. What I simply want is to down-sample the points and triangulate them.
exact down sampling and re-triangulation of mesh data(non-convex)
algorithm;mesh
null
_unix.197098
i am trying to add a custom action to the nemo file manager. The purpose of the action is just to replace all whitespace in the filename by _.My action file looks like this:[Nemo Action]Name=NormalizeComment=replace all occurences of by _Exec=<normalize.sh %F>Selection=AnyExtensions=AnyThe bash script normalize.sh is i the actions directory and looks like this:#!/usr/bin/bashif [[ $# != 1 ]] then exit 1finame=`echo $1 | sed s/\ /\_/g`mv $1 $nameexit 0Does anybody know, why this isn't working?
custom nemo actions / bash script
bash;cinnamon;file manager;nemo
The problem:Your problem is so trivial, that %F is the filename, and the filename contains spaces, so you're calling the script by this way:normalize.sh my fancy fileSo $1 becomes my, $2 becomes fancy and $3 becomes file. Now $# becomes 3.Fix 1 (recommended):To fix that. you don't need to check the number of arguments. Then you can use $@ instead of $1. The script will look like this:#!/usr/bin/bashname=`echo $@ | sed s/\ /\_/g`mv $@ $nameexit 0Fix 2:Another solution is to put quotes around %F. The correct code would be this:[Nemo Action]Name=NormalizeComment=replace all occurences of by _Exec=<normalize.sh %F>Selection=AnyExtensions=AnyImproved script:#!/usr/bin/env bashmv $@ $(tr ' ' '_' <<< '$@')exit 0Normally bash is on /bin/bash. As yours seems to be on /usr/bin/bash (the first time that I see this) I put a universal workaround to run bash wherever it be. However you can see the path to bash typing which bash on a terminal.Removed conditional to count arguments.Why use sed for that existing tr?Instead of echo the file to sed or tr, better use <<<.Why not to put all in one line?
_unix.115607
When I run the following hasys command with awk , I get output with machines names as the following:hasys -display|grep Shutdown | awk '{print $1}' machine1a machine1bplease advice how to print the machines names in one line as the following: examplehasys -display|grep Shutdown | awk '{print $1}' machine1a machine1bwhat I need to add in my awk syntax so I will able to print the names in one line?
awk + print awk output in one line
awk;ksh
You can say:hasys -display | grep Shutdown | awk '{print $1}' ORS=' '
_cs.71640
There are x digits and y boxes where y is between 1 and x inclusive. I have to print all the possible digits in boxes (combinations) in any order. For examples, if x = 5 and y = 2 we can have the following 4 combinations:1234 5123 4512 3451 2345Similarly if x = 5 and y = 3123 4 512 34 512 3 451 234 51 23 451 2 345if x = 5 and y = 5 then there is only 1 combination1 2 3 4 5Both x and y are variable and I can't figure out even a brute force way of doing this. I have tried using three nested for loops but have no luck.
Stuck on a combinations algo question
algorithms
null
_webapps.18850
Is there a way to print your Facebook Friends List? Not their information, just the names on your list. It would make it much easier to see who you lost when your amount of friends changes if you could have a list of who you are friends with. After you have so many, it is hard to determine.
Printing friends list off Facebook with just their names
facebook;friends;printing;friend list
null
_webmaster.100956
When implementing hreflang in the head section, do you call out the alternative and main language on every single page?So for example if I'm implementing Brazilian Portuguese where the main language of the site is English, for my English site it would place the following in the head section:<link rel=alternate href=http://example.com/about hreflang=en-US /><link rel=alternate href=http://example.com/about hreflang=en /><link rel=alternate href=http://example.com/pt-br/about hreflang=pt-br />Then for the Portuguese site it would be:<link rel=alternate href=http://example.com/pt-br/about hreflang=pt-br /><link rel=alternate href=http://example.com/pt-br/about hreflang=pt /><link rel=alternate href=http://example.com/about hreflang=en />
Implementing the hreflang tag in the head
seo;language;hreflang;translation
Yes that is how Google know it.But use only one line out of these two lines, <link rel=alternate href=http://example.com/about hreflang=en-US /><link rel=alternate href=http://example.com/about hreflang=en />because it is pointing to same URL. I can't say weather it is harmful or not for SEO but if Google have any testing tool for hreflang then it will trigger some error on that. So If your webpage completely written in US English language then keep it first line otherwise choose second one. Same apply to Portuguese hreflang links. On this Google official article you can see one example about that.It's a good idea to provide a generic URL for geographically unspecified users if you have several alternate URLs targeted at users with the same language, but in different locales. For example, you may have specific URLs for English speakers in Ireland (en-ie), Canada (en-ca), and Australia (en-au), but want all other English speakers to see your generic English (en) page, and everyone else to see the homepage. In this case you should specify the generic English-language (en) page for searchers in, say, the UK. You can annotate this cluster of pages using a Sitemap file or using HTML link tags like this:<link rel=alternate href=http://example.com/en-ie hreflang=en-ie /><link rel=alternate href=http://example.com/en-ca hreflang=en-ca /><link rel=alternate href=http://example.com/en-au hreflang=en-au /><link rel=alternate href=http://example.com/en hreflang=en />
_softwareengineering.95571
In an e-commerce site, when adding an item to a cart, I'd like to show a popup window with the options you can choose. Imagine you're ordering an iPod Shuffle and now you have to choose the color and text to engrave.I'd like the window to be modal, so I'm using a lightbox populated by an Ajax call. Now I have two options:Option 1: Send only the data, and generate the HTML markup using JavaScriptWhat's nice about this is that it trims down the Ajax request to the bear minimum and doesn't mix the data with the markup.What's not so great about this is that now I need to use JavaScript to do my rendering, instead of having a template engine on the server-side do it. I might be able to clean up the approach a bit by using a client-side templating solution.Option 2: Send the HTML markupWhat's good about this is that I can have the same server-side templating engine I'm using for the rest of my rendering tasks (Django), do the rendering of the lightbox. JavaScript is only used to insert the HTML fragment into the page. So it clearly leaves the rendering to the rendering engine. Makes sense to me.But I don't feel comfortable mixing data and markup in an Ajax call for some reason. I'm not sure what makes me feel uneasy about it. I mean, it's the same way every web page is served up -- data plus markup -- right?
Should I include HTML markup in my JSON response?
mvc;django;templates;json
JSON should just contain the data and no markup. In the long run this approach is more extensible because there is potential for using the JSON data in other parts of your site. If you include markup then using the same data to populate another template becomes much harder.
_softwareengineering.138561
Why would I want to write a web app with lots of processing server-side?To me, writing the program client-side is a huge advantage because it takes away as much server load as possible because it only has to send data to the client with minimal processing.I see very little on writing web-apps besides writing it server-side and treating client-side as only a view. Why would I ever want to do this? The only advantage I see is that I can write in whatever language I want (http://www.paulgraham.com/avg.html).
Pros/cons between emphasizing client-side or server-side processing
web applications;server side;client side
There are two major issues. The first is easy--you usually don't know what sort of resources are available on the client side. If it requires 1.5GB to process something, can you really push that onto an unknown client browser (IE, Safari, Opera, Firefox, etc.) on an unknown client platform? Will the client appreciate his system dogging when you overwhelm it?The second is more architectural--what layers do you want to expose to the outside world? Most would agree that it's incredibly risky to expose your data layer. How about your service layer? Do you really want to deliver that logic out there? If you do, are you also exposing the entry points to your data layer? If you keep the service layer server side, then what's left? The UI, right? See reason 1 about for considerations on how much of that lives on the server and how much on the client.
_softwareengineering.210111
If an agile team has members like Developers, Testers, and Automation Testers from different geographical regions, how can the daily scrum meeting can happen?Obviously they have to work in different time zones. Can this be successfully managed? Do you think the daily scrum meeting can be replaced by sending status emails at the end of day, or by answering the three Scrum questions in an email?
Can a daily scrum meeting be replaced by a status email?
agile;scrum
In my experience nothing beats a meeting face to face - even if it's over a video conference link. In my current project, we have developers and Scrum team members all over the UK and we conference call in for a daily scrum. it works relatively well. I don't think emails status works as well because Scrum is supposed to be an arena for back and forth interaction. Save email status reports for project management updates. In projects where emails were the main focus for clearing issues, the delays became longer, people 'missed' emails, and eventually it slowed the project to a crawl.
_scicomp.7025
I have made a standard curve. The X-axis is logarithmic. The y-axis is linear.I have added a logarithmic trendline (y = -1.546ln(x) + 39.254; R = 0.9906).How can I re-arrange the equation to calculate an unknown X-axis value?
How do I extrapolate data from a NON-LINEAR (logarithmic) standard curve in Excel?
nonlinear equations;nonlinear algebra
null
_webapps.76367
I have tried following steps from a lot of articles online, but they all seem to be outdated.
How do I remove the profile photo from a Yahoo! account?
yahoo
Yahoo have changed things so nobody can change/edit/remove their profile pic or nickname. We have been told that we will be able to in the future, so sit and wait.
_webapps.104553
Recently one of developer of my team had an Google email as [email protected] I know about sub-addressing [email protected] is that called and how is that important?Update: I have read Google docs and I could search about + sign in the ID, which is being used for filtering purpose. Where can I find more about dash.
Gmail ID with minus sign within username
gmail
null
_unix.243067
I'm reading the TurnKey Linux 14 documentation and it states that in order to preseed values for an appliance, you have to write them to the file system before the machine boots for the first time.The most obvious way to do this that I can think of, is to boot the VM to a Live CD and mount the file system in question in order to write the file. Does VirtualBox contain another way of doing this? For instance using a bash utility of some sort to write an external file to the existing file system? I believe there was a way to accomplish this on VMWare using vSphere, which is why I am asking.
How can you write to a file system before booting using VirtualBox?
filesystems;mount;virtualbox;virtual machine;turnkey
You can use libguestfs tools to access filesystems in a virtual machine image.mkdir ~/mntguestmount -a /path/to/vm-image.vdi -m /dev/sda1 ~/mntedit files fusermount -u ~/mntLibguestfs uses QEMU, which may use KVM. KVM and VirtualBox cannot be used at the same time. If you have VirtualBox running, either close it and make sure that the kvm kernel module is loaded, or arrange to run QEMU without KVM. You can make QEMU avoid KVM (slower, but not in a way that matters to just mount the filesystem and edit a few files) by setting LIBGUESTFS_BACKEND_SETTINGS=force_tcg in the environment.
_cs.62732
I am getting properly stuck into reinforcement learning and I am currently reading the review paper by Kober et al. (2013).And there is one constant feature that I cannot get my head around, but which is mentioned a lot, not just in this paper, but others too; namely the existence of gradients. In section 2.2.2. they say:The approach is very straightforward and even applicable to policies that are not differentiable.w.r.t. to finite difference gradients.What does it mean to say that the gradients exist and indeed, how do we know that they exist? When wouldn't they exist?
When do the gradients exist in a Reinforcement Learning setting?
reinforcement learning
The gradient doesn't exist / isn't well-defined for non-differentiable functions. What they mean by that statement is that there is an analogous version of gradients that can be used, instead of the gradient.Discrete functionsIn the discrete case, finite differences are the discrete version of derivatives. The derivative of a single-variable continuous function $f:\mathbb{R} \to \mathbb{R}$ is $df/dx$; the partial difference (a discrete derivative) of a single-variable discrete function $g:\mathbb{Z} \to \mathbb{Z}$ is $\Delta f : \mathbb{Z} \to \mathbb{Z}$ given by$$\Delta f(x) = f(x+1)-f(x).$$There's a similar thing that's analogous to a gradient. If we have a function $f(x,y)$ of two variables, the gradient consists of partial derivatives $\partial f / \partial x$ and $\partial f / \partial y$. In the discrete case $g(x,y)$, we have partial differences $\Delta_x f$ and $\Delta_y f$, where$$\Delta_x f(x,y) = f(x+1,y) - f(x)$$and similarly for $\Delta_y f$.Continuous functionsIf you have a continuous function that is not differentiable at some points (so the gradient does not exist), sometimes you can use the subgradient in lieu of the gradient.
_webmaster.71450
I can't find a free hosting that supports new gTLDs. On my opinion, these are really good hosting providers: freehosting io, 2freehosting.com and even there I get an error when I try to create an account to use hosting service. EDIT: I registered a new gTLD on GoDaddy and tried to create a new account on those service providers. Still have the same error.
Is there a free hosting that supports new TLDs?
domains;looking for hosting;top level domains
null
_softwareengineering.348426
I have been involved in a project where we synchronize data from eCommerce platform like Woocommerce, Shopify etc to Accounting systems or other similar platform that share common data. I have been trying to find some good reading material about what is the right approach to take in this kind API integration softwares. We formalize the data from the origin system to an internal format and then use the internal data model to create payload for the destination system. But what I am concerned is we are not using the original payload to create payload for the destination system in this process. So I would like to directly map one System to create payload for the destination system. For example A--> B , A--> C etc. With the current approach we have A--> Internal Format , Internal Format --> B or Internal Format --> CSo one platform can can provide payload for multiple platform.I would really appreciate your opinion on what are good approach to tackle these issues? What kind of architecture would be better ? If you have some reading material on how these kind of problem should be approached then please let me know.
Approach for connecting two API's
architecture;api;integration
null
_webmaster.27299
The Content Rules was written by CC Chapman last year, and I was wondering if the book was still relivent in 2012, or if the ideas in it are dated. I started reading it in 2011, didn't finish it, but now I feel like I might have a need to read it again which is why I ask.
Is the book The Content Rules still relevant in 2012?
seo;blog;content;books
null
_unix.22444
I'm trying to remove an LVM logical volume, which I believe is not currently in use.However, when I attempted to remove it, I get an error:# lvremove /dev/vg_service1/lv_home Logical volume vg_service1/lv_home is used by another device.It's definitely not mounted, as this returns nothing:# mount | grep lv_homeIs there any way to tell what is using this logical volume?
Which device is using this logical volume?
rhel;lvm
It turned out that the logical volume was itself part of a volume group. It didn't show up in /proc/mounts or in the output of lsof. The only way I was able to discover this was through the pvdisplay command, where it appeared as a physical volume:# pvdisplay ... --- Physical volume --- PV Name /dev/vg_service1/lv_home VG Name nova-volumes PV Size 179.91 GiB / not usable 4.00 MiB ...
_codereview.148576
A magic square adds up the values in each vertical, horizontal, and diagonal row to the same value. In this case, that value is 34. I have changed different indices values and the program returns false. It seems to work just fine. But I'm just learning 2d arrays. Please let me know if you see something wrong, much appreciated. public class Blank { public static void main(String[] args) { int [][] square = { {16, 3, 2, 13}, {5, 10, 11, 8}, {9, 6, 7, 12 }, {4, 15, 14, 1} }; System.out.println(Is magic square: + magicSquare(square)); } private static boolean magicSquare(int[][] square){ //calculate the sum of the first row and assign it to n int n = sumOfRow(square[0]); for (int[] row : square) { int sum = sumOfRow(row); if (sum != n) return false; } int sum = 0; for (int i = 0; i < square.length; i++) { sum += square[i][i]; } if (sum != n) return false; sum = 0; for (int i = 0; i < square.length; i++) { sum += square[i][square.length - 1 - i]; } if (sum != n) return false; return true; } //returns the sum of the elements in the row private static int sumOfRow(int[] row){ int sum = 0; for(int el : row){ sum += el; } return sum; }}
Magic square test
java;beginner;array
null
_unix.347301
I'm using below script to replace a list of words in a file.However I'm getting this error while executing the script:can't read s/@@/AU/g: No such file or directoryCan you please let me know the issue in script?# source the properties:. config.properties######## Generating test data on runtime ###############echo **************************************************************************echo Test Data Generation for Markets .. *echo **************************************************************************IFS=, read -ra items <<<$marketsfor item in ${items[@]}do Country=`echo $item|tr [a-z] [A-Z]` date1=$(date --date=20 day ago +%Y-%m-%d %H:%M) date2=$(date --date=400 day ago +%Y-%m-%d %H:%M) epoch1=$(date --date=20 day ago +%s) epoch2=$(date --date=40 day ago +%s) cp Sample_testdata testdata_$UPPER_CASE sed -i s/@@/${Country}/g -e s/date-20/${date1}/g -e s/date-400/${date2}/g -e s/epoch_date-20/${epoch1}/g -e s/epoch_date-40/${epoch2}/g testdata_$UPPER_CASE echo test data generation completed for Market :: $Countrydone
error when replacing multiple words in line using sed
sed;scripting
null
_cogsci.15605
Does the handwriting analysis of a person predict only his/her behavior or only his/her character or both?
Is hand-writing analysis used for analysis of a person's behaviour or anlayzing a person's character?
behaviorism;psychoanalysis
null
_webmaster.72025
My old site used to write the URLs without !.Eg: www.example.com/#/productsBut it has been more than 6 months since I changed it to include ! in the URL like so:www.example.com/#!/productsBut unfortunately Google search results still show my old URL schema.There is no way I could enter in the Google Removal Tool (via their Webmaster Tools) to remove www.example.com/#/products since Google will complain about an invalid URL.All I want is to remove www.example.com/#/products and Google to show the one with /#!/products in the results instead.
How to remove a fragment / hash URL from Google search results?
url;google search;serps
null
_unix.119919
I create an distro about 6 years ago, i recall i used dh_make command, i have a suggesstion for creating distro recently, When i use :root@debian:/home/mohsen# dpkg -L debhelper |egrep dh_make/usr/bin/dh_makeshlibs/usr/share/man/man1/dh_makeshlibs.1.gz/usr/share/man/es/man1/dh_makeshlibs.1.gz/usr/share/man/fr/man1/dh_makeshlibs.1.gz/usr/share/man/de/man1/dh_makeshlibs.1.gzI'm confused.Why dh_make doesn't exist? I decide to use debian installer ,debhelper and deboostrap, But i don't know dh_make has been eliminated?
debhelper and fun question about dh_make
debian;iso;debian installer
dh_make is contained in the dh-make package. You need to install that.
_unix.215012
I have an iMac mid 2011 running OSX and I am trying to install Arch Linux following this guide. I successfully set up a dual boot last year following a similar procedure but now I can't even start since I get a kernel panic while booting from the live usb installation of archiso: right before the login prompt. I'm 100% sure the image is not corrupted (I checked the signature and booted it on another pc).Since last year it worked I tried every old release and I isolated the one that introduced the problem: it's 2015-05-01 kernel 4.0.1.Older versions boot fine and I can complete the installation but after a restart I get the kernel panic anyway.I don't know what to do because I can't change any setting on the archiso image and the stack trace goes so fast I can't even record it: in a glimpse I have noticed null pointer dereference, scheduling while atomic and fixing recursive fault but reboot is needed.How can I debug it? And, possibly, how do I solve this issue?
How to debug a kernel panic on boot with archiso?
arch linux;kernel;debugging;kernel panic
I installed the linux-lts package as suggested by @mikeserv from chroot and I set it as the default boot option from the grub configuration.This way I could boot nicely into linux 3.14 and complete the installation process. The vanilla linux kernel is installed alongside with the LTS version so using the advanced options from the grub menu I could still boot with linux 4.0 and see the system crash.I then tried using Kdump to make a memory dump of the machine during the kernel panic but for some reason I still don't know kexec won't start on the kernel I recompiled with debug options.Eventually I manage to read the kernel panic log the hard way: by recording it with a high-frame rate camera and I was able to identify the driver that caused the crash: radeon_audio_detect. The bug has been reported several times and it seems to affect all macs with a radeon gpu and other systems as well.A patch for it as already been added to the kernel in 4.2rc5
_unix.17482
I keep getting an address collision warning at boot time, between ACPI and Video Rom. If I add acpi=off to grub.conf the error goes away, but then I have no power management (battery icon, proper shutdown, etc.). Anyone know the cause or a possible solution?
Fedora 15 address collision on Compaq CQ41?
fedora;kernel;laptop;acpi
This can probably be solved in BIOS configuration. If there is a newer BIOS for your machine, you should use it.Other than that, try booting with pci=noacpi option. If this results in loosing some capabilities you desire, whereas presently everything works fine despite the acpi warning, you might just disable kernel warnings using loglevel=3 boot option. Note however, that this disables all kernel warnings, so if you run into problems in the future, you might need to disable this option for diagnosing those.
_unix.97598
I have just got a new HDD and I wanted to test the sequential read speed (the whole disk). I used:pv /dev/sda > /dev/nullThe disk is 500GB WD VelociRaptor (WD5000HHTZ). At the beginning the read spead is 194 MB/s but gradually it drops. At the end it was reading only about 118 MB/s. I am wondering if this is normal, and perhaps has something to do with the disk internal geometry. I did not expect such great variation. Besides, 118 MB/s is really slow, even for a normal HDD. The VelociRaptor is supposed to be a high end HDD for desktops.
Varing speed when reading sequentially from a HDD
hard disk;performance;hardware
It is not unusual to have significant speed differences between the inner and outer tracks of an HDD.See also this answer.
_cs.19007
I am trying to find the plain text for the following cipher text using a frequency analysisvr pvst yqlp mq nvfBut for the letters above this is really difficult, as if I use the alphabetic substitution technique, where I assume that v corresponds to e as this occurs most in the english alphabet. What about p, this also occurs three times, does this mean it corresponds to e. Same for r,s,t,y,l,m,n,j,f which occur only once. Is there an algorithm which looks at such duplicated frequencies, or do I guess:v and p corresponds to eq corresponds to t r to f correspond to a?even using the bigram method for something like this is difficult as a bigram of pv is found, if p = tand v = hthat means p doesn't correspond to t anymore? Thanks in advance!
Cryptography substitution frequency analysis
cryptography
null
_codereview.123790
This is my first time using semaphores and I was wondering if I implemented them to the best of their abilities in my code....#include <time.h>#include <stdio.h>#include <stdlib.h>#include <pthread.h>#include <unistd.h>#include<semaphore.h>#include <math.h>#define NR_THREAD 2int sum=0;unsigned int seed;sem_t sem0;void* func0(void *param) { int tmp; int i; for(i=0; i<10; i++) { sem_wait (&sem0); tmp=sum; tmp++; if(rand_r(&seed)%2) { printf(sleeping for 1 sec\n); sleep(1); } else { printf(sleeping for 2 sec\n); sleep(2); } sem_post (&sem0); sem_wait (&sem0); sum=tmp; if(rand_r(&seed)%2) { printf(sleeping for 1 sec\n); sleep(1); } else { printf(sleeping for 2 sec\n); sleep(2); } sem_post (&sem0); } return (void*)0;}int main() { int i; int error; pthread_t *tid; pthread_attr_t attr; seed=(unsigned int)time(NULL); if((tid=(pthread_t*)calloc(NR_THREAD, sizeof(pthread_t)))==NULL) { fprintf(stderr, calloc() failed\n); exit(1); } sem_init(&sem0, 0, 1); if(sem_init(&sem0, 0, 1)==-1) { perror(Failed to sem_init() sem0); exit(1); } pthread_attr_init(&attr); for(i=0; i<NR_THREAD; i++) { if((error=pthread_create(&tid[i], &attr, func0, (void*)0))) { fprintf(stderr, pthread_create() failed: %d %d\n, i, error); tid[i]=pthread_self(); } } for(i=0; i<NR_THREAD; i++) { if(pthread_equal(pthread_self(), tid[i])) continue; if((error = pthread_join(tid[i], NULL))) { fprintf(stderr, pthread_join() failed: %d %d\n, i, error); } } printf(Final sum= %d\n, sum); free(tid); if(sem_destroy(&sem0)==-1) { perror(Failed to sem_destroy() sem0); exit(2); } return 0;}It runs and gets the correct answer, but I was wondering if there were better places to put them or not. Also, I'm getting a warning, I'm receiving an implicit declaration warning on if(rand_r(&seed)%2) { and I'm not sure how to go about fixing this problem.This is a demo in which two threads each sleep 10 times.
Using semaphore in C
c;random;pthreads
null
_codereview.116696
I was having a discussion with my coworker about a function that returns either an empty string, or a string of a css class. The function is passed an object which has an HTTP status code, and then depending on that statusCode, it returns a value. We couldn't agree which is cleaner.He wanted the function written as so:function getCssClass(options) { var statusCodeCssClass = ''; var statusCode = parseInt(options.statuscode, 10); if ((statusCode >= 100 && statusCode < 200) || statusCode >= 400) { statusCodeCssClass = 'text-danger'; } return statusCodeCssClass;};And I wanted it written as so:function getCssClass(options) { var statusCode = parseInt(options.statuscode, 10); if ((statusCode >= 100 && statusCode < 200) || statusCode >= 400) { return 'text-danger'; } return '';};The main difference is that I don't think the initial empty variable should be there, and he does. His argument is that the variable makes it easier to read, and my argument is that the variable obfuscates the function.I know it's splitting hairs, but I was unable to find an answer in the Clean Code book or on Google about unnecessary variable declarations.Can someone tell me why one is better than the other?
Choosing a CSS class based on an HTTP status code
javascript;comparative review
One very important principle of modern software design is that mutability should be minimised. The first case needlessly introduces mutability by potentially modifying the value of statusCodeCssClass. Thus I'd argue it's bad practice to write code like this, regardless of whether it's easier to read (which is a completely subjective claim as both are simple and easy-to-read).However, the second approach ignores the fact that JavaScript supports an idiomatic solution to to a test a value and return one of two results based on that test problem: the ternary operator. This can be used in this situation to yield a third solution that makes better use of language features: function getCssClass(options) { var statusCode = parseInt(options.statuscode, 10); return (statusCode >= 100 && statusCode < 200) || statusCode >= 400) ? 'text-danger' : '';}However, the code could be further improved by respecting the single responsibility principle. The function should only have one responsibility. Currently, it has two: it extracts the status code from options and it returns a CSS value based on that code. By splitting out obtaining the status code into another function, this one becomes more focused.
_scicomp.16147
The PETSC function VecSwap after a few layers of abstraction calls the BLAS primitive swap, which essentially copies data around (unless I am missing something).It seems to me that there should be a O(1) implementation that can be obtained just by exchanging pointers, at least if the vectors are identical in all their characteristics (underlying storage and distribution between the nodes).So, is there a way to swap vectors without a deep copy in PETSC?
Efficiently swap vectors in PETSC
parallel computing;petsc
null
_unix.47697
Current scripts create and delete multiple files over NFS. I have been told that this is the problem, so was thinking if the run directory the script ran in looked like a single file to NFS then I might alleviate the problem.I should add that we have hundreds of these scripts working in their own run directories but all over NFS at any one time, and we have a bottleneck due to the creation and deletion of many tens of files for each run directory.I have since found http://code.google.com/p/fuse-zip/ that I will investigate. Could someone share their experiences with this?
Is there a way to create a directory structure and files inside a file on a 'base' filesystem'?
filesystems
Ok, from the comments, it seems like it'll fall into one of these suggestions:You're making and deleting a bunch of temporary files, taking relatively little disk space. Suggestion: Mount a tmpfs somewhere on the local machine, and use that. (You may already have one under /tmp anyway)Most of them are temporary files, but a few need to be keptSuggestion: tmpfs again, but before unmounting the tmpfs at the end (thus losing its contents), copy the few files you need off it.They're temporary, but they're not small.Suggestion: Local storage.You need to access these many small files from multiple machines, concurrently.Suggestion: Beefier NFS server and/or network. Dedicated NFS server for just this load. Distributed filesystems. I'm having a hard time coming up with a scenario where the approach in your question is the best idea. But if you do want to do it...Suggestion: Make a single file on the NFS server. Use losetup to map it to a loop device, then mkfs that, and mount it. (Depending on which filesystem you're using, you make be able to mkfs the file directly, that'll work with mke2fs for example). Probably, mount it with the async flag (or similar). This will perform much better than a zip file.Another thing I'll note, depending on what you're making and deleting all these temporary files for, files may not be the best approach. E.g., maybe they should be rows in a database of some sort.
_unix.371204
I'm setting up a vision system using Ubuntu 16.04 with a number of GIGE vision cameras and two local networks. I have 6 GIGE ports on my computer to try and sort out and I'm not having much luck. I'm hoping that this is something fairly obvious that I'm missing.To list them out:enp0s31f6: Connects to the university network using dhcpenp1s0: Connects to local instrument LAN (static IP, 192.168.175.x subnet)enp2s0: Connects to GIGE camera (192.168.0.3)enp3s0: Connects to GIGE camera (192.168.0.4)enp4s0: Connects to GIGE camera (192.168.0.5)enp5s0: Connects to GIGE camera (192.168.0.6)My interfaces file so far is: # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback# Primary interfaceauto enp0s31f6iface enp0s31f6 inet dhcp# Secondary interface for vehicle commsauto enp1s0iface enp1s0 inet static address 192.168.175.13 netmask 255.255.255.0 gateway 192.168.175.1 up route add -net 192.168.175.0 netmask 255.255.255.0 gw 192.168.175.1 up route del default gw 192.168.175.1 post-up route del -net 192.168.175.0 netmask 255.255.255.0 gw 0.0.0.0#GIGE Port 1auto enp2s0iface enp2s0 inet static address 192.168.0.2 netmask 255.255.255.0 gateway 192.168.0.1 #post-up route del -net 192.168.0.0 netmask 255.255.255.0 gw 0.0.0.0 #up route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1 mtu 9000The problem I'm having is that the routes are terribly messed up. Right now they are:Kernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 enp2s010.64.226.0 0.0.0.0 255.255.254.0 U 0 0 0 enp0s31f6169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enp2s0192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0192.168.175.0 0.0.0.0 255.255.255.0 U 0 0 0 enp1s0Which isn't super helpful, since it now routes all traffic through enp2s0, which is only connected to a camera. I'm also not sure how to route only a single IP address through an interface.Thoughts?
Networking with many Ethnernet ports
networking
null
_softwareengineering.164542
After 1 months research I basically give up on getting all URL's from a search results programmatically,I looked at Google Search API to find a way to get millions of search results URL's to be specific to a text file or something relative but no success, but I am 100% there must be a way or trick of doing it.Real Question :Is there anyway programmatically or manually I can get 1000+ search results (URLs using search query e.g. Apple returns million of results on google and I want as much as possible URLs of them results in a text file)Note :Don't care for any specific search engine or programming language or technique or software or just point me to right direction, but yeah I tried it with google API i can't get more then 100 results at all.
Getting URLs from search results
c#;computer science;web;internationalization
null
_webmaster.79893
I just got a thin content penalty from Google. I was not sure what that meant, so after research I contacted a SEO expert who told me I was scraping websites and I needed to stop. The problem is, I am not scraping websites, I have 17 websites that are scraping me. I also have a google blogger that has decided to run a blog with my website name with all of my articles for the past seven months. I am not sure what to do, or if this is in fact what I got a penalty for. Does Google make mistakes like this? Any advice would be appreciated. Thanks.
Thin Content Penalty
google
null
_unix.264384
I have a Centos 7 machine.I decided to install apache, mysql, and php from source.I already installed (from source) the apache & mysql packages (requirements: with apr (source), apr-util (source), pcre-devel (yum installed), perl (yum installed)).Now, I am trying to install php and the configuration file stops at extensions section of install and says:configure: error: DBA: Could not find necessary header file(s)1) what should I do to repair it?I saw on the internet that I can fix it with db4-devel, the problem is that there's no db4-devel in CentOS 7.2) Is there any replacement package for this?3) how can I make php(7.0.3) install all extensions in ./configure?
php ./configure error: DBA: Could not find necessary header file(s)
centos;software installation;php
null
_softwareengineering.95395
I've been an ASP.net web developer for about 2.5 years now.I would describe my technical training before that as being classical C++.It seemed like it took an eternity to get up to speed with ASP.net. I kept wanting to think of programming in VB.net and C#.net as if it were C++ programming, which of course, it isn't. Even my supervisor admitted that at the beginning he had doubts about keeping me on board, but I made it. I've now been working on a project of my own for about a year.Here are some concepts and technologies I've picked up some skill with along the way.class inheritanceseparation of concernsLINQSQLSession StateJavaScriptjQueryAJAXCSSThe first two that I mentioned are essential for keeping the code organized. LINQ is very nice to have to avoid having to write for loops over and over. JavaScript seems to have become the backbone of web programming in spite of its shortcomings and jQuery seems to couple it very tightly with CSS.I've been making a big effort to learn to write better JavaScript; mainly by reading on Douglas Crockford's web site.I would like to know, from more experienced web developers, besides what I mentioned here, what are the most important tools to have in your toolbox to write great web applications?
What skills to master to become a better ASP.net developer?
web development;asp.net;skills
null
_codereview.92635
I have a windows form application which uses a form for two different purposes. We use the form for both our handheld system and our in-house system.I would just like someone to review the code for saving and see if I have done it the best way or if not, what the best solution is.Windows Form Save Methodprivate void SavePDVDetails() { LockType = 0; AccessInfo = 0; V2a = 0; V10a = 0; PayMethod = 0; SaveCheckBoxes(ref LockType, ref AccessInfo, ref V2a, ref V10a, ref PayMethod); var pdv = isHandheld == true ? new PDVHH() : new PDV(); if (!isHandheld) pdv.Timestamp = timestamp; pdv.CaseID = caseID; pdv.CustContactTel = txtCustContactTel.Text; pdv.CustMobileTel = txtCustMobileTel.Text; pdv.PropertyType = Systems.CheckComboNullString(cboPropertyType); pdv.PremisesStatus = Systems.CheckComboNullString(cboPremisesStatus); pdv.LockType = LockType; pdv.AccessInfo = AccessInfo; pdv.V1 = Systems.CheckComboNullString(cboV1); pdv.V2 = Systems.CheckComboNullString(cboV2); pdv.V2a = V2a; pdv.V3 = Systems.CheckComboNullString(cboV3); pdv.V4 = Systems.CheckComboNullString(cboV4); pdv.V4a = txtV4a.Text; pdv.V5 = Systems.CheckComboNullString(cboV5); pdv.V6 = Systems.CheckComboNullString(cboV6); pdv.V7 = Systems.CheckComboNullString(cboV7); pdv.V7a = txtV7a.Text; pdv.V8 = Systems.CheckComboNullString(cboV8); pdv.V8a = txtV8a.Text; pdv.V9 = Systems.CheckComboNullString(cboV9); pdv.V9a = txtV9a.Text; pdv.V10 = Systems.CheckComboNullString(cboV10); pdv.V10a = V10a; pdv.V11 = Systems.CheckComboNullString(cboV11); pdv.V11a = txtV11a.Text; pdv.V12 = Systems.CheckComboNullString(cboV12); pdv.VulnerableOther = txtVulnerableOther.Text; pdv.ContactType = Systems.CheckComboNullString(cboContactType); pdv.NINumber = txtNINumber.Text; pdv.ContactDate = mtxtContactDate.Text; pdv.CustDOB = mtxtCustDOB.Text; pdv.PayAmount = txtPayAmount.Text == string.Empty ? Convert.ToDouble(null) : Convert.ToDouble(txtPayAmount.Text); pdv.ClearedFunds = chkClearedFunds.Checked; pdv.PayAmount2 = txtPayAmount2.Text == string.Empty ? Convert.ToDouble(null) : Convert.ToDouble(txtPayAmount2.Text); pdv.ClearedFunds2 = chkClearedFunds.Checked; pdv.PayMethod = PayMethod; pdv.ReceiptNo = txtReceiptNo.Text; pdv.DirectPayAmount = txtDirectPayAmount.Text == string.Empty ? Convert.ToDouble(null) : Convert.ToDouble(txtDirectPayAmount.Text); pdv.COT = chkCOT.Checked; pdv.TitleCode = Systems.CheckComboNullString(cboTitle); pdv.OtherTitle = txtOtherTitle.Text; pdv.FirstName = txtFirstName.Text; pdv.MiddleInitials = txtMiddleInitials.Text; pdv.SurName = txtSurName.Text; pdv.COTProofType = Systems.CheckComboNullString(cboCOTProofType); pdv.COTDate = mtxtCOTDate.Text; pdv.PropRespMtrRead = txtPropRestMtrRead.Text; pdv.PropRespMtrBRead = txtPropRestMtrBRead.Text; pdv.PrevAdd1 = txtPrevAdd1.Text; pdv.PrevAdd2 = txtPrevAdd2.Text; pdv.PrevAdd3 = txtPrevAdd3.Text; pdv.PrevAdd4 = txtPrevAdd4.Text; pdv.PrevPostcode = txtPrevAddPostcode.Text; pdv.FwdName = txtFwdName.Text; pdv.FwdAdd1 = txtFwdAdd1.Text; pdv.FwdAdd2 = txtFwdAdd2.Text; pdv.FwdAdd3 = txtFwdAdd3.Text; pdv.FwdAdd4 = txtFwdAdd4.Text; pdv.FwdPostcode = txtFwdAddPostcode.Text; pdv.PayArranged = chkPayArranged.Checked; pdv.PayStartDate = mtxtPayStartDate.Text; pdv.PayArrAmount = txtPayArrAmount.Text == string.Empty ? Convert.ToDouble(null) : Convert.ToDouble(txtPayArrAmount.Text); pdv.Frequency = Systems.CheckComboNullString(cboFrequency); pdv.PayArrDetail = Systems.CheckComboNullString(cboPayArrDetail); pdv.PPMAgreed = chkPPMAgreed.Checked; pdv.PPMBookedDate = mtxtPPMApptDate.Text; pdv.PPMHHBookedTime = Systems.CheckComboNullString(cboPPMApptTime); pdv.EmploymentStatus = Systems.CheckComboNullString(cboEmploymentStatus); pdv.RecoveryRate = txtRecoveryRate.Text == string.Empty ? Convert.ToDouble(null) : Convert.ToDouble(txtRecoveryRate.Text); pdv.PPMApptComments = txtPPMApptComments.Text; pdv.PPMArranged = chkPPMArranged.Checked; pdv.PPMAppointmentDate = mtxtPPMAppointmentDate.Text; pdv.PPMDetail = Systems.CheckComboNullString(cboPPMDetail); pdv.AuthCode = txtAuthCode.Text; pdv.DateOfLeaving = mtxtDateOfLeaving.Text; pdv.VacantPropComments = txtVacPropComments.Text; pdv.CustComplaintCode = Systems.CheckComboNullString(cboCustComplaintCode); pdv.DisputeComments = txtDisputeComments.Text; pdv.IncidentDets = txtIncidentDets.Text; pdv.PDVComments = txtPDVComments.Text; pdv.Dissatisfaction = chkDissatisfied.Checked; pdv.DissatisfactionComments = txtDissatisfiedComments.Text; pdv.HealthSafety = chkHealthSafety.Checked; pdv.ContactCode = Systems.CheckComboNullString(cboContact_Code); pdv.WhoSpokenTo = Systems.CheckComboNullString(cboWhoSpokenTo); pdv.HealthSafetyComments = txtHealthSafetyComments.Text; pdv.InfoNotes = txtInfoNotes.Text; pdv.EnergyTrust = chkEnergyTrust.Checked; pdv.EnergyTrustComments = txtEnergyTrustComments.Text; pdv.VisitDate1 = mtxtVisitDate1.Text; pdv.VisitTime = mtxtVisitTime.Text; pdv.VisitDate2 = mtxtVisitDate2.Text; pdv.VisitTime2 = mtxtVisitTime2.Text; if (isHandheld) { (pdv as PDVHH).PDVResult = Systems.CheckComboNullString(cboGasPDVResult); (pdv as PDVHH).SecPDVResult = Systems.CheckComboNullString(cboElectricPDVResult); pdvDetails.SavePDVHH((PDVHH)pdv); } else pdvDetails.SavePDV(pdv); UpdateMeterPDV(); AccountDetails.SaveMeterPDV(meterPDV, isHandheld); }Model public class PDV{ public int CaseID { get; set; } public object Timestamp { get; set; } public string CustContactTel { get; set; } public string CustMobileTel { get; set; } public string PropertyType { get; set; } public string PremisesStatus { get; set; } public int LockType { get; set; } public int AccessInfo { get; set; } public string V1 { get; set; } public string V2 { get; set; } public int V2a { get; set; } public string V3 { get; set; } public string V4 { get; set; } public string V4a { get; set; } public string V5 { get; set; } public string V6 { get; set; } public string V7 { get; set; } public string V7a { get; set; } public string V8 { get; set; } public string V8a { get; set; } public string V9 { get; set; } public string V9a { get; set; } public string V10 { get; set; } public int V10a { get; set; } public string V11 { get; set; } public string V11a { get; set; } public string V12 { get; set; } public string VulnerableOther { get; set; } public string ContactType { get; set; } public string NINumber { get; set; } public string ContactDate { get; set; } public string CustDOB { get; set; } public double? PayAmount { get; set; } public bool ClearedFunds { get; set; } public double? PayAmount2 { get; set; } public bool ClearedFunds2 { get; set; } public int PayMethod { get; set; } public string ReceiptNo { get; set; } public double? DirectPayAmount { get; set; } public bool COT { get; set; } public string TitleCode { get; set; } public string OtherTitle { get; set; } public string FirstName { get; set; } public string MiddleInitials { get; set; } public string SurName { get; set; } public string COTProofType { get; set; } public string COTDate { get; set; } public string PropRespMtrRead { get; set; } public string PropRespMtrBRead { get; set; } public string PrevAdd1 { get; set; } public string PrevAdd2 { get; set; } public string PrevAdd3 { get; set; } public string PrevAdd4 { get; set; } public string PrevPostcode { get; set; } public string FwdName { get; set; } public string FwdAdd1 { get; set; } public string FwdAdd2 { get; set; } public string FwdAdd3 { get; set; } public string FwdAdd4 { get; set; } public string FwdPostcode { get; set; } public bool PayArranged { get; set; } public string PayStartDate { get; set; } public double? PayArrAmount { get; set; } public string Frequency { get; set; } public string PayArrDetail { get; set; } public bool PPMAgreed { get; set; } public string PPMBookedDate { get; set; } public string PPMHHBookedTime { get; set; } public string EmploymentStatus { get; set; } public double? RecoveryRate { get; set; } public string PPMApptComments { get; set; } public bool PPMArranged { get; set; } public string PPMAppointmentDate { get; set; } public string PPMDetail { get; set; } public string AuthCode { get; set; } public string DateOfLeaving { get; set; } public string VacantPropComments { get; set; } public string CustComplaintCode { get; set; } public string DisputeComments { get; set; } public string IncidentDets { get; set; } public string PDVComments { get; set; } public bool Dissatisfaction { get; set; } public string DissatisfactionComments { get; set; } public bool HealthSafety { get; set; } public string ContactCode { get; set; } public string WhoSpokenTo { get; set; } public string HealthSafetyComments { get; set; } public string InfoNotes { get; set; } public bool EnergyTrust { get; set; } public string EnergyTrustComments { get; set; } public string VisitDate1 { get; set; } public string VisitTime { get; set; } public string VisitDate2 { get; set; } public string VisitTime2 { get; set; } public string ClientComments { get; set; } public string PDVNote { get; set; }}public class PDVHH : PDV{ public string PDVResult { get; set; } public string SecPDVResult { get; set; } public string D2PrintDate { get; set; } public string RPDVResult { get; set; } public string RSecPDVResult { get; set; }}Save Functionspublic void SavePDV(PDV pdv) { var parameters = new List<SqlParameter>(); parameters.Add(new SqlParameter(@CaseID, pdv.CaseID)); parameters.Add(new SqlParameter(@PDVTimestamp, pdv.Timestamp)); parameters.Add(new SqlParameter(@CustContactTel, pdv.CustContactTel)); parameters.Add(new SqlParameter(@CustMobileTel,pdv.CustMobileTel)); parameters.Add(new SqlParameter(@PropertyType, pdv.PropertyType)); parameters.Add(new SqlParameter(@PremisesStatus, pdv.PremisesStatus)); parameters.Add(new SqlParameter(@LockType, pdv.LockType)); parameters.Add(new SqlParameter(@AccessInfo, pdv.AccessInfo)); parameters.Add(new SqlParameter(@V1, pdv.V1)); parameters.Add(new SqlParameter(@V2, pdv.V2)); parameters.Add(new SqlParameter(@V2a, pdv.V2a)); parameters.Add(new SqlParameter(@V3, pdv.V3)); parameters.Add(new SqlParameter(@V4, pdv.V4)); parameters.Add(new SqlParameter(@V4a, pdv.V4a)); parameters.Add(new SqlParameter(@V5, pdv.V5)); parameters.Add(new SqlParameter(@V6, pdv.V6)); parameters.Add(new SqlParameter(@V7, pdv.V7)); parameters.Add(new SqlParameter(V7a, pdv.V7a)); parameters.Add(new SqlParameter(@V8, pdv.V8)); parameters.Add(new SqlParameter(@V8a, pdv.V8a)); parameters.Add(new SqlParameter(@V9, pdv.V9)); parameters.Add(new SqlParameter(@V9a, pdv.V9a)); parameters.Add(new SqlParameter(@V10, pdv.V10)); parameters.Add(new SqlParameter(@V10a, pdv.V10a)); parameters.Add(new SqlParameter(@V11, pdv.V11)); parameters.Add(new SqlParameter(@V11a, pdv.V11a)); parameters.Add(new SqlParameter(@V12, pdv.V12)); parameters.Add(new SqlParameter(@VulnerableOther, pdv.VulnerableOther)); parameters.Add(new SqlParameter(@ContactType, pdv.ContactType)); parameters.Add(new SqlParameter(@NINumber, pdv.NINumber)); parameters.Add(new SqlParameter(@CustDOB, pdv.ContactDate)); parameters.Add(new SqlParameter(@ContactDate, pdv.CustDOB)); parameters.Add(new SqlParameter(@PayAmount, pdv.PayAmount)); parameters.Add(new SqlParameter(@ClearedFunds, pdv.ClearedFunds)); parameters.Add(new SqlParameter(@PayAmount2, pdv.PayAmount2)); parameters.Add(new SqlParameter(@ClearedFunds2, pdv.ClearedFunds2)); parameters.Add(new SqlParameter(@PayMethod, pdv.PayMethod)); parameters.Add(new SqlParameter(@ReceiptNo, pdv.ReceiptNo)); parameters.Add(new SqlParameter(@DirectPayAmount, pdv.DirectPayAmount)); parameters.Add(new SqlParameter(@COT, pdv.COT)); parameters.Add(new SqlParameter(@TitleCode, pdv.TitleCode)); parameters.Add(new SqlParameter(@OtherTitle, pdv.OtherTitle)); parameters.Add(new SqlParameter(@FirstName, pdv.FirstName)); parameters.Add(new SqlParameter(@MiddleInitials, pdv.MiddleInitials)); parameters.Add(new SqlParameter(@SurName, pdv.SurName)); parameters.Add(new SqlParameter(@COTProofType, pdv.COTProofType)); parameters.Add(new SqlParameter(@COTDate, pdv.COTDate)); parameters.Add(new SqlParameter(@PropRespMtrRead, pdv.PropRespMtrRead)); parameters.Add(new SqlParameter(@PropRespMtrBRead, pdv.PropRespMtrBRead)); parameters.Add(new SqlParameter(@PrevAdd1, pdv.PrevAdd1)); parameters.Add(new SqlParameter(@PrevAdd2, pdv.PrevAdd2)); parameters.Add(new SqlParameter(@PrevAdd3, pdv.PrevAdd3)); parameters.Add(new SqlParameter(@PrevAdd4, pdv.PrevAdd4)); parameters.Add(new SqlParameter(@PrevPostcode, pdv.PrevPostcode)); parameters.Add(new SqlParameter(@FwdName, pdv.FwdName)); parameters.Add(new SqlParameter(@FwdAdd1, pdv.FwdAdd1)); parameters.Add(new SqlParameter(@FwdAdd2, pdv.FwdAdd2)); parameters.Add(new SqlParameter(@FwdAdd3, pdv.FwdAdd3)); parameters.Add(new SqlParameter(@FwdAdd4, pdv.FwdAdd4)); parameters.Add(new SqlParameter(@FwdPostcode, pdv.FwdPostcode)); parameters.Add(new SqlParameter(@PayArranged, pdv.PayArranged)); parameters.Add(new SqlParameter(@PayStartDate, pdv.PayStartDate)); parameters.Add(new SqlParameter(@PayArrAmount, pdv.PayArrAmount)); parameters.Add(new SqlParameter(@Frequency, pdv.Frequency)); parameters.Add(new SqlParameter(@PayArrDetail, pdv.PayArrDetail)); parameters.Add(new SqlParameter(@PPMAgreed, pdv.PPMAgreed)); parameters.Add(new SqlParameter(@PPMBookedDate, pdv.PPMBookedDate)); parameters.Add(new SqlParameter(@PPMHHBookedTime, pdv.PPMHHBookedTime)); parameters.Add(new SqlParameter(@EmploymentStatus, pdv.EmploymentStatus)); parameters.Add(new SqlParameter(@RecoveryRate, pdv.RecoveryRate)); parameters.Add(new SqlParameter(@PPMApptComments, pdv.PPMApptComments)); parameters.Add(new SqlParameter(@PPMArranged, pdv.PPMArranged)); parameters.Add(new SqlParameter(@PPMAppointmentDate, pdv.PPMAppointmentDate)); parameters.Add(new SqlParameter(@PPMDetail, pdv.PPMDetail)); parameters.Add(new SqlParameter(@AuthCode, pdv.AuthCode)); parameters.Add(new SqlParameter(@DateOfLeaving, pdv.DateOfLeaving)); parameters.Add(new SqlParameter(@VacantPropComments, pdv.VacantPropComments)); parameters.Add(new SqlParameter(@CustComplaintCode, pdv.CustComplaintCode)); parameters.Add(new SqlParameter(@DisputeComments, pdv.DisputeComments)); parameters.Add(new SqlParameter(@IncidentDets, pdv.IncidentDets)); parameters.Add(new SqlParameter(@PDVComments, pdv.PDVComments)); parameters.Add(new SqlParameter(@Dissatisfaction, pdv.Dissatisfaction)); parameters.Add(new SqlParameter(@DissatisfactionComments, pdv.DissatisfactionComments)); parameters.Add(new SqlParameter(@HealthSafety, pdv.HealthSafety)); parameters.Add(new SqlParameter(@Contact_Code, pdv.ContactCode)); parameters.Add(new SqlParameter(@WhoSpokenTo, pdv.WhoSpokenTo)); parameters.Add(new SqlParameter(@HealthSafetyComments, pdv.HealthSafetyComments)); parameters.Add(new SqlParameter(@InfoNotes, pdv.InfoNotes)); parameters.Add(new SqlParameter(@EnergyTrust, pdv.EnergyTrust)); parameters.Add(new SqlParameter(@EnergyTrustComments, pdv.EnergyTrustComments)); parameters.Add(new SqlParameter(@VisitDate1, pdv.VisitDate1)); parameters.Add(new SqlParameter(@VisitTime, pdv.VisitTime)); parameters.Add(new SqlParameter(@VisitDate2, pdv.VisitDate2)); parameters.Add(new SqlParameter(@VisitTime2, pdv.VisitTime2)); SQLHelper.ExecuteNonQuery(prcUMUpdateDebtPDVDetails, CommandType.StoredProcedure, parameters); parameters = null; } public void SavePDVHH(PDVHH pdv) { var parameters = new List<SqlParameter>(); parameters.Add(new SqlParameter(@CaseID, pdv.CaseID)); parameters.Add(new SqlParameter(@CustContactTel, pdv.CustContactTel)); parameters.Add(new SqlParameter(@CustMobileTel, pdv.CustMobileTel)); parameters.Add(new SqlParameter(@PropertyType, pdv.PropertyType)); parameters.Add(new SqlParameter(@PremisesStatus, pdv.PremisesStatus)); parameters.Add(new SqlParameter(@LockType, pdv.LockType)); parameters.Add(new SqlParameter(@AccessInfo, pdv.AccessInfo)); parameters.Add(new SqlParameter(@V1, pdv.V1)); parameters.Add(new SqlParameter(@V2, pdv.V2)); parameters.Add(new SqlParameter(@V2a, pdv.V2a)); parameters.Add(new SqlParameter(@V3, pdv.V3)); parameters.Add(new SqlParameter(@V4, pdv.V4)); parameters.Add(new SqlParameter(@V4a, pdv.V4a)); parameters.Add(new SqlParameter(@V5, pdv.V5)); parameters.Add(new SqlParameter(@V6, pdv.V6)); parameters.Add(new SqlParameter(@V7, pdv.V7)); parameters.Add(new SqlParameter(V7a, pdv.V7a)); parameters.Add(new SqlParameter(@V8, pdv.V8)); parameters.Add(new SqlParameter(@V8a, pdv.V8a)); parameters.Add(new SqlParameter(@V9, pdv.V9)); parameters.Add(new SqlParameter(@V9a, pdv.V9a)); parameters.Add(new SqlParameter(@V10, pdv.V10)); parameters.Add(new SqlParameter(@V10a, pdv.V10a)); parameters.Add(new SqlParameter(@V11, pdv.V11)); parameters.Add(new SqlParameter(@V11a, pdv.V11a)); parameters.Add(new SqlParameter(@V12, pdv.V12)); parameters.Add(new SqlParameter(@VulnerableOther, pdv.VulnerableOther)); parameters.Add(new SqlParameter(@ContactType, pdv.ContactType)); parameters.Add(new SqlParameter(@NINumber, pdv.NINumber)); parameters.Add(new SqlParameter(@CustDOB, pdv.ContactDate)); parameters.Add(new SqlParameter(@ContactDate, pdv.CustDOB)); parameters.Add(new SqlParameter(@PayAmount, pdv.PayAmount)); parameters.Add(new SqlParameter(@PayAmount2, pdv.PayAmount2)); parameters.Add(new SqlParameter(@PayMethod, pdv.PayMethod)); parameters.Add(new SqlParameter(@ReceiptNo, pdv.ReceiptNo)); parameters.Add(new SqlParameter(@DirectPayAmount, pdv.DirectPayAmount)); parameters.Add(new SqlParameter(@COT, pdv.COT)); parameters.Add(new SqlParameter(@TitleCode, pdv.TitleCode)); parameters.Add(new SqlParameter(@OtherTitle, pdv.OtherTitle)); parameters.Add(new SqlParameter(@FirstName, pdv.FirstName)); parameters.Add(new SqlParameter(@MiddleInitials, pdv.MiddleInitials)); parameters.Add(new SqlParameter(@SurName, pdv.SurName)); parameters.Add(new SqlParameter(@COTProofType, pdv.COTProofType)); parameters.Add(new SqlParameter(@COTDate, pdv.COTDate)); parameters.Add(new SqlParameter(@PropRespMtrRead, pdv.PropRespMtrRead)); parameters.Add(new SqlParameter(@PropRespMtrBRead, pdv.PropRespMtrBRead)); parameters.Add(new SqlParameter(@PrevAdd1, pdv.PrevAdd1)); parameters.Add(new SqlParameter(@PrevAdd2, pdv.PrevAdd2)); parameters.Add(new SqlParameter(@PrevAdd3, pdv.PrevAdd3)); parameters.Add(new SqlParameter(@PrevAdd4, pdv.PrevAdd4)); parameters.Add(new SqlParameter(@PrevPostcode, pdv.PrevPostcode)); parameters.Add(new SqlParameter(@FwdName, pdv.FwdName)); parameters.Add(new SqlParameter(@FwdAdd1, pdv.FwdAdd1)); parameters.Add(new SqlParameter(@FwdAdd2, pdv.FwdAdd2)); parameters.Add(new SqlParameter(@FwdAdd3, pdv.FwdAdd3)); parameters.Add(new SqlParameter(@FwdAdd4, pdv.FwdAdd4)); parameters.Add(new SqlParameter(@FwdPostcode, pdv.FwdPostcode)); parameters.Add(new SqlParameter(@PayArranged, pdv.PayArranged)); parameters.Add(new SqlParameter(@PayStartDate, pdv.PayStartDate)); parameters.Add(new SqlParameter(@PayArrAmount, pdv.PayArrAmount)); parameters.Add(new SqlParameter(@Frequency, pdv.Frequency)); parameters.Add(new SqlParameter(@PayArrDetail, pdv.PayArrDetail)); parameters.Add(new SqlParameter(@PPMAgreed, pdv.PPMAgreed)); parameters.Add(new SqlParameter(@PPMBookedDate, pdv.PPMBookedDate)); parameters.Add(new SqlParameter(@PPMHHBookedTime, pdv.PPMHHBookedTime)); parameters.Add(new SqlParameter(@EmploymentStatus, pdv.EmploymentStatus)); parameters.Add(new SqlParameter(@RecoveryRate, pdv.RecoveryRate)); parameters.Add(new SqlParameter(@PPMApptComments, pdv.PPMApptComments)); parameters.Add(new SqlParameter(@PPMArranged, pdv.PPMArranged)); parameters.Add(new SqlParameter(@PPMAppointmentDate, pdv.PPMAppointmentDate)); parameters.Add(new SqlParameter(@PPMDetail, pdv.PPMDetail)); parameters.Add(new SqlParameter(@AuthCode, pdv.AuthCode)); parameters.Add(new SqlParameter(@DateOfLeaving, pdv.DateOfLeaving)); parameters.Add(new SqlParameter(@VacantPropComments, pdv.VacantPropComments)); parameters.Add(new SqlParameter(@CustComplaintCode, pdv.CustComplaintCode)); parameters.Add(new SqlParameter(@DisputeComments, pdv.DisputeComments)); parameters.Add(new SqlParameter(@IncidentDets, pdv.IncidentDets)); parameters.Add(new SqlParameter(@PDVComments, pdv.PDVComments)); parameters.Add(new SqlParameter(@Dissatisfaction, pdv.Dissatisfaction)); parameters.Add(new SqlParameter(@DissatisfactionComments, pdv.DissatisfactionComments)); parameters.Add(new SqlParameter(@HealthSafety, pdv.HealthSafety)); parameters.Add(new SqlParameter(@Contact_Code, pdv.ContactCode)); parameters.Add(new SqlParameter(@WhoSpokenTo, pdv.WhoSpokenTo)); parameters.Add(new SqlParameter(@HealthSafetyComments, pdv.HealthSafetyComments)); parameters.Add(new SqlParameter(@InfoNotes, pdv.InfoNotes)); parameters.Add(new SqlParameter(@EnergyTrust, pdv.EnergyTrust)); parameters.Add(new SqlParameter(@EnergyTrustComments, pdv.EnergyTrustComments)); parameters.Add(new SqlParameter(@VisitDate1, pdv.VisitDate1)); parameters.Add(new SqlParameter(@VisitTime, pdv.VisitTime)); parameters.Add(new SqlParameter(@VisitDate2, pdv.VisitDate2)); parameters.Add(new SqlParameter(@VisitTime2, pdv.VisitTime2)); parameters.Add(new SqlParameter(@RPDVResult, pdv.RPDVResult)); parameters.Add(new SqlParameter(@RSecPDVResult, pdv.RSecPDVResult)); SQLHelper.ExecuteNonQuery(prcUMUpdateDebtPDVHHDetails, CommandType.StoredProcedure, parameters); parameters = null; }
Saving a form to a database
c#;sql;form
Ok so you have a lot of duplicated properties here.What you want to do is have each of your objects maintain the list of properties that they will use during a save.Use inheritance to your advantage. I've added a method GetCommandParameters to your base class, this is overridable. Its only concern is to add the parameters that are valid for that object.public class PDV{ public int CaseID { get; set; } public object Timestamp { get; set; } public string CustContactTel { get; set; } public string CustMobileTel { get; set; } public string PropertyType { get; set; } public string PremisesStatus { get; set; } public int LockType { get; set; } public int AccessInfo { get; set; } public string V1 { get; set; } public string V2 { get; set; } public int V2a { get; set; } public string V3 { get; set; } public string V4 { get; set; } public string V4a { get; set; } public string V5 { get; set; } public string V6 { get; set; } public string V7 { get; set; } public string V7a { get; set; } public string V8 { get; set; } public string V8a { get; set; } public string V9 { get; set; } public string V9a { get; set; } public string V10 { get; set; } public int V10a { get; set; } public string V11 { get; set; } public string V11a { get; set; } public string V12 { get; set; } public string VulnerableOther { get; set; } public string ContactType { get; set; } public string NINumber { get; set; } public string ContactDate { get; set; } public string CustDOB { get; set; } public double? PayAmount { get; set; } public bool ClearedFunds { get; set; } public double? PayAmount2 { get; set; } public bool ClearedFunds2 { get; set; } public int PayMethod { get; set; } public string ReceiptNo { get; set; } public double? DirectPayAmount { get; set; } public bool COT { get; set; } public string TitleCode { get; set; } public string OtherTitle { get; set; } public string FirstName { get; set; } public string MiddleInitials { get; set; } public string SurName { get; set; } public string COTProofType { get; set; } public string COTDate { get; set; } public string PropRespMtrRead { get; set; } public string PropRespMtrBRead { get; set; } public string PrevAdd1 { get; set; } public string PrevAdd2 { get; set; } public string PrevAdd3 { get; set; } public string PrevAdd4 { get; set; } public string PrevPostcode { get; set; } public string FwdName { get; set; } public string FwdAdd1 { get; set; } public string FwdAdd2 { get; set; } public string FwdAdd3 { get; set; } public string FwdAdd4 { get; set; } public string FwdPostcode { get; set; } public bool PayArranged { get; set; } public string PayStartDate { get; set; } public double? PayArrAmount { get; set; } public string Frequency { get; set; } public string PayArrDetail { get; set; } public bool PPMAgreed { get; set; } public string PPMBookedDate { get; set; } public string PPMHHBookedTime { get; set; } public string EmploymentStatus { get; set; } public double? RecoveryRate { get; set; } public string PPMApptComments { get; set; } public bool PPMArranged { get; set; } public string PPMAppointmentDate { get; set; } public string PPMDetail { get; set; } public string AuthCode { get; set; } public string DateOfLeaving { get; set; } public string VacantPropComments { get; set; } public string CustComplaintCode { get; set; } public string DisputeComments { get; set; } public string IncidentDets { get; set; } public string PDVComments { get; set; } public bool Dissatisfaction { get; set; } public string DissatisfactionComments { get; set; } public bool HealthSafety { get; set; } public string ContactCode { get; set; } public string WhoSpokenTo { get; set; } public string HealthSafetyComments { get; set; } public string InfoNotes { get; set; } public bool EnergyTrust { get; set; } public string EnergyTrustComments { get; set; } public string VisitDate1 { get; set; } public string VisitTime { get; set; } public string VisitDate2 { get; set; } public string VisitTime2 { get; set; } public string ClientComments { get; set; } public string PDVNote { get; set; } public virtual List<SqlParameter> GetCommandParameters() { return new List<SqlParameter> { new SqlParameter(@CaseID, CaseID), new SqlParameter(@PDVTimestamp, Timestamp), new SqlParameter(@CustContactTel, CustContactTel), new SqlParameter(@CustMobileTel, CustMobileTel), new SqlParameter(@PropertyType, PropertyType), new SqlParameter(@PremisesStatus, PremisesStatus), new SqlParameter(@LockType, LockType), new SqlParameter(@AccessInfo, AccessInfo), new SqlParameter(@V1, V1), new SqlParameter(@V2, V2), new SqlParameter(@V2a, V2a), new SqlParameter(@V3, V3), new SqlParameter(@V4, V4), new SqlParameter(@V4a, V4a), new SqlParameter(@V5, V5), new SqlParameter(@V6, V6), new SqlParameter(@V7, V7), new SqlParameter(V7a, V7a), new SqlParameter(@V8, V8), new SqlParameter(@V8a, V8a), new SqlParameter(@V9, V9), new SqlParameter(@V9a, V9a), new SqlParameter(@V10, V10), new SqlParameter(@V10a, V10a), new SqlParameter(@V11, V11), new SqlParameter(@V11a, V11a), new SqlParameter(@V12, V12), new SqlParameter(@VulnerableOther, VulnerableOther), new SqlParameter(@ContactType, ContactType), new SqlParameter(@NINumber, NINumber), new SqlParameter(@CustDOB, ContactDate), new SqlParameter(@ContactDate, CustDOB), new SqlParameter(@PayAmount, PayAmount), new SqlParameter(@ClearedFunds, ClearedFunds), new SqlParameter(@PayAmount2, PayAmount2), new SqlParameter(@ClearedFunds2, ClearedFunds2), new SqlParameter(@PayMethod, PayMethod), new SqlParameter(@ReceiptNo, ReceiptNo), new SqlParameter(@DirectPayAmount, DirectPayAmount), new SqlParameter(@COT, COT), new SqlParameter(@TitleCode, TitleCode), new SqlParameter(@OtherTitle, OtherTitle), new SqlParameter(@FirstName, FirstName), new SqlParameter(@MiddleInitials, MiddleInitials), new SqlParameter(@SurName, SurName), new SqlParameter(@COTProofType, COTProofType), new SqlParameter(@COTDate, COTDate), new SqlParameter(@PropRespMtrRead, PropRespMtrRead), new SqlParameter(@PropRespMtrBRead, PropRespMtrBRead), new SqlParameter(@PrevAdd1, PrevAdd1), new SqlParameter(@PrevAdd2, PrevAdd2), new SqlParameter(@PrevAdd3, PrevAdd3), new SqlParameter(@PrevAdd4, PrevAdd4), new SqlParameter(@PrevPostcode, PrevPostcode), new SqlParameter(@FwdName, FwdName), new SqlParameter(@FwdAdd1, FwdAdd1), new SqlParameter(@FwdAdd2, FwdAdd2), new SqlParameter(@FwdAdd3, FwdAdd3), new SqlParameter(@FwdAdd4, FwdAdd4), new SqlParameter(@FwdPostcode, FwdPostcode), new SqlParameter(@PayArranged, PayArranged), new SqlParameter(@PayStartDate, PayStartDate), new SqlParameter(@PayArrAmount, PayArrAmount), new SqlParameter(@Frequency, Frequency), new SqlParameter(@PayArrDetail, PayArrDetail), new SqlParameter(@PPMAgreed, PPMAgreed), new SqlParameter(@PPMBookedDate, PPMBookedDate), new SqlParameter(@PPMHHBookedTime, PPMHHBookedTime), new SqlParameter(@EmploymentStatus, EmploymentStatus), new SqlParameter(@RecoveryRate, RecoveryRate), new SqlParameter(@PPMApptComments, PPMApptComments), new SqlParameter(@PPMArranged, PPMArranged), new SqlParameter(@PPMAppointmentDate, PPMAppointmentDate), new SqlParameter(@PPMDetail, PPMDetail), new SqlParameter(@AuthCode, AuthCode), new SqlParameter(@DateOfLeaving, DateOfLeaving), new SqlParameter(@VacantPropComments, VacantPropComments), new SqlParameter(@CustComplaintCode, CustComplaintCode), new SqlParameter(@DisputeComments, DisputeComments), new SqlParameter(@IncidentDets, IncidentDets), new SqlParameter(@PDVComments, PDVComments), new SqlParameter(@Dissatisfaction, Dissatisfaction), new SqlParameter(@DissatisfactionComments, DissatisfactionComments), new SqlParameter(@HealthSafety, HealthSafety), new SqlParameter(@Contact_Code, ContactCode), new SqlParameter(@WhoSpokenTo, WhoSpokenTo), new SqlParameter(@HealthSafetyComments, HealthSafetyComments), new SqlParameter(@InfoNotes, InfoNotes), new SqlParameter(@EnergyTrust, EnergyTrust), new SqlParameter(@EnergyTrustComments, EnergyTrustComments), new SqlParameter(@VisitDate1, VisitDate1), new SqlParameter(@VisitTime, VisitTime), new SqlParameter(@VisitDate2, VisitDate2), new SqlParameter(@VisitTime2, VisitTime2) }; }}Because PDVHH inherits PDV, we want all of the parameters that apply to that class aswell as the new properties the we have. This way we only maintain a list in appropriate places.public class PDVHH : PDV{ public string PDVResult { get; set; } public string SecPDVResult { get; set; } public string D2PrintDate { get; set; } public string RPDVResult { get; set; } public string RSecPDVResult { get; set; } public override List<SqlParameter> GetCommandParameters() { var rtnList = base.GetCommandParameters(); rtnList.Add(new SqlParameter(@PDVResult, PDVResult)); rtnList.Add(new SqlParameter(@SecPDVResult, SecPDVResult)); rtnList.Add(new SqlParameter(@D2PrintDate, D2PrintDate)); rtnList.Add(new SqlParameter(@RPDVResult, RPDVResult)); rtnList.Add(new SqlParameter(@RSecPDVResult, RSecPDVResult)); return rtnList; }}This makes your save code much more succinct.public void SavePDV(PDV pdv){ SQLHelper.ExecuteNonQuery(prcUMUpdateDebtPDVDetails, CommandType.StoredProcedure, pdv.GetCommandParameters());}public void SavePDVHH(PDVHH pdv){ SQLHelper.ExecuteNonQuery(prcUMUpdateDebtPDVHHDetails, CommandType.StoredProcedure, pdv.GetCommandParameters());}
_cs.33452
$$ x_1 + x_2 + \cdots +x_n = c_1 $$$$ \frac{x_1^2}{2} + \frac{x_2^2}{2} + \cdots +\frac{x_n^2}{2} = c_2 $$$$ \cdots $$$$ \frac{x_1^n}{n!} + \frac{x_2^n}{n!} + \cdots +\frac{x_n^n}{n!} = c_n $$$c_1,\cdots,c_n$ are known constants. $x_1 \cdots x_n$ are the unknown variables to solve.
Is there any algorithm can solve the following equations efficiently?
algorithms
One way, which is numerically probably a bad idea, is to use Newton's identities. They give the value of the elementary symmetric functions given the power sums, and from the elementary symmetric functions you can construct a polynomial whose roots are the answers to your problem. Let $p_k = k! c_k$, and let $e_k$ be the sum of all $\binom{n}{k}$ products of $k$ variables out of $x_1,\ldots,x_n$. Newton's identities state that$$ ke_k = (-1)^{k-1} p_k + \sum_{i=1}^{k-1} (-1)^{i-1} e_{k-i} p_i. $$Using these identities, you can compute $e_1,\ldots,e_n$. Now consider the polynomial$$ P = x^n + \sum_{i=1}^n (-1)^i e_i x^{n-i}. $$The unique solution to your equations are the $n$ roots of $P$.As an example, let's do the case $n = 2$. We have $e_1 = p_1$ and$$ 2e_2 = -p_2 + e_1 p_1 = p_1^2 - p_2. $$The polynomial $P$ is therefore$$ x^2 - p_1 x + \frac{p_1^2-p_2}{2}. $$For $n=3$ we calculate additionally$$ 3e_3 = p_3 - e_1 p_2 + e_2 p_1 = p_3 - p_1 p_2 + \frac{p_1^2-p_2}{2} p_1 = \frac{2p_3 - 3p_1p_2 + p_1^3}{2}. $$The polynomial $P$ is therefore$$ x^3 - p_1 x^2 + \frac{p_1^2-p_2}{2}x - \frac{2p_3 - 3p_1p_2 + p_1^3}{6}. $$
_codereview.44097
I'm trying to login into a webapi2 site from a desktop application. After a lot of googling, I cobbled together a working prototype. Since we are talking about security I wanted to do a peer review. I'm just starting with security design and I'm not exactly sure about my design.The WebAPI site that is targeted is a wepapi 2 standard template out of visual studio.I'm mainly looking for security issuesut general issues are also greatly appreciated.One issue I'm aware of is that SSL should be added and with that ssl validation. I haven't implemented it yet.static internal async Task<string> GetWebAPIReguest(string siteUrl, string APIController, string userName, string Password){ TokenResponseModel Token = await GetBearerToken(siteUrl, userName, Password); HttpClient client = new HttpClient(); client.BaseAddress = new Uri(siteUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(application/json)); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Bearer, Token.AccessToken); return await client.GetStringAsync(APIController);}static internal async Task<TokenResponseModel> GetBearerToken(string siteUrl, string Username, string Password){ HttpClient client = new HttpClient(); client.BaseAddress = new Uri(siteUrl); client.DefaultRequestHeaders.Accept.Clear(); HttpContent requestContent = new StringContent(grant_type=password&username= + Username + &password= + Password, Encoding.UTF8, application/x-www-form-urlencoded); HttpResponseMessage responseMessage = await client.PostAsync(Token, requestContent); if (responseMessage.IsSuccessStatusCode) { string jsonMessage; using (Stream responseStream = await responseMessage.Content.ReadAsStreamAsync()) { jsonMessage = new StreamReader(responseStream).ReadToEnd(); } TokenResponseModel tokenResponse = (TokenResponseModel)JsonConvert.DeserializeObject(jsonMessage, typeof(TokenResponseModel)); return tokenResponse; } else { return null; }}class TokenResponseModel{ [JsonProperty(access_token)] public string AccessToken { get; set; } [JsonProperty(token_type)] public string TokenType { get; set; } [JsonProperty(expires_in)] public int ExpiresIn { get; set; } [JsonProperty(userName)] public string Username { get; set; } [JsonProperty(.issued)] public string IssuedAt { get; set; } [JsonProperty(.expires)] public string ExpiresAt { get; set; }}
Logging into WebAPI 2 site from c# desktop application
c#;security;api
null
_unix.342906
I have a machine running Linux Mint 17.3 with XFCE which I have just upgraded to 18.I have also decided to give KDE Plasma a try so I followed this guide to install it. However, I wasn't prompted to choose between lightdm and sddm during installation.Is installing KDE also supposed to install and enable sddm?
Does installing KDE also install sddm?
desktop environment;kde5;sddm
Turns out, I was missing the sddm package on this system. Installing it allowed to immediately choose sddm as my display manager:sudo apt-get install sddm
_unix.259861
I am operating across three systems: A remote Unix machine (let's call it Unix1), which stores some filesA local Windows machine (let's call it win1), which stores the private key to Unix1A remote Unix machine (let's call it Unix2) which stores a process.The process on Unix2 cannot be installed on Unix1. Ideally, I am trying to do the following:From Unix2, connect to Unix1 (using the private key on win1)Pull some files from Unix1 to Unix2Run a process on Unix2Push the output files from Unix2 to Unix1 (using the private key on win1)What syntax would I need to follow here? The location of the private key is what's creating quite some issues for me.
Push/Pull files among Unix machines with private key on Windows
ssh;scp
null
_codereview.108077
We typically do our saves and deletes for our asp.net pages (SQL Server as back-end) in the code behind. I've seen some reference the idea of creating a stored procedure for this purpose. Is this the best approach or is what I'm doing practical enough? Any suggestions? Here's an example of the delete button function (first half is for triggers set up in SQL):protected void DeleteClick(object sender, EventArgs e){ cookie = Request.Cookies[pAuthCookie]; if (txtKey.Text == ) { string scriptstring = alert('User Error - Must Select Fromn the LIST first.');; ScriptManager.RegisterStartupScript(Tab1, typeof(string), alertscript, scriptstring, true); if (TabContainer1.ActiveTabIndex == 1) TabContainer1.ActiveTabIndex = 0; return; } else { String fprescript = txtKey.Text; string empno = cookie[thenum].ToString(); string sqlstring1 = UPDATE prescriptions set empfk = @empfk WHERE prescriptpk = @prescriptpk; con.Open(); SqlCommand cmd1 = new SqlCommand(sqlstring1, con); cmd1.Parameters.Add(@prescriptpk, SqlDbType.Int); cmd1.Parameters.Add(@empfk, SqlDbType.Int); cmd1.Parameters[@prescriptpk].Value = Convert.ToInt32(fprescript); cmd1.Parameters[@empfk].Value = empno.Trim(); cmd1.ExecuteNonQuery(); con.Close(); string sqlstring = DELETE FROM prescriptions WHERE prescriptpk = @prescriptpk; con.Open(); SqlCommand cmd = new SqlCommand(sqlstring, con); cmd.Parameters.Add(@prescriptpk, SqlDbType.Int); cmd.Parameters[@prescriptpk].Value = Convert.ToInt32(fprescript); cmd.ExecuteNonQuery(); con.Close(); clearoutdata(); TabContainer1.ActiveTabIndex = 0; GridView1.DataBind(); }}
Should I be using a stored procedure for this function in my code behind?
c#;sql;asp.net
null
_webmaster.9936
I have a traditional HTML website that loads pages/sections of the site when people click on menu items. Pretty standard.Currently, I'm working on relaunching my website with a brand new HTML5 code & jquery that loads the whole thing, and just slides from one section to the next, sort of like this website: http://www.mino.pl/My concern is that this will affect my ranking with google and websiteoutlook.com because it may seem like the website only has one page now instead of 8, making it look like I have less pageviews and making my site less relevant for search engine rankings.Are my concerns legit? If so, do you have suggestions on how to avoid it? I really like the idea of working with a page that 'slides' to different sections better than having pages load all the time.Any suggestions/thoughts would be very much appreciated. Thanks.
Will my new HTML5 website decrease my Google ranking?
seo;javascript;html5
null
_softwareengineering.23234
Just wondered what are the features of the three main programming languages which show you are an 'expert'? Please exclude 'practical' skills such as indenting.Am I right in saying for C++ the most difficult aspect to master is STL/generics? Java seems much easier as memory is handled for you. I'm not entirely sure on C# either?I'm trying to use this to guage my current level of ability and what i wish to aim for.ps this was posted on stackoverflow but got binned due to arguing, please do try to keep it civil as I am really interested in the answers from everyone :)
What are the hardest parts of the C++/C#/Java programming languages?
java;c#;c++
null
_unix.382203
I daily work on my computer which is running on debian. In this last period of time the computer began to be pretty slow. Usually i use a web browser, either Chrome or Opera, an editor (atom) and a terminal. I suspect something is wrong with the hardware but I really have no clues. How can i figure it out? this is my lshw outputdebian description: Desktop Computer product: To Be Filled By O.E.M. (To Be Filled By O.E.M.) vendor: To Be Filled By O.E.M. version: To Be Filled By O.E.M. serial: To Be Filled By O.E.M. width: 64 bits capabilities: smbios-2.7 dmi-2.7 smp vsyscall32 configuration: boot=normal chassis=desktop family=To Be Filled By O.E.M. sku=To Be Filled By O.E.M. uuid=00020003-0004-0005-0006-000700080009 *-core description: Motherboard product: H61M-GS vendor: ASRock physical id: 0 *-firmware description: BIOS vendor: American Megatrends Inc. physical id: 0 version: P1.20 date: 06/21/2011 size: 64KiB capacity: 4032KiB capabilities: pci upgrade shadowing cdboot bootselect socketedrom edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int9keyboard int14serial int17printer acpi usb biosbootspecification uefi *-cache:0 description: L1 cache physical id: 4 size: 256KiB capacity: 256KiB capabilities: internal varies configuration: level=1 *-cache:1 description: L2 cache physical id: 5 size: 1MiB capacity: 1MiB capabilities: internal varies unified configuration: level=2 *-cache:2 description: L3 cache physical id: 6 size: 6MiB capacity: 6MiB capabilities: internal varies unified configuration: level=3 *-memory description: System Memory physical id: c slot: System board or motherboard size: 8GiB *-bank:0 description: DIMM DDR3 Synchronous 1067 MHz (0,9 ns) product: CMX8GX3M2A1333C9 vendor: Corsair physical id: 0 serial: 00000000 slot: A1_DIMM0 size: 4GiB width: 64 bits clock: 1067MHz (0.9ns) *-bank:1 description: DIMM DDR3 Synchronous 1067 MHz (0,9 ns) product: CMX8GX3M2A1333C9 vendor: Corsair physical id: 1 serial: 00000000 slot: A1_DIMM1 size: 4GiB width: 64 bits clock: 1067MHz (0.9ns) *-cpu description: CPU product: Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz vendor: Intel Corp. physical id: 16 bus info: cpu@0 version: Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz slot: CPUSocket size: 1657MHz capacity: 3800MHz width: 64 bits clock: 100MHz capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm epb tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm ida arat pln pts cpufreq configuration: cores=4 enabledcores=4 threads=4 *-pci description: Host bridge product: 2nd Generation Core Processor Family DRAM Controller vendor: Intel Corporation physical id: 100 bus info: pci@0000:00:00.0 version: 09 width: 32 bits clock: 33MHz configuration: driver=snb_uncore resources: irq:0 *-pci:0 description: PCI bridge product: Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port vendor: Intel Corporation physical id: 1 bus info: pci@0000:00:01.0 version: 09 width: 32 bits clock: 33MHz capabilities: pci pm msi pciexpress normal_decode bus_master cap_list configuration: driver=pcieport resources: irq:24 ioport:e000(size=4096) memory:f8000000-fa0fffff ioport:d0000000(size=201326592) *-display description: VGA compatible controller product: GF114 [GeForce GTX 560] vendor: NVIDIA Corporation physical id: 0 bus info: pci@0000:01:00.0 version: a1 width: 64 bits clock: 33MHz capabilities: pm msi pciexpress vga_controller bus_master cap_list rom configuration: driver=nouveau latency=0 resources: irq:31 memory:f8000000-f9ffffff memory:d0000000-d7ffffff memory:d8000000-dbffffff ioport:e000(size=128) memory:c0000-dffff *-multimedia description: Audio device product: GF114 HDMI Audio Controller vendor: NVIDIA Corporation physical id: 0.1 bus info: pci@0000:01:00.1 version: a1 width: 32 bits clock: 33MHz capabilities: pm msi pciexpress bus_master cap_list configuration: driver=snd_hda_intel latency=0 resources: irq:17 memory:fa080000-fa083fff *-communication description: Communication controller product: 6 Series/C200 Series Chipset Family MEI Controller #1 vendor: Intel Corporation physical id: 16 bus info: pci@0000:00:16.0 version: 04 width: 64 bits clock: 33MHz capabilities: pm msi bus_master cap_list configuration: driver=mei_me latency=0 resources: irq:29 memory:fa307000-fa30700f *-usb:0 description: USB controller product: 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 vendor: Intel Corporation physical id: 1a bus info: pci@0000:00:1a.0 version: 05 width: 32 bits clock: 33MHz capabilities: pm debug ehci bus_master cap_list configuration: driver=ehci-pci latency=0 resources: irq:16 memory:fa306000-fa3063ff *-usbhost product: EHCI Host Controller vendor: Linux 4.9.0-3-amd64 ehci_hcd physical id: 1 bus info: usb@1 logical name: usb1 version: 4.09 capabilities: usb-2.00 configuration: driver=hub slots=2 speed=480Mbit/s *-usb description: USB hub product: Integrated Rate Matching Hub vendor: Intel Corp. physical id: 1 bus info: usb@1:1 version: 0.00 capabilities: usb-2.00 configuration: driver=hub slots=4 speed=480Mbit/s *-usb:0 description: Keyboard product: USB Receiver vendor: Logitech physical id: 3 bus info: usb@1:1.3 version: 12.04 capabilities: usb-2.00 configuration: driver=usbhid maxpower=98mA speed=12Mbit/s *-usb:1 description: Audio device product: Jabra SPEAK 510 USB vendor: GN Netcom physical id: 4 bus info: usb@1:1.4 version: 2.10 serial: 501AA5550366020A00 capabilities: usb-2.00 audio-control configuration: driver=usbhid maxpower=500mA speed=12Mbit/s *-multimedia description: Audio device product: 6 Series/C200 Series Chipset Family High Definition Audio Controller vendor: Intel Corporation physical id: 1b bus info: pci@0000:00:1b.0 version: 05 width: 64 bits clock: 33MHz capabilities: pm msi pciexpress bus_master cap_list configuration: driver=snd_hda_intel latency=0 resources: irq:30 memory:fa300000-fa303fff *-pci:1 description: PCI bridge product: 6 Series/C200 Series Chipset Family PCI Express Root Port 1 vendor: Intel Corporation physical id: 1c bus info: pci@0000:00:1c.0 version: b5 width: 32 bits clock: 33MHz capabilities: pci pciexpress msi pm normal_decode bus_master cap_list configuration: driver=pcieport resources: irq:25 *-pci:2 description: PCI bridge product: 6 Series/C200 Series Chipset Family PCI Express Root Port 2 vendor: Intel Corporation physical id: 1c.1 bus info: pci@0000:00:1c.1 version: b5 width: 32 bits clock: 33MHz capabilities: pci pciexpress msi pm normal_decode bus_master cap_list configuration: driver=pcieport resources: irq:26 ioport:d000(size=4096) memory:fa200000-fa2fffff ioport:dc100000(size=1048576) *-network description: Ethernet interface product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:03:00.0 logical name: enp3s0 version: 06 serial: e8:de:27:00:de:e2 size: 10Mbit/s capacity: 1Gbit/s width: 64 bits clock: 33MHz capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half latency=0 link=no multicast=yes port=MII speed=10Mbit/s resources: irq:28 ioport:d000(size=256) memory:fa200000-fa200fff memory:dc100000-dc103fff *-pci:3 description: PCI bridge product: 6 Series/C200 Series Chipset Family PCI Express Root Port 3 vendor: Intel Corporation physical id: 1c.2 bus info: pci@0000:00:1c.2 version: b5 width: 32 bits clock: 33MHz capabilities: pci pciexpress msi pm normal_decode bus_master cap_list configuration: driver=pcieport resources: irq:27 ioport:c000(size=4096) memory:fa100000-fa1fffff *-network description: Ethernet interface product: AR8151 v2.0 Gigabit Ethernet vendor: Qualcomm Atheros physical id: 0 bus info: pci@0000:04:00.0 logical name: enp4s0 version: c0 serial: 00:25:22:d6:ba:a1 size: 100Mbit/s capacity: 1Gbit/s width: 64 bits clock: 33MHz capabilities: pm msi pciexpress vpd bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=atl1c driverversion=1.0.1.1-NAPI duplex=full ip=192.168.1.9 latency=0 link=yes multicast=yes port=twisted pair speed=100Mbit/s resources: irq:32 memory:fa100000-fa13ffff ioport:c000(size=128) *-usb:1 description: USB controller product: 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 vendor: Intel Corporation physical id: 1d bus info: pci@0000:00:1d.0 version: 05 width: 32 bits clock: 33MHz capabilities: pm debug ehci bus_master cap_list configuration: driver=ehci-pci latency=0 resources: irq:23 memory:fa305000-fa3053ff *-usbhost product: EHCI Host Controller vendor: Linux 4.9.0-3-amd64 ehci_hcd physical id: 1 bus info: usb@2 logical name: usb2 version: 4.09 capabilities: usb-2.00 configuration: driver=hub slots=2 speed=480Mbit/s *-usb description: USB hub product: Integrated Rate Matching Hub vendor: Intel Corp. physical id: 1 bus info: usb@2:1 version: 0.00 capabilities: usb-2.00 configuration: driver=hub slots=6 speed=480Mbit/s *-usb:0 description: USB hub product: USB 2.0 Hub vendor: Terminus Technology Inc. physical id: 4 bus info: usb@2:1.4 version: 1.11 capabilities: usb-2.00 configuration: driver=hub maxpower=100mA slots=4 speed=480Mbit/s *-usb description: Mass storage device product: Mass Storage vendor: Generic physical id: 3 bus info: usb@2:1.4.3 logical name: scsi4 version: 1.02 serial: A0C2F9AC capabilities: usb-2.00 scsi emulated configuration: driver=usb-storage maxpower=200mA speed=480Mbit/s *-disk description: SCSI Disk product: Flash Disk vendor: Generic physical id: 0.0.0 bus info: scsi@4:0.0.0 logical name: /dev/sdd version: 8.07 serial: A size: 1912MiB (2004MB) capabilities: removable configuration: ansiversion=4 logicalsectorsize=512 sectorsize=512 *-medium physical id: 0 logical name: /dev/sdd size: 1912MiB (2004MB) capabilities: partitioned partitioned:dos configuration: signature=8bafd155 *-volume description: Windows FAT volume vendor: MSDOS5.0 physical id: 1 logical name: /dev/sdd1 logical name: /media/giovanni/0E17-AC39 version: FAT32 serial: 0e17-ac39 size: 1908MiB capacity: 1910MiB capabilities: primary fat initialized configuration: FATs=2 filesystem=fat mount.fstype=vfat mount.options=rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro state=mounted *-usb:1 description: Mouse product: USB-PS/2 Optical Mouse vendor: Logitech physical id: 5 bus info: usb@2:1.5 version: 20.00 capabilities: usb-2.00 configuration: driver=usbhid maxpower=98mA speed=1Mbit/s *-usb:2 description: Keyboard product: Coolermaster Novatouch TKL vendor: CM Storm physical id: 6 bus info: usb@2:1.6 version: 0.01 capabilities: usb-2.00 configuration: driver=usbhid maxpower=100mA speed=12Mbit/s *-isa description: ISA bridge product: H61 Express Chipset Family LPC Controller vendor: Intel Corporation physical id: 1f bus info: pci@0000:00:1f.0 version: 05 width: 32 bits clock: 33MHz capabilities: isa bus_master cap_list configuration: driver=lpc_ich latency=0 resources: irq:0 *-ide:0 description: IDE interface product: 6 Series/C200 Series Chipset Family 4 port SATA IDE Controller vendor: Intel Corporation physical id: 1f.2 bus info: pci@0000:00:1f.2 version: 05 width: 32 bits clock: 66MHz capabilities: ide pm bus_master cap_list configuration: driver=ata_piix latency=0 resources: irq:19 ioport:1f0(size=8) ioport:3f6 ioport:170(size=8) ioport:376 ioport:f090(size=16) ioport:f080(size=16) *-serial description: SMBus product: 6 Series/C200 Series Chipset Family SMBus Controller vendor: Intel Corporation physical id: 1f.3 bus info: pci@0000:00:1f.3 version: 05 width: 64 bits clock: 33MHz configuration: driver=i801_smbus latency=0 resources: irq:18 memory:fa304000-fa3040ff ioport:f000(size=32) *-ide:1 description: IDE interface product: 6 Series/C200 Series Chipset Family 2 port SATA IDE Controller vendor: Intel Corporation physical id: 1f.5 bus info: pci@0000:00:1f.5 version: 05 width: 32 bits clock: 66MHz capabilities: ide pm bus_master cap_list configuration: driver=ata_piix latency=0 resources: irq:19 ioport:f070(size=8) ioport:f060(size=4) ioport:f050(size=8) ioport:f040(size=4) ioport:f030(size=16) ioport:f020(size=16) *-scsi:0 physical id: 1 logical name: scsi1 capabilities: emulated *-disk description: ATA Disk product: OCZ-VERTEX3 physical id: 0.0.0 bus info: scsi@1:0.0.0 logical name: /dev/sdc version: 2.15 serial: OCZ-KCQP8A25NTY55298 size: 111GiB (120GB) capabilities: partitioned partitioned:dos configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=55ea8566 *-volume:0 description: EXT4 volume vendor: Linux physical id: 1 bus info: scsi@1:0.0.0,1 logical name: /dev/sdc1 logical name: / version: 1.0 serial: 60cfdb08-6083-4531-83b0-db57b07b010d size: 103GiB capacity: 103GiB capabilities: primary bootable journaled extended_attributes large_files huge_files dir_nlink 64bit extents ext4 ext2 initialized configuration: created=2017-06-22 22:50:21 filesystem=ext4 lastmountpoint=/ modified=2017-07-27 19:31:07 mount.fstype=ext4 mount.options=rw,relatime,errors=remount-ro,data=ordered mounted=2017-07-23 20:44:48 state=mounted *-volume:1 description: Extended partition physical id: 2 bus info: scsi@1:0.0.0,2 logical name: /dev/sdc2 size: 8172MiB capacity: 8172MiB capabilities: primary extended partitioned partitioned:extended *-logicalvolume description: Linux swap volume physical id: 5 logical name: /dev/sdc5 version: 1 serial: 90aef283-c1a2-495e-99f6-6d82939a9992 size: 8172MiB capacity: 8172MiB capabilities: nofs swap initialized configuration: filesystem=swap pagesize=4096 *-scsi:1 physical id: 2 logical name: scsi2 capabilities: emulated *-disk description: ATA Disk product: WDC WD10EARS-00Y vendor: Western Digital physical id: 0.0.0 bus info: scsi@2:0.0.0 logical name: /dev/sda version: 0A80 serial: WD-WCAV59925972 size: 931GiB (1TB) capabilities: partitioned partitioned:dos configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=adf644a9 *-volume description: Windows NTFS volume physical id: 1 bus info: scsi@2:0.0.0,1 logical name: /dev/sda1 version: 3.1 serial: 02b7128e-282a-ad47-aa33-e324f94afe65 size: 931GiB capacity: 931GiB capabilities: primary ntfs initialized configuration: clustersize=4096 created=2010-06-26 19:59:07 filesystem=ntfs label=Volume modified_by_chkdsk=true mounted_on_nt4=true resize_log_file=true state=dirty upgrade_on_mount=true *-scsi:2 physical id: 3 logical name: scsi3 capabilities: emulated *-disk description: ATA Disk product: MAXTOR STM332082 vendor: Maxtor physical id: 0.0.0 bus info: scsi@3:0.0.0 logical name: /dev/sdb version: E serial: 9QF9WMAV size: 298GiB (320GB) capabilities: partitioned partitioned:dos configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=0002e29b *-volume:0 description: Windows NTFS volume physical id: 1 bus info: scsi@3:0.0.0,1 logical name: /dev/sdb1 version: 3.1 serial: 272564bb-0128-47aa-9923-4c3d7bfeab78 size: 294GiB capacity: 294GiB capabilities: primary ntfs initialized configuration: clustersize=4096 created=2012-05-15 16:00:05 filesystem=ntfs modified_by_chkdsk=true mounted_on_nt4=true resize_log_file=true state=dirty upgrade_on_mount=true *-volume:1 description: Extended partition physical id: 3 bus info: scsi@3:0.0.0,3 logical name: /dev/sdb3 size: 4094MiB capacity: 4094MiB capabilities: primary extended partitioned partitioned:extended *-logicalvolume description: Linux swap volume physical id: 5 logical name: /dev/sdb5 version: 1 serial: 1d77a2cf-e67f-4d88-81da-94976ed47bbb size: 4094MiB capacity: 4094MiB capabilities: nofs swap initialized configuration: filesystem=swap pagesize=4096
test my debian machine's hardware
hardware
null
_unix.12497
I have been using w3m for a couple of weeks and am convinced that it is my preferred text browser - with one exception.Is there any way to yank URLs to the clipboard without using the mouse?I have looked through the manual and, using the default keybindings, there doesn't appear to be any documented way to do this.Has anyone developed a script to work around this?
Yanking URLs in w3m
configuration;keyboard shortcuts;browser;clipboard;w3m
Set the External Browser option tosh -c 'printf %s $0 | xsel'You can use xsel -b to use the clipboard instead of the primary selection. An alternative to xsel is xclip (xclip for the primary selection, xclip -selection CLIPBOARD for the clipboard).In ~/.w3m/config, that's the extbrowser setting.Then press M to copy (yank) the URL of the current page, or ESC M to copy the URL of the link under the cursor.You can use the second or third external browser for that instead; then the key combination is 2 M or 3 M or 2 ESC M or 3 ESC M.
_cs.10955
Suppose we have a function based on two inputs of length $m,n$. Therefore the time complexity of the function is calculated by $T(m,n)$. Suppose that we have:$T(m,c)\in O(m^2)$ for any constant $c$.$T(c',n)\in O(n^2)$ for any constant $c'$.What can we say about $T(m,n)$?
Time complexity based on two variables
asymptotics;landau notation
With this exact phrasing, and without additional assumptions on the structure of $T$, you can't really say anything about it's asymptotic behavior in general.First, observe that the function $m^2n^2$ satisfies the constraints, so you can at least $\Omega(m^2n^2)$. However, you can get much more than that.Let $f(k)$ be some function. Think of $f$ as a very quickly-growing function (e.g. $f(k)=2^k$).Now, think of $\mathbb{N}^2$ as a two dimensional plane, with the $m$ and $n$ axes. We require that along every vertical and every horizontal line, the function is asymptotically quadratic. This means that we can do whatever we want with finitely many elements of every row/column.Thus, for example, you can set $T(k,k)=f(k)$ for every $k$, and set $T(m,n)=m^2n^2$ for all entries where $m\neq n$.The diagonal of this function is huge. That is, $T(k,k)=\Omega(f(k))$. However, the function still satisfies the constraints. Also, note that you can make this function monotonic by adding $f(k)$ to all elements in the relevant row/column. That is, take$$T(m,n)=f(\min\{m,n\})+m^2n^2$$This still has the same property, only here we change finitely many elements, instead of a single element.
_vi.7292
I wanted to highlight all occurence of TODO and NOTE in my code.Looking on the internet, I inserted the following code in my .vimrc:match GruvboxGreenBold /NOTE/:2match ErrorMsg /TODO/This seemed to work fine at first. When I open a file with gvim, the syntax highlights correctly.However, as soon as I split my screen and the file appears twice, the second one get the correct highlighting but the first one loses it.It repeats whenever I open a new buffer.Here's a screenshot Does anyone know how to correct this behavior ?
Highlighting with :match does not appear in all buffers
syntax highlighting;gvim
From :help :match: Note that highlighting the last used search pattern with 'hlsearch' is used in all windows, while the pattern defined with :match only exists in the current window. It is kept when switching to another buffer.It seems that the highlighting created by :match is local to the current window, not to the current buffer. When you split your screen, you create a new window, so you probably have to reapply your highlighting. If you want :match and :2match to be automatically executed whenever you launch Vim or enter a new window, you could install the following autocmd:augroup custom_highlighting autocmd! autocmd VimEnter,WinEnter * match GruvboxGreenBold /NOTE/ | 2match ErrorMsg /TODO/augroup END
_webmaster.108262
Can Anyone Help Me to Remove Sitename: from google Search results. This is my real title name <title>Web Design & Web Development | Ixeun Software Solutions | Batticaloa</title> but google adds iXeun: Web Design & Web Development | Ixeun Software Solutions | Batticaloa from search results this is little bit confusing for me. Please Search for site:ixeun.com on google so you will find my home page link root shows like above.
Google Force Adding 'Site name : ' on Search Result
seo;google;google search console
From this answer: Site URL being displayed before TITLE on SERPThis is a well known effect for those who experiment with using the pipe character (|) in title tag. I mention it here in an update: Pipes or colons in HTML title tags? which I should update again with new findings when I sort out my thoughts.When the pipe character is used in a title tag, Google treats the tag as a keyword list. This does not work for other characters- it is a relatively new effect following a trend. If the domain name, either with or without the TLD, appears at the end of the list Google takes it as a branding signal and will place example.com : at the beginning of the title tag and remove the keyword from the end of the title tag.While there is not a direct match, it appears that Google is picking up the branding signal and doing what is advertised.From this answer: Does changing company/brand name in title have SEO issues?The pipe character (|) indicates a semantic cluster. A semantic cluster is a sub-section of text that is to be semantically analyzed by itself.Google is specifically looking for a brand in the last section. If your brand is recognized as a brand within the brand ontology such as Kellogg, Mars, Coke Cola, etc., Google will primarily defer to the ontology. If your brand does not exist in the brand ontology (or even if it does), Google will specifically look at the terms within the brand and the domain name.This is the first case where I have seen Google picking up branding signals from a semantic cluster that is not the last one.Whenever people use the pipe character within the title tag, they should really know what is going on. In your case, Google is doing what is advertised and there is no surprise here.I suggest reading the two linked answers for specific information. It will be a trivial edit of the title tag to change this effect.If you want to avoid this form of branding altogether, you can avoid using pipes with a title such as this:Web Design & Web Development by Ixeun Software Solutions - Batticaloa
_webmaster.48806
Our pages used to be formulated using the ? string but since we changed to AJAX loading we now use #!, for example: Old link: /post.php?idPost=5326New link: /post.php#!idPost=5326The snapshot you can get it by adding _escaped_fragment_= after the ?.All have the same content, what has happened to the site since we changed the linking system?
Using Ajax #! for Google but site is not being crawled any more
seo;google;indexing;ajax;web crawlers
Even though hashbangs #! are still supported, Google suggests steering away from using them and just use the History API to change the URL. Libraries like History.js make it easy to do so.This basically removes your problem altogether, there's no need to set up urls with _escaped_fragment_ when using the History API
_unix.233675
If I were to log on to remote host using ssh and run a program there, does the program use resources (CPU etc) of local machine or remote host?If it is the former is there a way to make it run using the remote host's resources? I'm trying to run a java program on a remote host using ssh.
SSH remote execution of program resource usage?
ssh
If you connect via ssh, you open a terminal on the remote machine.Everything you do uses the resources of the remote machine.The resources of the local machine are used to display the output of the terminal you're connected to.
_unix.199887
I'm configuring sendmail on hpux 11.31 i have to set a a random fileif i setdefine(`confRAND_FILE',`dev:/dev/urandom')dnlGive this errorSTARTTLS: Error: no proper random file definition dev:/dev/urandomif i setdefine(`confRAND_FILE',`file:/dev/urandom')dnlGive this errorSTARTTLS: Warning: safeopen(/dev/urandom) failedHow to set?Thanks
sendmail: proper /dev/urandom
sendmail
Solution foundhttp://support.hp.com/id-en/document/c00916394Must use egd:/dev/urandom,not file,using /dev/random give an errorHere's the correct mc filedivert(0)dnlVERSIONID(`$Id: generic-hpux10.mc,v 8.13 2001/05/29 17:29:52 ca Exp $')OSTYPE(hpux11)dnlDOMAIN(generic)dnldefine(`_X400_UUCP_')dnldefine(`_MASQUERADE_ENVELOPE_')dnldefine(`MASQUERADE_NAME')dnldefine(`confTRY_NULL_MX_LIST',`T')dnldefine(`LUSER_RELAY',`name_of_luser_relay')dnldefine(`DATABASE_MAP_TYPE',`dbm')dnldefine(`_CLASS_U_')dnldefine(`LOCAL_RELAY')dnldefine(`MAIL_HUB')dnlTRUST_AUTH_MECH(`GSSAPI DIGEST-MD5')dnlFEATURE(always_add_domain)dnlMAILER(local)dnlMAILER(smtp)dnlMAILER(openmail)dnlMAILER(uucp)dnldefine(`SMART_HOST', `posta.domain.com')define(`confCACERT_PATH', `/etc/mail/certs')dnldefine(`confCACERT', `/etc/mail/certs/domain.com.crt')dnldefine(`confSERVER_CERT', `/etc/mail/certs/hpux2.domain.com.crt')dnldefine(`confSERVER_KEY', `/etc/mail/certs/hpux2.domain.com.key')dnldefine(`confCLIENT_CERT', `/etc/mail/certs/hpux2.domain.com.crt')dnldefine(`confCLIENT_KEY', `/etc/mail/certs/hpux2.domain.com.key')dnldefine(`confRAND_FILE',`egd:/dev/urandom')dnlD{tls_version}TLSv1O UseTLS=True
_unix.160267
I am running Linux Mint 17 Xfce on an HP Elitebook 840 G1 laptop. Up until just now I was using an external monitor, displaying identically the same thing as the built-in laptop display, connected via the VGA port. This worked absolutely fine and as expected. However, I have accidentally unchecked a tick-box in the System Settings -> Display options, which said something like use this display. Now the external monitor has vanished from the system settings, seemingly never to return. Of course I have tried restarting the computer and monitor, unplugging the VGA cord etc. Even worse, xrandr now cannot detect a VGA output on my laptop at all! Anyone have a clue what I've done here?I should add that the display works while the computer is booting up, and also works fine at the login screen. Only once I have tapped in my password does the output to the monitor suddenly stop. I also have Windows installed on another hard drive on the same machine, and the external monitor works fine for that. So there's clearly nothing wrong with the hardware.
External VGA monitor disappeared from display options list
monitors;display settings
null
_webmaster.87163
I have been looking for documentation or examples of bitly branded short domains which use https (ssl / secure links). Have not found anything.Example of a branded short url: http://sgnl.link/1IvurmDI would like to setup: https://sgnl.link/1IvurmDIs this supported?
Do bitly Branded short domains support https?
https;security certificate;url shorteners;bitly;custom short url
YES. It's not official yet, but Bitly is starting to talk about their upcoming HTTPS support and it's already being rolled out.Here are two examples: https://huff.to/1NozAOQ and https://tcrn.ch/1SMWIINI tried it for my own branded domain (on a free account) and, initially, it didn't work. However, after several hours, a new certificate showed up and HTTPS requests were totally supported!How it worksIf you look at the certificate authority, they are using Let's Encrypt to issue separate certificates for each domain. In order to issue (and reissue) certificates, Let's Encrypt creates challenges that only the respective domain owner can complete. Because the domain owner has pointed their domain at Bitly's server (via either an A or CNAME record), Bitly is able to complete these challenges on the fly, thus confirming to Let's Encrypt that Bitly has the authority to serve an issued certificate. Bitly is, therefore, able to get certificates issued on the fly for all of the domains they want to support.There is one additional catch, however! In order to handle HTTPS requests from each client, they need to know which domain the client has sent their request to. Traditionally, this wouldn't be available over SSL/TLS without decrypting the request, and since Bitly can't decrypt the request without the right set of keys, they face a kind of catch-22. Thankfully, an add-on to TLS called Server Name Indication (SNI) was designed to solve exactly this problem. This allows the client to pass along a plaintext version of the server name, so that the receiving server can pair that with the correct decryption keys.This means that Bitly's HTTPS support only works with slightly more modern browsers, since really old browsers don't support SNI. But they're probably fine with that trade-off.Whew. A lot of moving parts there. This is a big announcement for Bitly and is actually a lot harder to get right than it might seem from the outset.
_unix.166083
If I want to add an entry to /etc/hosts to resolve all traffic for example.com to 1.2.3.4, do I need to add1.2.3.4 example.com1.2.3.4 www.example.com1.2.3.4 smtp.example.com1.2.3.4 pop.example.com...Or will just adding1.2.3.4 example.comsuffice?
Should /etc/hosts contain the domain name or the FQDN?
networking;dns;internet;hosts
You will need to specify each and every subdomain. If that is not what you want, you should look into installing a real DNS server (e.g. bind9).This is rather easy to check by first adding just example.com to /etc/hosts and then do ping -c 2 example.comping -c 2 www.example.comThe first will succeed with the provided IP address. The second will go to 93.184.216.119 (the IP address in the internet for www.example.com)
_cstheory.22626
I was wondering if there is any known complexity of problem for which primitive recursive functions cannot solve. One such problem might be is N the ackermann function for $k_1$ $k_2$ as it seems one would need to compute the ackermann function for $k_1$ and $k_2$ to decide this. It also seems that the traveling salesman problem can be solved using a primitive recursive function (I didn't try. it just seems possible by generating all permutations and checking each one). So it seems that I have a very hard problem to solve which can't be solved by primitive recursion and one very hard problem to solve which can be (I think). So what complexity of problems can be solved by primitive recursion, what complexity of problems cannot? Perhaps NP-hard problems are solvable with primitive recursion but not as efficiently?edit:It seems that my suspicion Perhaps NP-hard problems are solvable with primitive recursion but not as efficiently was correct. If this is the case which problems are solvable as efficiently with a turing machine as with primitive recursion?
Complexity of problems solvable by primitive recursion
cc.complexity theory;computability
null
_webmaster.58976
I've updated bingplaces.com with description, images, hours of operation, secondary phone, fax, email and website.All I see though in Bing Maps is still the address and one phone number.Where does all of the additional information they asked for even show up?Edit:I've now found some of this content on Bing if I type in EXACTLY the company name. It will show on the right side with company name, map, address, phone, website, and hours.I still have no idea where, if anywhere, the logo and photos are being used though?
Where does Bingplaces information appear?
bing
After about 2 weeks of checking every day I slowed down checking but at some point they finally did show up.If I type in the exact name the images all show up. Additionally, I can now click on the map and it directs me to a bing.com/local/?lid.... which has all of our information, images, and contact stuff on the left then map on the right.So if anyone else is having this issue I'd say give it a good 6 to 8 weeks for the images.
_unix.278117
Currently I am using Arch Linux with a Gnome Desktop Environment. Now I have chosen to use Yakuake as my terminal. I'd like to use other skins that other people have put up online for my terminal. However when I try to get 'hot new skins', this is what happens. I must inform people that I have an http proxy. This maybe the primary reason why I cannot connect to http://kde-look.org/index.php?xsortmode=high&page=0&xcontentmode=87. As an alternative, is there a way I can get skins on Yakuake offline by downloading the skins from the website? This will only be a valid answer if I cannot download my skin over the proxy and the port I have as of now.
Trying to download new Yakuake skins on my Arch/Gnome installation, but cannot
arch linux;terminal;gnome;proxy
null
_unix.31824
I have detached a process from my terminal, like this:$ process &That terminal is now long closed, but process is still running and I want to send some commands to that process's stdin. Is that possible?
How to attach terminal to detached process?
linux;shell;command line;terminal;process
Yes, it is. First, create a pipe:mkfifo /tmp/fifo. Use gdb to attach to the process:gdb -p PIDThen close stdin: call close (0); and open it again: call open (/tmp/fifo, 0600)Finally, write away (from a different terminal, as gdb will probably hang):echo blah > /tmp/fifo
_codereview.3312
My current setup is a 3 layered application: UI > BLL > DAL. Each layer is set up as a separate project. The UI is an ASP.Net website and the BLL & DAL are Class Library projects.I've shown some sample code from each of my layers. Hopefully you guys can critique my application design and give me some tips/pointers or I'm doing this wrong, steer me in the right direction. Thanks!DAL Method:public static object Get_UserId(string username){ ConnectionSettings connectionSettings = new ConnectionSettings(); SqlConnection sqlConnection = new SqlConnection(connectionSettings.ConnectionString); string sql = String.Format(select UserId from Users where Username = '{0}', username); try { sqlConnection.Open(); SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection); return sqlCommand.ExecuteScalar(); } catch { throw new DALException(Unable to retreive User ID); } finally { sqlConnection.Close(); }}The BLL method responsible for retreiving User ID: public static int GetUserId(string username) { try { int userId = Int32.Parse(UserDAL.Get_UserId(username).ToString()); return userId; } catch (Exception ex) { throw new BLLException(ex.Message); } }The call to the BLL from UI:try{ int id = UserBLL.GetUserId(bobloblaw); Response.Write(id);}catch (DALException dalEx){ Response.Write(dalEx.Message);}catch (BLLException bllEx){ Response.Write(bllEx.Message);}
3-layer ASP.NET app - Need critique/advice
c#;.net;asp.net
null