id
stringlengths 5
27
| question
stringlengths 19
69.9k
| title
stringlengths 1
150
| tags
stringlengths 1
118
| accepted_answer
stringlengths 4
29.9k
⌀ |
---|---|---|---|---|
_softwareengineering.139889 | I am learning Programming languages principles and there is a lot of information about stuff which make up a programming language . Unfortunately every material I came across until now has a lot of technical jargon involved and is very difficult to understand (Atleast for a beginner sincerely trying to understand the topic on his own by reading the material) . Can anyone explain me the Subscript binding and array categories in general .. The classification says there are five kinds of arrays -1.Static array2.Fixed stack-dynamic array3.Stack dynamic array4.Fixed heap dynamic array5.Heap dynamic arrayThis is what I could understand from the definitions (almost on every article on this topic I came across) . Static array - subscript ranges are statically bound and storage allocation is static.I understood that the space for the array is allocated in memory at compile time (before run time) . Fixed stack-dynamic array - subscript ranges are statically bound, but the allocation is done at elaboration time during execution.Now I didn't understand anything . What is meaning of the italicized phrases Stack-dynamic array - the subscript ranges are dynamically bound, and the storage allocation is dynamic during execution. Once bound they remain fixed during the lifetime of the variable.I dont understand what is meant by being 'bound' ? I should be able to understand the remaining two definitions if I understand these three . I know I am asking a lot .Thanks :)Here's a link I recently came across which I find useful for this topic . Anyone interested in this topic , check it out . :) | Subscript binding and array categories | programming languages;array | To elaborate DeadMG's answer, it sounds like they mean:Static array: an array whose size is known, and whose storage is allocated, at compile time. In C, you might write at global (file) scope:int static_array[7];Fixed stack-dynamic array: you know the size of your array at compile time, but allow it to be allocated automatically on the stack (the size is fixed at compile time but the storage is allocated when you enter its scope, and released when you leave it)void foo(){ int fixed_stack_dynamic_array[7]; /* ... */}Stack dynamic array: you don't know the size until runtime, eg. C99 allows this:void foo(int n){ int stack_dynamic_array[n]; /* ... */}Fixed heap dynamic array: same as the 2 except using explicit heap allocationint * fixed_heap_dynamic_array = malloc(7 * sizeof(int));Heap dynamic array: you can probably guess this:void foo(int n){ int * heap_dynamic_array = malloc(n * sizeof(int));}Is this the same book as Concepts of Programming Languages? Because again, these aren't a useful classification of types, they only address the allocation mechanism. Once you pass any of these different things into a function, their classification under this scheme is irrelevant. |
_opensource.5222 | TL;DRIs having a repository on GitHub considered distribution in the sense of a license?DescriptionI have some repositories on GitHub. Now I modified a file for a project. The file was licensed under Apache 2.The project is for an online course from Udacity to learn Android development.My understanding is the following. If I distribute the file then I have to comply with the license in the sense that I have to:include the copyrightinclude the licensestate the changesinclude a noticeQuestionNow my thinking is since I keep my repository public on GitHub, is it considered distribution, and thus I have to state the changes and include notices, etc. ? | Is having a repository on GitHub considered distribution? | apache 2.0;github;distribution | Yes, this is considered redistribution. If not what would? |
_unix.308078 | There is a collection of .doc files, in addition to other types of files, on a remote server (which supports SCP).I saw a script:FILE=`ssh abc@xyz ls -ht /tmp/*.doc | head -n 1`rsync -avz -e ssh abc@xyz:$FILE .It can copy the latest file from remote server when it use the parameter head -n 1. But I found it cannot copy latest three files from remote server even if it use the parameter head -n 3. | Copying latest three files from remote server | shell script;rsync;head | If abc's login shell on xyz is zsh:ssh abc@xyz 'cd /tmp && tar cf - ./*.doc(.LM-100om[1,3]) | gzip -3' | gunzip | tar xvf -If it's not zsh (but zsh is installed):ssh abc@xyz cd /tmp && exec zsh -c 'tar cf - ./*.doc(.LM-100om[1,3]) | gzip -3' | gunzip | tar xvf -In any case, beware that /tmp (or any world-writable directory) is a mine-field. Above, we're careful enough to only select regular files smaller than 100 MiB (with (.LM-100)), and tar will not follow symlinks or read the content of devices or named pipes but there's still a race-condition where someone could enlarge a file to several tebibytes in between that glob being expanded and the tar command being run.And of course, anybody could put malware with a .doc extension in /tmp, so you'd need to treat those download files very carefully.It would be better to do that in private directory instead of /tmp. |
_unix.110866 | Using the zsh shell, I've noticed a difference in the behavior of the tput command compared to bash. For instance With zsh, if you have many things output to a terminal emulator window and you're at the bottom, if you do tput cup 1, you go back up and everything below is cleared. With bash the output remains and is not cleared (on my setup). This comparison is valid for every terminal capability that moves the cursor around (cuu, cud, sc & rc, home, etc.). Do you have any control over that behavior in zsh i.e. not clearing? I'm looking at the possible options, but there's lots of things... If you cannot alter the behavior, can you use some other command which doesn't behave like such? | Cursor movement related tput commands under zsh: can the 'clear' behavior be configured? | zsh;termcap;tput | zsh outputs its completions below the prompt, so it makes sure that area is clear.I don't think you can disable it. However you can tell zsh that the escape sequence to clear until the end of the screen is the empty string.infocmp -x | sed 's/ed=[^,]*/ed=/' | TERMINFO=~/.zsh-terminfo tic -x -Then, you can start zsh with:TERMINFO=~/.zsh-terminfo zshAnd unset TERMINFO later, but you'll find that the completion is never cleared which makes it awkward to use. |
_softwareengineering.17254 | I'm reading Coders at Work by Peter Seibel, and many a time it has been mentioned that programmers who can't write generally make poor programmers - it's been claimed by Douglas Crockford, Joshua Bloch, Joe Armstrong, Dijkstra (and I've only read half the book).What's your view of this? Is an inability to express yourself in writing in a natural language such as English a hindrance of writing good code? | Do poor writers make poor programmers? | writing | There's much more to programming than 'writing code'. A big part of being a successful programmer involves communication; Being able to connect with customers, understand their needs, translate them into the technical realm, express them in code, and then explain the result back to the customers.Programmers who have a hard time expressing themselves clearly in writing may not be able to communicate well in general, whereas those who have a good grasp of language and writing can generally translate those skills to the code they write. I think being unable to write well, and thus communicate well, will keep one from being a very good programmer.As Jason Fried and David Heinemeier Hansson (of 37signals) say in their book Rework:If you're trying to decide among a few people to fill a position, hire the best writer. Being a good writer is about more than writing. Clear writing is a sign of clear thinking. Great writers know how to communicate. |
_unix.5310 | How can I disable bells/visualbells in vim?I've tried:set noebset novb.. but nothing has changed afaik.Just to be clear, I'm referring to the visual bell I get in vim when I do something that doesn't do anything, for exmaple pressing ESC in normal mode, or pressing h in on col 0. | How can I disable bells/visualbells in vim? | vim;bell | To disable the bell altogether, you need toenable vim's internal visual bell, with set visualbell (= set vb);set the effect of the vim visual bell to do nothing, with set t_vb=(This is explained in the documentation of 'visualbell', but not very clearly.) Even with novisualbell, you might see a visual bell if vim emits a bell control sequence (usually \a) and the terminal is configured to flash rather than make a sound. |
_softwareengineering.121423 | First, a little background. I'm a .Net developer (C#) and have over 5 years experience in both web development and desktop applications. I've been wanting to look into iPhone development for some time now, but for one reason or another always got side tracked. I finally have a potential project on the horizon, and I'm now going full steam ahead learning this stuff.My question is this: I haven't done any C/C++ programming since my schooling days, I've been living in managed land ever since. How much knowledge if any is needed to be successful as an iOS developer? Obviously memory management is something that I'll have to be conscious about (although with iOS 5 there seems to be something called ARC which should make my life easier), but what else? I'm not just talking about the C API (for example, in order to get the sin of a number, I call the sin() function), that's what Google is for. I'm talking about fundamental C/C++ idioms that the average C# developer is unaware of. | How much C/C++ knowledge is needed for Objective-C/iPhone development? | c#;c;iphone;ios | Don't worry about it. If you know enough C to be able to write function calls, understand and write arithmetic expressions, and deal with pointers, you'll probably be fine. You'll still need to learn Objective-C, of course, but much of the code that you'll write will be more Objective-C than plain old C. Getting used to Objective-C style and learning Cocoa Touch will consume much more of your time than brushing up on C.I usually tell people who are starting from zero to learn C before jumping into Objective-C. I stand by that advice -- learning C will teach you basic knowledge that you need in order to work effectively in Objective-C. You need to know what a function is, how to use control structures like loops and conditional statements, how the various basic data types work, what a struct is and so on. And since all of C is fair game in Objective-C, the more C you know the better you'll be prepared to understand code you might run across. That said, many tasks are done differently in Objective-C, so standard C idioms aren't necessarily standard Objective-C idioms. NSString and NSArray take the place of C-style arrays. Pointers are ubiquitous, but they're used mainly to refer to objects -- pointer arithmetic doesn't come up very often. Instead of allocating memory directly, you create objects.The same goes for C++... you won't need much C++ to get along fine in Objective-C. At some point in the future you might need to increase your C++ knowledge in order to integrate some existing C++ code into an app, and at that point you might need to spend some time learning, but don't let a lack of C++ knowledge stop you from trying your hand at iOS programming. |
_unix.128830 | OK, so source runs the script in the current shell and . separately, as detailed in running script with . and with source for example, but, specifically, in my .bashrc file, I have:[ -f ~/.bash_aliases ] && source ~/.bash_aliases[ -f ~/.git-completion.bash ] && source ~/.git-completion.bash[ -s ~/.autojump/etc/profile.d/autojump.sh ] && source ~/.autojump/etc/profile.d/autojump.shCan I replace this with:[ -f ~/.bash_aliases ] && . ~/.bash_aliases[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash[ -s ~/.autojump/etc/profile.d/autojump.sh ] && . ~/.autojump/etc/profile.d/autojump.shWill that work on OS X - is that the POSIX issue?I tried it and the above still seem to work on Ubuntu (so they actually work with both source and ., that is, they give me the desired functionality in the shell). Should I choose one over the other, or am I missing something?FWIW, on OS X, I source my .bashrc from my .bash_profile. | Is it OK to use . to run files instead of source - in .bashrc in Ubuntu and OS X? | osx;bashrc;posix | This is POSIX's definition of .dot:The shell shall execute commands from the file in the current environment.If file does not contain a /<slash>, the shell shall use the search path specified by $PATH to find the directory containing file. Unlike normal command search, however, the file searched for by the .dot utility need not be executable. If no readable file is found, a non-interactive shell shall abort; an interactive shell shall write a diagnostic message to standard error, but this condition shall not be considered a syntax error.Considering the above, you might as well just replace your [ -f ./file ] && source ./file with . ./file altogether. If the file is not there the worst that will happen is you'll get a notice at login - which is probably information you'd want to have, I think.Of course if you'd rather keep the test you could do:test -f ./file && . $_ |
_unix.291975 | I just downloaded VLC 3.0 Beta (using ubuntu ppa) and I wanted to know how to set it up to stream to chromecast. It's in the repo's NEWS that the feature has been added. Numerous news outlets are covering it. But, there is no example of how to actually use it yet.I know it's not in the GUI (having searched the source code). And, I have no idea how to use the code from the command line.Here is the Ubuntu PPA that I used to install it. However, it shouldn't matter. Nor, should the OS or system matter. It's just software. You can build it yourself or download a binary (nightly) here. | How do I stream to Chromecast using VLC? | vlc;chromecast | Thus far this feature is not available under the GUI, however you can stream to Chromecast like this,$ vlc --sout=#chromecast{ip=ip_address} ./video.mp4You can watch the video at the same time with$ vlc --sout=#duplicate{dst=display,#chromecast{ip=ip_address}} ./video.mp4To make matters even better, you can actually add a delay on the video so it better syncs with the audio (sets the delay to 3100ms).$ vlc --sout=#duplicate{dst=display{delay=3100},#chromecast{ip=ip_address}} ./video.mp4You can find the list of options support to chromecast here, they currently includeipporthttp-portmuxmimevideo |
_ai.1568 | Significant AI vs human board game matches include:chess: Deep Blue vs Kasparov in 1996,Go: DeepMind AlphaGo vs Lee Sedol in 2016,which demonstrated that AI challenged and defeated professional players.Are there known board games left where a human can still win against an AI? I mean based on the final outcome of authoritative famous matches, where there is still same board game where AI cannot beat a world champion of that game. | Is there any board game where a human can still beat an AI? | history;challenges;game theory | For many years, the focus has been on games with perfect information. That is, in Chess and Go both of us are looking at the same board. In something like Poker, you have information that I don't have and I have information that you don't have, and so for either of us to make sense of each other's actions we need to model what hidden information the other player has, and also manage how we leak our hidden information. (A poker bot whose hand strength could be trivially determined from its bets will be easier to beat than a poker bot that doesn't.)Current research is switching to tackling games with imperfect information. Deepmind, for example, has said they might approach Starcraft next.I don't see too much different between video games and board games, and there are several good reasons to switch to video games for games with imperfect information. One is that if you want beating the best human to be a major victory, there needs to be a pyramid of skill that human is atop of--it'll be harder to unseat the top Starcraft champion that the top Warcraft champion, even though the bots might be comparably difficult to code, just because humans have tried harder at Starcraft.Another is that many games with imperfect information deal with reading faces and concealing information, which an AI would have an unnatural advantage at; for multiplayer video games, players normally interact with each other through a server as intermediary and so the competition will be more normal. |
_webmaster.89435 | There is a website scenario in which a user gives date as input and the result will be something related with that date.Lets take the scenario is my website gives earth quakes happened in Europe on a particular date. Lets say below is the a result page of earth quakes happened in europe on 28-12-1994.www.geography.com/earth-quakes-in-europe-on/28-12-1994I am sure about the sentence part of my URL (earth-quakes-in-europe-on) is correct as per SEO standard. My question is can the date be decoded by Google correctly if somebody searches in Google earths quakes in europe on 28-12-1994 earths quakes in europe on 28/12/1994earths quakes in europe on December 28, 1994 Will my URL be decoded correctly and shown in Google result as per the query? | Best way to use date in URL for better SEO | seo;google;google search;url;dates | One of the primary places Google looks for a date for any given page is in the URL. If a date is found in the URL, it is considered to be a strong indicator over most if not all other sources including within the response header.From this answer: How to tell how old a page is?4] Google looks for a date within the URL. It looks for the following formats; YYYMMDDHH - YYYY - YYYYMM.These may not be the only formats, but after a lot of research at the time the question was asked and answered, there was little to go on that was solid.The URL is one of the strongest semantic clues for search engines just behind the title tag and before any link text. It is an important factor and part of the blended SERP result set before filter analysis is applied. A good URL/URI (domain name/path - these are really two separate entities) can really boost the opportunity to have a page found providing that it meets certain semantic standards.As far as where along the URL to place the date, there are some criteria that need to be considered. Mostly the question is how important is the date and where along the line does it make sense to include it? If for example, you are organizing by date, then the date should come first. Of course that is a no brainer. But if you are talking about celebrity birthdays, then the organization could be celebrity/birthday/date. This would allow for other structures such as celebrity/died/date. This structure is least specific to more specific from left to right.This answer gives a lot of information on that: Well structured URLs vs. URLs optimized for SEO |
_codereview.172090 | Pattern matching for years, I need to be able to return all years from a string. When there is a dash - I need to return all numbers between. For example, '2004-2006' should return an array of numbers [2004,2005,2006];If the number at the beginning of the dash is larger than the number following it, nothing should be printed out. For example '2006-2005' should return [].years between commas should simply be returned as long as they do not exceed the current year, and are not less than 1999. For example '1998,2020' should return an empty array []. There should be no duplicates and the values should be ordered.I believe my code could be written in a more elegant and consise way. Here are my test cases:assert.deepEqual(parseRange('2002-2005, 2002-2005, 2002 - 2005'), [2002, 2003, 2004, 2005]);assert.deepEqual(parseRange('2017'), [2017]);assert.deepEqual(parseRange('2017 - 2015'), []);assert.deepEqual(parseRange('2015 - 2015'), [2015]);assert.deepEqual(parseRange('1999 , 2000, , 2008'), [1999, 2000, 2008]);assert.deepEqual(parseRange('2015, 2014, 2010'), [2010, 2014, 2015]);assert.deepEqual(parseRange('1999, 3000'), [1999]);assert.deepEqual(parseRange('1998, 2020'), []);Here is my working Codefunction parseRange(string) { return [...new Set(string.split(',').map(range => range.includes('-') ? range.split('-').map(num => +num) : +range) .filter(set => Array.isArray(set) ? set[0] <= set[1] : set > 1998 && set <= new Date().getFullYear()).reduceRight((arr, val) => arr.concat(Array.isArray(val) ? Array(val[1] - val[0] + 1).fill().map((_, num) => val[0] + num) : val), []))].sort();}console.log(parseRange('2002-2005, 2002-2005, 2002 - 2005'));console.log(parseRange('2017'));console.log(parseRange('2017 - 2015'));console.log(parseRange('2015 - 2015'));console.log(parseRange('1999 , 2000, , 2008'));console.log(parseRange('2015, 2014, 2010'));console.log(parseRange('1999, 3000'));console.log(parseRange('1998, 2020')); | Pattern finding function for years between 1998 and 2017 with several test cases | javascript;array;parsing;interval | null |
_webapps.104295 | I want to use my email (in apple mail app) to send a message to a friend on Facebook. Is there an email I can send it to from my mail app? Is this even possible? | How to use email to message someone on Facebook | facebook;facebook chat | null |
_cstheory.16693 | I have a network flow (with min and max capacities) where the only transport units flowing are within a cycle (of flow value 2). The source of the network does not send out any transport units into any direction and the transport units getting into the sink are all getting sent away directly, so 0 transport units stay there. Now my question is, is such a flow allowed as long as minimium neccesarry flow (given by min capacities) exists and the amount of incoming transport units is equal to the amount of outgoing transport units? Or is a flow network where the source doesnt send out any transport units not permitted? I look forward for any help. | Source sending 0 transport units | graph theory;graph algorithms | You can make it valid depending on your definition of a valid network flow.Let s and t be the source and sink, respectively. Depending on your problem you may no further restrictions of the network flow conservation of t and s. In most definitions there are even no further restrictions on that, as this would just complicate the definition (without helping much).If you want to restrict such superficial network flows in your example, you may however further state that for each edge (u,v) with a flow (i.e. flow function f(u,v)>0) there must be a path from s to u where each edge on the path has a positive flow (i.e. f(e)>0).You may further restrict the flow on s not to be negative and the flow on t not beeing positive, i.e. for sum for all u on f(s,u) must be positive and sum for all u on f(u,t) must be positive or 0.This should then remodel a more intuitive network flow comparable with water flows :).(Note that the restriction: the source must not send out any transport units does not help much to prevent such superficial flows as suggested in the question.)However, typically one assumes that f(t,u)<=0 for all vertices u, i.e. the sink consumes everything which it retrieves. |
_unix.111300 | I know how to use setgid on directories, to enforce that whole directory structure has uniform user:group ownership. Is there a similar way to set the umask for a directory, so that the whole directory structure inherits specific permissions (i.e. 750/640)? | set umask (permissions) similarly as setgid on a directory | permissions;directory;umask;setuid | Here is ugly hack to apply on directory. mount -o loop,umask=027,uid=test /opt/dev_test /home/test/test2Since umask on mount point applied on NTFS or VFAT partition, I had created block device using dd command then formatted with mkfs.vfat and mounted with command as mentioned above. Test Result Inside test2 directory [test@test-server test2]$ touch xyz[test@test-server test2]$ ls -rlt xyz-rwxr-x--- 1 test root 0 Jan 28 23:22 xyz[test@test-server test2]$ umask0002Outside test2 directory[test@test-server test2]$ cd ../[test@test-server ~]$ touch xyz[test@test-server ~]$ ls -rlt xyz-rw-rw-r-- 1 test test 0 Jan 28 23:22 xyz[test@test-server ~]$ umask0002 |
_cs.59981 | I was reading that system f-sub (polymorphic lambda calculus with sub-typing) and I was quite confused with its one checking rule called T-TAPP.This rule as following (ctx denotes the typing context) ctx |- t1 : X<:T11. T12 , ctx |- T2<:T11 ----------------------------------------------- ctx |- t1 [T2] : [X-->T2]T12I could not understand how '[x-->T2]T12' will be used (I know it is substitution). This rule appears on page 10 in the following source.I am looking for two type checking examples, in which above inference rule will be applied and at least one example is a case of type checking failure.Could anyone provide me with concrete examples?Description of system F-sub | System f-sub, how to do type checking? | type theory;type checking;type inference | It would've helped if you mentioned what page that rule appears in.Anyhow, from what I can tell here's an example. t : X <: Animal. X makes noise Cat <: Animal------------------------------------------------------------ t [Cat] : Cat makes noiseThe idea seems to be that t is to be treated as a generic function, or a dependently-typed function, in that for each Animal subtype X, in our example, it gives us a proof t[X] and the rule just formalises this idea.Hope that helps. |
_unix.117941 | I'm trying to add a user with this command on my debian server:#!/bin/bashAPPUSER=test1APPGROUP=test2# Useradduser -c 'uwsgi user' --group $APPGROUP --system --no-create-home --disabled-login --disabled-password $APPUSERHowever it tells me I can only specify one name, but I am only specifying one name as far as I can see.What's going wrong? | adduser: Specify only one name in this mode | linux;bash;shell;debian | null |
_unix.120199 | I have an Asus laptop that has a special key that can be configured to launch any software (at least on Windows).The general question is: how can I detect any key press (globally)?Then, how can I detect when the user press this key? | How to detect global key presses | keyboard shortcuts;keyboard;x server | I typically will use xev to determine the key's scancode and then map it to whatever action I want using either xdotool or XBindKeys.xev$ xev | grep -A2 --line-buffered '^KeyRelease' \ | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'After running the above xev command you'll get a little white window that'll pop up. You'll want to put the mouse over this window and then press the problem key. The name of the key should be showing up in the terminal as you press the various keys.Screenshot mapping the key to something usefulYou can create shortcut key combinations that will launch commands using xbindkeys, for example. I've successfully been using XBindKeys on GNOME 3.8.4 for this very purpose.My use has been modest but I like to create keyboard shortcuts for Nautilus to launch with certain directories opened.ExampleYou'll need to first make sure the packages xbindkeys is installed.Then you'll need to run the following command, one time only, to create a template xbindkeys configuration file.$ xbindkeys --defaults > /home/saml/.xbindkeysrcWith the file created you can open it in a text editor and add a rule like this:nautilus --browser /home/saml/projects/path/to/some/dir Mod4+shift + qWith the above change made we need to kill xbindkeys if it's already running and then restart it.$ killall xbindkeys$ xbindkeysNow with this running any time I type Mod+Shift+Q Nautilus will open with the corresponding folder opened.Using GNOME's Keyboard AppletIf you go through the settings (System Settings Keyboard, select Shortcuts tab and add a new custom shortcut for your browser. Using the steps 1-5 as in the diagram you could map a command to your special key as well. |
_unix.308030 | How do I enable nfs-kernel-server logging? Preferably /file/folder access.Nothing I Google gives me an answer. | how do I enable nfs-kernel-server logging? | logs;nfs | null |
_unix.258402 | I try to retrieve the result from $_ inside a tcsh script itself sourced by another tcsh script (I'll refer to them respectively as the inner and outer script). But $_ is not set with the value I expect (being the last command executed). outer code:#!/usr/bin/tcshset lastCmd0 = ($_)echo ${lastCmd0}echo $0source innerecho enOuterinner code:#!/usr/bin/tcshset lastCmd1 = ($_)echo ${lastCmd1}echo $0echo endInnerHere are the output when calling source outer:source outer tcshsource outer tcshendInnerenOuterQ 1 Why is there two source outer, the second one shoudn't be source inner?Here are the output when calling ./outer:./outer./outerendInnerenOuterQ 2 Why $_ isn't set when sourcing inner ?It seems that $_ is never set again when executing a script, I don't know if it is a normal or not. Anyway if it is not possible to use $_, is there an alternative secure way to get the last command executed inside a script ? | How to properly use $_ inside a tcsh script sourced from another tcsh script? | shell script;tcsh | null |
_unix.378450 | I need to take an iso image from fedora 25 workstation installed on my laptop to reinstall it again including all packages, programs and options which i made it. I tried to use Remastersys but it fails because the current distribution have a size of 13 GB after install all packages and programs which i need. Is there another way to do that? | Make iso file from my current distribution | linux;fedora;iso | null |
_codereview.55634 | K and R Exercise 5-10Write the program expr, which evaluates a reverse Polish expression from the command line, where each operator or operand is a separate argument. For example,expr 2 3 4 + *evaluates2 * (3+4)#include <stdio.h>#include expression_parser.hint parse_polish(int size, char *expression[]){ char *entry; int temp1, temp2; if (expression[1] && ((isdigit(*expression[1]) && isdigit(*expression[2])))) { stack_init(&size, expression); expression++; for ( ; *expression; expression++) { if (isdigit(*(entry = *expression))) push(atoi(entry)); else { switch (*entry) { case '+': push(pop() + pop()); break; case '-': temp1 = pop(); temp2 = pop(); push(temp1 - temp2); break; case '*': push(pop() * pop()); break; case '/': temp1 = pop(); temp2 = pop(); if (!(temp2)) return -1; else push(temp1 / temp2); break; default: return -1; } } } return pop(); } else return -1;}Repository | Basic Reverse Polish CL Parser | c;programming challenge;math expression eval | null |
_unix.319719 | How to list all loadable modules in iptables (given after the -m flag)?This post proposes to list loadable modules withls /lib*/iptables/I don't have this folder with my version (v1.6.0). | How to list iptables loadable match modules | iptables;kali linux;firewall | You got everything described in the linked your post.1) List all available modules::~# ls /lib/modules/`uname -r`/kernel/net/netfilter/2) List all loaded modules::~# cat /proc/net/ip_tables_matchescommentaddrtypemarkconntrackconntrackconntrackrecentrecentaddrtypeudpliteudptcpmultiporticmp |
_cs.10233 | In a comment to Learning F#: What books using other programming languages can be translated to F# to learn functional concepts? Makarius stated:Note that the CPS approach has done great harm to performance in SML/NJ. Its physical evaluation model violates too many assumptions that are built into the hardware. If you take big symbolic applications of SML like Isabelle/HOL, SML/NJ with CPS comes out approx. 100 times slower than Poly/ML with its conventional stack.Can someone explain the reasons for this? (Preferably with some examples) Is there an impedance mismatch here? | The CPS approach has done great harm to performance in SML/NJ; reasoning desired | compilers;functional programming;proof assistants;continuations | At first approximation, there is a difference in locality of memory access, when a programm just runs forward on the heap in CPS style, instead of the traditional growing and shrinking of stack. Also note that CPS will always need GC to recover your seemingly local data placed on the heap. These observations alone would have been adequate 10 or 20 years ago, when hardware was much simpler than today.I am myself neither a hardware nor compiler guru, so as second approximation, here are some concrete reasons for the approx. factor 100 seen in Isabelle/HOL:Basic performance loss according to the first approximation above.SML/NJ heap management and GC has severe problems to scale beyond several tens MB; Isabelle now uses 100-1000 MB routinely, sometimes several GB.SML/NJ compilation is very slow -- this might be totally unrelated(note that Isabelle/HOL alternates runtime compilation and running code).SML/NJ lacks native multithreading -- not fully unrelated, since CPS was advertized as roll your own threads in user space without separate stacks.The correlation of heap and threads is also discussed in the paper by Morriset/Tolmach PPOPP 1993 Procs and Locks: A Portable Multiprocessing Platform for Standard ML of New Jersey (CiteSeerX) Note: PDF at CiteSeerX is backward, pages from from 10-1 instead of 1-10. |
_cogsci.12789 | I have a limited amount of time to analyse strucutural neuroimaging from a sample of patients. My objective is to simply extract volumes from selected fronto-parietal areas.I have no previous knowledge on using SPM nor FreeSurfer. Which should I learn? Which has the fastest learning curve?I usually prefer working with free and open source software in research, so if any of these two is able to plug into R, for example, it would be a plus. | Structural neuroimaging processing with FreeSurfer or SPM? | neuroimaging | SPM and FreeSurfer are similar in the sense that both are morphometry tools.However, they belong to different kinds.SPM implements voxel-based morphometry while FreeSurfer represents surface-based morphometry. It is really difficult to do an objective choice here. I don't know a truly impartial comparison of both methods. As a disclaimer, I should say that I prefer surface-based morphometry, and I would suggest as a comparison for you the PDF An Absolute Beginners Guide to Surface- and Voxel-based Morphometric Analysis and, as it is written by researchers at the home of FreeSurfer, it is somewhat inclined to FreeSurfer's approach. But its references are good for both SPM and FreeSurfer if you want to know them better.Putting morphometric technicalities aside, other aspect setting them apart is that SPM is a MATLAB toolbox, so despite being free, it relies on a non-free software. SPM project, under request, are able to provide a standalone version, but this precludes contributed SPM toolboxes. This can be an option when core SPM is enough for your needs. Regarding FreeSurfer, it can be used on a mostly free platform (not free as in Free Software Foundation's sense but more like what you would find in Ubuntu's based software). FreeSurfer runs natively on POSIX-like operating systems (Linux and MacOS) and the project has virtual machine images for VirtualBox, so Windows users can run a virtualized XUbuntu with FreeSurfer installed.Finally, in terms of integration with R, FreeSurfer project lacks an official integration as it tries to be self contained and includes some statistical analysis capabilities on its own. I have used R to analyze data from FreeSurfer and it wasn't particularly difficult as it is stored in textual form. I heard about an R package, freesurfR I don't know if it is still maintained that could do some things in a two-way fashion.SPM, being aimed at MATLAB, makes an integration with R a somewhat challenging manual task. I heard about an attempt to implement it in R, by means of a package called spmR. When I have used SPM, I had access to a licensed MATLAB and R integration was not that important so I have not insisted. Perhaps it can be done on a more natural way.In the context of my Master's, FreeSurfer was our choice. |
_unix.291843 | In ubuntu, to know the time taken by CPU to run a program we would use time in terminal. Whereas in case of intel GPU, we would use intel_gpu_time. But in case of CentOS time command works. But intel_gpu_time is not working. It is showing command not found. How to know the utilization and time of intel CPU and GPU in CentOS? | How to know the utilization of intel CPU and GPU in Linux? | centos;command line;terminal;intel graphics | null |
_codereview.5565 | I have a private field called individualProfile (camelCase) and I've created a public property called IndividualProfile (PascalCase) on it:private Profile individualProfile;public Profile IndividualProfile{ get { if (individualProfile == null) { individualProfile = ProfileFacade.Instance.GetMainProfileByType ( PortalContext.CurrentUserId, ProfileType.IrnicIndividual ); if (individualProfile == null) { individualProfile = new Profile() { FirstName = string.Empty, Family = string.Empty, Details = new IrnicIndividual() { NationalCode = string.Empty } }; } } return individualProfile; }}I have to use this public property in almost 10 places, so I first check the private member to see if it's null and load it only once, so that I load it only once and I cache it and use it 10 times. Also, since GetMainProfileByType can return null value, I check another time to see if the private member is null or not. If it's null, I simply set it to an empty object, so that I won't bother checking null values when I bind this object to my view.Is this code efficient and maintainable? Is there anything I've overlooked? | Public property, backing up by a private field, with caching and null checking inside | c#;cache | Good thinking about the caching and efficiency. I have two minor suggestions1 - Enforce SRP (single responsibility principal), which basically states (according to Robert C. Martin) that in the world of Clean Code classes must have one reason to change for better maintainability, which is one of the concerns you had in your question. So to apply this to your case, the class that contains the Profile property need not be changed if you decide to change the signature of the ProfileFacade.Instance.GetMainProfileByType method, or maybe choose another method to populate the Profile. So maybe refactoring that code out of the class would be a good idea. Here is what I mean by that:private Profile _individualProfile;public Profile IndividualProfile{ get { if (_individualProfile != null) return _individualProfile; return (_individualProfile = ProfileFacade.Instance.GetIrnicProfile() ?? Profile.NullProfile); }}As you can see in the code snippet I used the short hand null check using the ?? null-coalescing operator.2 - NULL object pattern. Basically define the neutral state (or NULL state) of your object inside the object itself, benefiting from not changing the calling code if ou decide to redefine what the NULL means for your object. In my code snippet I added Profile.NullProfile which is defined as such:public class Profile{ public string FirstName { get; set; } // Other properties here public static Profile NullProfile { get { return new Profile { FirstName = String.Empty, // etc... }; } }}Other than that... Good work! |
_webapps.79474 | I have a Google Apps (for education) email address for work. I am leaving the job, and want to import all of my emails into my personal, regular Gmail account. I attempted to use the tool called Mail Fetcher (Check mail from other accounts using POP3), as well as Import Mail and Contacts. I followed the directions Google gives. However, it just generates an error.Below is the error message I see when I try to use Mail Fetcher:Email address: ln****@t****.org There was a problem connecting to pop.gmail.com Show error details: Server denied POP3 access for the given username and password. Server returned error: malformed command e127mb198161291itbUsername: Password: ******* POP Server: pop.gmail.comPort: 995A different time, the error read as follows:Server returned error: [SYS/TEMP] Temporary system problem. Please try again later. s82mb74850398ioeI have also recieved The server has timed out error. But I have tried this on several different days, and it still isn't working.Could someone help me figure out how to import my mail?Postscript: I successfully imported all of my mail into a different personal Gmail account. I still don't know why the first one didn't work. | Getting [SYS/TEMP] Temporary system problem when importing to Gmail from Google Apps | gmail;google apps;email;google apps email | null |
_unix.219768 | When my Ubuntu 14.04 machine awakes from hibernation, sometimes the network is disable and enabling it does not make it work again. Runningsudo service network-manager restartalone does not solve the problem. But sudo ifconfig wlan0 down && sudo ifconfig wlan0 uptend to solve the problem for a wlan connection. However, it fails to start a PPP connection through 3G or GPRS unless I re-boot. Re-starting the smartphone used as a modem does not help here.How can I re-start all network modules without re-booting?More information:The machine is connected through a USB cable to the smartphone. I am using the network-manager and the nm-applet to start the connection. It's a persistent problem, in earlier versions it was already a problem. I won't enter on the reason why the network gets disabled after hibernation. I believe there's information somewhere about how to deal with this bug though. However, it was not a big issue for me. sudo lsmod | grep pppppp_deflate 12950 0 ppp_async 17413 1 crc_ccitt 12707 1 ppp_asyncsudo lsmod | grep usbusb_serial_simple 17386 2 usbserial 45141 6 usb_serial_simpleusb_storage 66545 1 uas | Restarting all the network in Ubuntu after hibernating | ubuntu;networkmanager;network interface;troubleshooting | null |
_datascience.20216 | I am working on a project where I am trying to detect whether a sound is a sneeze from a human or not. Unfortunately, I don't have a lot of data(around 20 sound samples) and it's expensive to collect gold standard data in this case. I am looking for an innovative technique where this can be accomplished with limited amount of data | How to detect a sneeze without a lot of training data using a machine learning algorithm? | machine learning;python;deep learning;feature engineering;audio recognition | null |
_codereview.124467 | I have been trying to write a BrainF*** program that prints the Fibonacci sequence numbers repeatedly. I was wondering whether this is the most efficient way to do it. I basically repeatedly duplicate two cells into a third cell, and shift one cell forward and repeat.+++++[->----[---->+<]>++.-[++++>---<]>.++.---------.+++.[++>---<]>--.++[->+++<]>.+++++++++..---.+++++++.+[-->+++++<]>-.<] | Fibonacci Sequence in BrainF*** | fibonacci sequence;brainfuck | PortabilityYour first loop immediately subtracts 4 from a cell whose value is 0. It seems like your program is designed to run using the wraparound dialect of Brainfuck, so it would be a good idea to note that in a comment. On the other hand, writing a Fibonacci sequence generator using the 8-bit dialect isn't that useful, because you would overflow after 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233.However, I'm puzzled by why you would want to do any subtraction at all. After all, the Fibonacci sequence involves addition, not subtraction.ReadabilityThere's no need to cram everything on one line. Best practice would be to insert line breaks after . commands and use indentation to show off the loop structure. Add some spaces as well, to let your code breathe.Suggested solution++++++++++ [-> +++>+++++++>++++++++++>+++++++++++>++++++++++++ <<<<<]>> +++ .< ++ .>>> ++ .< +++++ .> ++++ .> + .<<<< .>>> .< - .--- .<< .>> + .> ----- ..--- .<<< + . |
_unix.244469 | To start with, I apologize if this is a painfully obvious/trivial issue, I'm still learning the ins and outs of linux/unix.I work with a few servers that require access via ssh and private key to log into. So, the command is something like this:ssh -i /path/to/key.pem [email protected]'ve created a bash script that let's me just use my own call, access, and just has a basic switch statement for the arguments that follow to control which server I log into. For example, access server1 would issue the appropriate ssh command to log into server1.The ProblemThe ssh call just hangs up and I'm left with an empty terminal that won't accept SIGINT (Ctrl + C) and I must quit the terminal and open it up again to even use it.As far as I can tell, this might be a permissions thing for the private key. Its permissions are currently 600. Changing it to 644 gives me an error that the permissions are too open and exits the ssh attempt. Any advice? | Unable to SSH Using a Private Key Through Bash Script | bash;shell script;ssh;permissions | There is ssh_config, made for this, where you can specify your hosts aliases and keys and store it without creating such hara-kiri as bash scripts to do so. It is basically stored in your ~/.ssh/config in this format:Host host1 Hostname 000.000.000.000 User user IdentityFile /path/to/key.pemand then you can simply call ssh host1to get to 000.000.000.000If you really want to be effective and have even shorter shortcuts, bash alias is more suitable than the bash scripts.alias access=ssh -i /path/to/key.pem [email protected] you really want to use bash script, you need to force ssh to allocate you TTY on remote server using -tt option:ssh -tti /path/to/key.pem [email protected] more tips, you can browse through the manual page for ssh and ssh_config. |
_softwareengineering.303127 | I would like to implement an algorithm but I guess it's a well-known problem and it has been implemented yet, but I am unable to verify that without its name.Here is what I am willing to do :I have a list of assertions that can be either true or falseI have an oracle that can tell me how many assertions are true among a specified list, but which is unable to tell explicitly which ones are valid or notMy goal is to know for each assertion if it is true or falseThe oracle can only check lists with at least a huge number of assertions (it is not possible to test each assertion one by one)My approach is to work on subsets (dichotomy seems to be the most efficient way) on my assertion list to divide it in two parts, and submit both parts to the oracle.After this, I would change the way my assertion list is split and make another test and so on ...For those who know the game Mastermindthis is somehow the idea.Well, is there any official name for this problem and reputed way of solving it ? | What is this algorithm? | algorithms | null |
_unix.158319 | I have a directory of files such as:file.1111111_1.pdffile.1111111_2.pdffile.2222222_1.pdffile.2222222_2.pdffile.1234567_1.pdffile.1234567_2.pdffile.aaaaaaa_1.pdffile.aaaaaaa_2.pdffile.abcdefg_1.pdffile.abcdefg_2.pdfHow can I merge the first 7digit same file name to new file in same directory or subdirectory, It should end up like this:file.1111111.pdffile.2222222.pdffile.1234567.pdffile.aaaaaaa.pdffile.abcdefg.pdf | Shell script to merge files with same names | shell script;files;pdf | null |
_codereview.94308 | The following snippet will return a list containing the words in all of the works of Shakespeare:>>>def shakespeare_tokens(path = 'shakespeare.txt', url = 'http://inst.eecs.berkeley.edu/~cs61a/fa11/shakespeare.txt'): Return the words of Shakespeare's plays as a list import os from urllib.request import urlopen if os.path.exists(path): return open('shakespeare.txt', encoding='ascii').read().split() else: shakespeare = urlopen(url) return shakespeare.read().decode(encoding='ascii').split()>>>tokens = shakespeare_tokens()Problem 1:Here's the idea: We start with some word - we'll use The as an example. Then we look through all of the texts of Shakespeare and for every instance of The we record the word that follows The and add it to a list, known as the successors of The. Now suppose we've done this for every word Shakespeare has used, ever.Let's go back to The. Now, we randomly choose a word from this list, say cat. Then we look up the successors of cat and randomly choose a word from that list, and we continue this process. This eventually will terminate in a period (.) and we will have generated a Shakespearean sentence!The object that we'll be looking things up in is called a 'successor table', although really it's just a dictionary. The keys in this dictionary are words, and the values are lists of successors to those words.Here's an incomplete definition of the build_successors_table function. The input is a list of words (corresponding to a Shakespearean text), and the output is a successors table. (By default, the first word is a successor to '.'). >>> table = build_successors_table(tokens)Problem 2:Let's generate some sentences Suppose we're given a starting word. We can look up this word in our table to find its list of successors, and then randomly select a word from this list to be the next word in the sentence. Then we just repeat until we reach some ending punctuation. (Note: to randomly select from a list, first make sure you import the Python random library with import random and then use the expression random.choice(my_list)) This might not be a bad time to play around with adding strings together as well. >>> construct_sent('The', table)Below is the solution for above 2 problems:#Shakespeare and Dictionariesdef build_successors_table(tokens): table = {} prev = '.' for word in tokens: if prev in table: table[prev].append(word) else: table[prev] = [word] prev = word return tabledef construct_sent(word, table): import random result = '' while word not in ['.', '!', '?']: result = result + word word = random.choice(table[word]) return result + word | Shakespeare and dictionaries | python;hash table | null |
_unix.201900 | If you have gnome-terminal running, and want a new instance of the program, you might think that running gnome-terminal & from a shell would do the trick.Astonishingly, this new instance behaves like some insipid Windows or Mac program; it only sends a message to the existing, running gnome-terminal to create a new window. If this one gnome-terminal process crashes, you lose all of the terminal windows!(Of course, each window has its own shell, which is an independent process, but the actual terminal emulator and its GUI are managed from a single instance of the application.)How can we create independent instances of gnome-terminal, each running in their own process, so that killing that process only destroys the window(s) associated with that process? | Run true multiple process instances of gnome-terminal | gnome terminal | According to man gnome-terminal, the option you're looking for appears to be the confusingly-named --disable-factory Do not register with the activation name server, do not re-use an active terminal.However, the option is apparently removed in more recent releases so should not be relied on. |
_webapps.28094 | Possible Duplicate:Font Search App Is there a web service that is able to guess the font of a text?For example, I have an image shown below:The text is Type text or a website and the text color is #666666. What may be the best guess of the font used?As another example, I have an image shown below:The text is DESIGN PAINTING and the text color is #343434. What may be the best guess of the font used? | Web app that guess the font of an image? | images;font | null |
_webapps.31395 | When I want to view a doc attachment in Gmail, I am automatically sent to my Google Docs to view it. How to stop that and use a default viewer (Word, Foxit, etc.)? | How to opt out viewing doc files in Gmail through Google Docs? | gmail;google;google drive | null |
_unix.101876 | I have always been confused why the file manager in Linux cannot stop applications from opening a single file twice at the same time?Specifically, I want to stop the PDF file reader Okular from opening the file A.pdf again when I have already opened it. I need to get an warning or just show me the opened copy of the file A.pdf.More generally, I would like this to happen with any application, not just Okular. I want to make the document management behavior in Linux the same as in Windows. | If I open the same file twice in Okular, switch to the existing window | kde;open files;file opening;okular | A file manager is responsible for invoking applications to open a file. It has no control over what the application does with the file, and in particular whether the application will open a new window if you open the same file twice.Having the same file open in multiple windows can be useful, for example when you want to see different sections from the same document. So systematically refusing to open more than one window on the same document would be bad. Which behavior is the default is mostly a matter of taste. Some applications default to opening a new window, others default to focusing the existing window.Okular defaults to opening a new window. If you start all instances with okular --unique, then the second time you run that command, it doesn't open a new window (though it doesn't focus the existing window, at least if you aren't running KDE). Note that the first instance must have been started with --unique as well as the second one.Evince, the Gnome PDF viewer, defaults to the behavior you want: if you open the same document a second time, it focuses the existing window. It doesn't have a command line option to open a separate window, you have to do this through the GUI (menu File Open a Copy or Ctrl+N). |
_vi.12258 | In nerdtree as we go deeper filenames are hidden due to smaller width of tree window. Is there a fix to show full filename over the window which is currently highlighted in tree? | Nerd tree show full filename | plugin nerdtree | null |
_reverseengineering.6166 | By analyzing a piece of a trojan code, I have the memset()-function with the following parameters:char *s; //Ollydbg says that it shows to 0012F8A3int c = 0;int n = 512;memset(s, c, n);So, I know what this function does and so on. So my question would be:Is there a way to find out which string is at place 0012F8A3 using Olldbg ? By right-clicking and Go to Expression -> 0012F8A3, I came to a place with the following code lines: 0012F8A3 0000 ADD BYTE PTR DS: [EAX], ALThis line occurs consecutively. And in the stack window of Ollydbg, there is no such a place labeled with 0012F8A3.Can someone help ? | memset() in malware | assembly | null |
_unix.269372 | What happens when writing to a device driver?For example: echo some text > /proc/device_driverI'm guessing that echo has a write-call that somehow invokes the write-function in the driver. What are the steps from the echo-function to the drivers write function? | What happens when writing to a device driver? | linux;devices;system calls | As explained in the The Linux Kernel Module Programming Guide (5.2. Read and Write a /proc File), the kernel calls a function associated with the driver during the driver's initialization to read the data from userspace into the kernel.The echo program does not know anything special about the kernel; the kernel does all of the work.Further reading:How to read/write from/to a linux /proc file from kernel space?How to write a kernel module for Linux |
_cs.9642 | I often read that deciding whether or not a number $r$ is a quadratic residue modulo $n$ is an interesting (and hard) problem from number theory (especially if $n$ is not prime). I am looking at the following special case of this problem: Let $p$ and $q$ be two different prime numbers and $n:=pq$. Given $r$ between $1$ and $n$. Decide if there exists an $x\in\mathbb{Z}/n\mathbb{Z}$ such that $x^2\equiv r\pmod{n}$.My question is: The functional version of this problem i.e. Find such an $x$ as above yields an randomized algorithm for integer factoring. So it is very interesting for practical reasons like breaking RSA. Is there any such result for the decision version of this problem? If not, what are typical problems that let us think that deciding quadratic residuosity it is a hard problem?And furthermore, is the special case I'm looking at really a special case? Or can I solve the general case with an arbitrary $n$ with an oracle for the decision problem above? | Quadratic residue and integer factoring | cryptography;number theory | Tibor Jager and Jrg Schwenk show in The Generic Hardness of Subset Membership Problems under the Factoring Assumption that factoring reduces to distinguishing quadratic residues from numbers with Jacobi symbol 1, for generic ring algorithms. These are algorithms whose only API to integers are ring operations (addition, multiplication, subtraction, division), equality comparisons and generating a random element. They also show that the Jacobi symbol, which can be efficiently computed in polynomial time, has no efficient generic ring algorithm. So their result doesn't answer your question, other than implying that the answer isn't known. |
_softwareengineering.91799 | If 'explicit is better than implicit', why aren't there explicit access modifiers in Python: Public, Protected, Private, etc.? I know that the idea is that the programmer should know what to do through a hint - no need to use 'brute force'. But IMO 'Encapsulation' or 'information hiding' isn't just to keep people out, it's a question of organization and structure: your development layers should have self-defining, clearly delimited scopes and borders, just like physical systems do. Can someone please help me out here with a solid explanation as to why access restrictions are implied rather than explicit in Python, a language that otherwise seems close to perfect?Edit: So far I have seen 3 proposed answers, and I realized that there are 2 parts to my question:Why aren't there key words, for example private def myFunc(): dostuff....instead of IMO the ugly and hard to type underscores. But that's not the important point.More importantly: Why are these access modifiers only 'recommendations' or hints and not enforced. It will be hard to change later? It's very simple to change 'protected' to 'public' - and if you have a convoluted inheritance chain that makes it difficult, you have a poor design - your design should be refined rather than relying on a language feature that makes it easy to write poorly structured code. When access modifiers are enforced, your code is automatically compartmentalized - you KNOW that certain segments are out of scope so you don't have to deal with them except if and when it's necessary. And, if your design is no good and you find yourself constantly moving things into and out of different scopes, the language can help you to clean up your act.As much as I love Python, I'm finding this 2nd point to be a serious deficiency. And I have yet to see a good answer for this. | Why aren't there explicit access modifiers in Python: | python;access modifiers | Explicit is better than implicit is only one of the maxims in Python's design philosophy. Simple is better than complex is there too. And, although it's not in the Zen of Python, We're all consenting adults here is another.That second rule is perhaps the most important here. When I design a class, I have some idea of how it's going to be used. But I can't possibly predict all possible uses. It may be that some future use of my code requires access to the variables I've thought of as private. Why should I make it hard - or even impossible - to access these, if a future programmer (or even a future me) needs them? The best thing to do is to mark them with a warning - as Joonas notes, a single underscore prefix is the standard - that they are internal, and might change; but forbidding access altogether seems unnecessary. |
_unix.89536 | I have this output I'd like to sort numerically by port (starting at the 35th column):tcp 0 0 192.168.0.210:110 0.0.0.0:* LISTEN 3385/dovecottcp 0 0 192.168.0.210:143 0.0.0.0:* LISTEN 3385/dovecottcp 0 0 192.168.0.210:22 0.0.0.0:* LISTEN 2223/sshdtcp 0 0 192.168.0.210:25 0.0.0.0:* LISTEN 3589/mastertcp 0 0 192.168.0.210:443 0.0.0.0:* LISTEN 2037/apachetcp 0 0 192.168.0.210:587 0.0.0.0:* LISTEN 3589/mastertcp 0 0 192.168.0.210:80 0.0.0.0:* LISTEN 2037/apache# ^# Sorted at this column (#35)So that the new output looks like this (lowest port first):tcp 0 0 192.168.0.210:22 0.0.0.0:* LISTEN 2223/sshdtcp 0 0 192.168.0.210:25 0.0.0.0:* LISTEN 3589/mastertcp 0 0 192.168.0.210:80 0.0.0.0:* LISTEN 2037/apachetcp 0 0 192.168.0.210:110 0.0.0.0:* LISTEN 3385/dovecottcp 0 0 192.168.0.210:143 0.0.0.0:* LISTEN 3385/dovecottcp 0 0 192.168.0.210:443 0.0.0.0:* LISTEN 2037/apachetcp 0 0 192.168.0.210:587 0.0.0.0:* LISTEN 3589/master# ^# Sorted at this column (#35)I've played around with all different forms of |sort, including:|sort -n # <- I thought this would work|sort -nk35|sort -nk35,37Etcetera, etcetera. Maybe I'm misunderstanding the purpose of the -k flag? Or maybe those colons are messing things up? | Help with the sort command (numeric) | sort | sort expects whitespace separated fields. To get it to sort on the port, you should change the field separator:sort -t: -nk2 fileHere, I am telling sort to take : as the field separator. Therefore the first characters of the second field are the port number and it sorts as you want it to:$ sort -t: -nk2 filetcp 0 0 192.168.0.210:22 0.0.0.0:* LISTEN 2223/sshdtcp 0 0 192.168.0.210:25 0.0.0.0:* LISTEN 3589/mastertcp 0 0 192.168.0.210:80 0.0.0.0:* LISTEN 2037/apachetcp 0 0 192.168.0.210:110 0.0.0.0:* LISTEN 3385/dovecottcp 0 0 192.168.0.210:143 0.0.0.0:* LISTEN 3385/dovecottcp 0 0 192.168.0.210:443 0.0.0.0:* LISTEN 2037/apachetcp 0 0 192.168.0.210:587 0.0.0.0:* LISTEN 3589/master |
_codereview.6143 | For a project I'm working on, I need to compare version strings where:version strings are composed only of numbers and periodsversion strings are made up of an arbitrary number of segments (major.minor, manjor.minor.build, etc)1.0 is equivalent to 1.0.0, etc.Please provide feedback on performance considerations or style.Here's my shot at it:public class VersionStringComparer : IComparer<string>{ public int Compare(string x, string y) { if (x == y) return 0; var xparts = x.Split('.'); var yparts = y.Split('.'); var length = new[] {xparts.Length, yparts.Length}.Max(); for (var i = 0; i < length; i++) { int xint; int yint; if (!Int32.TryParse(xparts.ElementAtOrDefault(i), out xint)) xint = 0; if (!Int32.TryParse(yparts.ElementAtOrDefault(i), out yint)) yint = 0; if (xint > yint) return 1; if (yint > xint) return -1; } //they're equal value but not equal strings, eg 1 and 1.0 return 0; }}And two quick unit tests (using the Should.Fluent library: [TestMethod] public void VersionStringComparerSortsMajorAndMinorVersionString() { var versions = new[]{1.5,1.0,2.0,1.0}; var versionStringComparer = new ReleaseGateway.Util.VersionStringComparer(); var sorted = versions.OrderBy(x => x, versionStringComparer).ToArray(); var expected = new[] {1.0, 1.0, 1.5, 2.0}; sorted.Should().Equal(expected); } [TestMethod] public void VersionStringComparerSortsArbitraryRadixVersionStrings() { var versions = new[] { 1.5.4, 1.7, 1.0, 1,1.4 }; var versionStringComparer = new ReleaseGateway.Util.VersionStringComparer(); var sorted = versions.OrderBy(x => x, versionStringComparer).ToArray(); var expected = new[] { 1.0, 1, 1.4, 1.5.4, 1.7 }; sorted.Should().Equal(expected); } | VersionString (eg 1.0.2) IComparer algorithm | c#;algorithm;linq;unit testing | null |
_scicomp.11088 | I am looking for finding the velocity distribution using Principle of Maximum entropy when applied to Tsallis entropy.Tsallis entropy is defined as:$$S_{T} = \frac{1}{q-1}\left(1-\int{f(p)^qdp}\right)$$I have the following constraints:$$\int{f(p)dp}=1\\\int{pf(p)dp}=0\\\int{p^2f(p)dp}=1\\\int{p^3f(p)dp}=0\\$$Using these constraints and incorporating Lagrange multipliers, the equation of ${S_{T}}$ becomes:$$S_{T} = \frac{1}{q-1}\left(1-\int{f(p)^qdp}\right) + \lambda_0 \left(\int{f(p)dp}-1\right) + \lambda_1 \left(\int{pf(p)dp}\right) + \lambda_2 \left(\int{p^2f(p)dp-1}\right)+ \lambda_3 \left(\int{p^3f(p)dp}\right)$$Taking variation of ${S_{T}}$ with respect to ${f(p)}$ and equating it to 0, the distribution function becomes:$$f(p)=\left[\left(\frac{q-1}{q}\right)\left(\lambda_0+\lambda_1p+\lambda_2p^2+\lambda_3p^3\right)\right]^{\frac{1}{q-1}}$$The entire problem then boils down to solving for the Lagrange multiplier. However, I am unable to solve this problem using Newton-Raphson. Can anyone give me some pointers as to how to proceed with solving this problem. My MATLAB Newton Raphson code incorporating first three constraints is shown below. Any help would be appreciated:%Here we use Newton_Solverclear all;clc;%Initial Trialslambda(1,1) = -1.5;lambda(2,1) = 0.0;lambda(3,1) = 0.09;lambda(4,1) = 0.09;ll = -5;ul = 5;steps = 10000;iter = 1500;i = 0;q = 1.5; %Tsallis q indexwhile(i<iter) func_val = zeros(4,1); Jacobian_mat = zeros(4,4); avg_v0 = 0.0; avg_v1 = 0.0; avg_v2 = 0.0; avg_v3 = 0.0; avg_v4 = 0.0; avg_v5 = 0.0; avg_v6 = 0.0; for(j=1:steps) p = ll+(ul-ll)*j/steps; temp = (lambda(1) + lambda(2)*p + lambda(3)*p*p + lambda(4)*p*p*p)*(q-1)/q; temp = temp^(1/(q-1)); temp = temp*(ul-ll)/steps; func_val(1) = func_val(1) + temp; func_val(2) = func_val(2) + temp*p; func_val(3) = func_val(3) + temp*p*p; func_val(4) = func_val(4) + temp*p*p*p; temp1 = lambda(1) + lambda(2)*p + lambda(3)*p*p + lambda(4)*p*p*p; temp1 = temp1^((2-q)/(q-1)); temp1 = temp1*((q-1)/q)^(1/(q-1))/(q-1); temp1 = temp1*(ul-ll)/steps; avg_v0 = avg_v0 + temp1; avg_v1 = avg_v1 + temp1*p; avg_v2 = avg_v2 + temp1*p*p; avg_v3 = avg_v3 + temp1*p*p*p; avg_v4 = avg_v4 + temp1*p*p*p*p; avg_v5 = avg_v5 + temp1*p*p*p*p*p; avg_v6 = avg_v6 + temp1*p*p*p*p*p*p; end Jacobian_mat(1,1) = avg_v0; Jacobian_mat(1,2) = avg_v1; Jacobian_mat(1,3) = avg_v2; Jacobian_mat(1,4) = avg_v3; Jacobian_mat(2,1) = avg_v1; Jacobian_mat(2,2) = avg_v2; Jacobian_mat(2,3) = avg_v3; Jacobian_mat(2,4) = avg_v5; Jacobian_mat(3,1) = avg_v2; Jacobian_mat(3,2) = avg_v3; Jacobian_mat(3,3) = avg_v4; Jacobian_mat(3,4) = avg_v5; Jacobian_mat(4,1) = avg_v3; Jacobian_mat(4,2) = avg_v4; Jacobian_mat(4,3) = avg_v5; Jacobian_mat(4,4) = avg_v6; func_val(1) = func_val(1) - 1.0; func_val(2) = func_val(2) - 0.0; func_val(3) = func_val(3) - 1.0; func_val(4) = func_val(4) - 0.0; Jacobian_inv = Jacobian_mat^(-1); lambda = lambda - Jacobian_inv*func_val*1.0; Disp_val = ['Step is: ',num2str(i), ' Lambda 1 values:', num2str(lambda(1,1))]; Disp_val1 = ['Step is: ',num2str(i), ' Lambda 2 values:', num2str(lambda(2,1))]; Disp_val2 = ['Step is: ',num2str(i), ' Lambda 3 values:', num2str(lambda(3,1))]; Disp_val3 = ['Step is: ',num2str(i), ' Lambda 4 values:', num2str(lambda(4,1))]; Disp_val4 = ['Step is: ',num2str(i), ' AVG 1 values:', num2str(func_val(1) + 1.0)]; Disp_val5 = ['Step is: ',num2str(i), ' AVG 2 values:', num2str(func_val(2) + 0.0)]; Disp_val6 = ['Step is: ',num2str(i), ' AVG 3 values:', num2str(func_val(3) + 1.0)]; Disp_val7 = ['Step is: ',num2str(i), ' AVG 4 values:', num2str(func_val(4) + 0.0)]; disp(Disp_val); disp(Disp_val1); disp(Disp_val2); disp(Disp_val3); disp(Disp_val4); disp(Disp_val5); disp(Disp_val6); disp(Disp_val7); disp(' '); i = i+1;end | Constrained Minimization of Tsallis Entropy | algorithms | null |
_cstheory.32171 | In paper 'On vanishing of Kronecker coefficients' here in http://arxiv.org/pdf/1507.02955v1.pdf, it is showed that deciding positivity of kronecker coefficients is in general NP hard. However there is a caveat which states that only positivity of 'rectangular Kronecker coefficients' is needed in GCT. What is the implication to GCT if this also turns to be NP hard? A related question is what is consequence to GCT if there is no general positive formula akin to one for special case of LR coefficients? | A question on GCT | cc.complexity theory | Even if deciding positivity of Kronecker coefficients is NP-hard, or even if there is no general positive formula for them, it is still quite possible for GCT to work. Even under the preceding assumption, it is still possible that there is a positive formula (and even a polynomial-time decision procedure) for some of the rectangular Kronecker coefficients. If one could find such a formula, and then show that the corresponding irreducible representations appear with nonzero multiplicity in the coordinate ring of the orbit closure of an appropriately-sized permanent, it would still prove the (Strong) Permanent versus Determinant Conjecture.Update 8/30/15: I should add that, independent of positive combinatorial formulae, I think the geometric approach to complexity, as in GCT, is a very useful way to understand the structure of complexity classes, and using representation theory where it naturally arises (such as here) is always a Good Idea. Landsberg's work in this area is notable in this direction (i.e., using geometric techniques combined with representation theory, even in the absence of positive combinatorial formulae). [end update][Now back to positive combinatorial formulae...] Even if more and more Kronecker coefficients end up being NP-hard to decide their vanishing, or if there isn't a positive combinatorial formula for them, (a) it is simply a testament to just how hard these problems are (after all, while GCT gets around the known barriers, it is still aiming at proving some very hard open problems), and/or (b) suggests where to narrow one's focus in order to get GCT to work (e.g., as above).Also, although NP-hardness is bad news in general, it is not necessarily the end of the road. For example, although Hamiltonian Cycle is NP-hard, there are still lots of theorems and theoretical understanding around Hamiltonian cycles. The NP-hardness just leads one (or at least, me) to expect that there won't ever be a complete theory of Hamiltonian cycles. But one doesn't need such a complete theory of Kronecker coefficients to prove a lower bound via GCT - one just needs one family of representations that vanishes on the orbit closure of the determinant but not on the orbit closure of the permanent.(This answer also applies to the recent paper of Kahle and Michalek which shows that there are families of plethysm multiplicities that are not given by the number of integer points in a natural family of polytopes.) |
_computergraphics.4919 | I have a series of MRI images. I want to build a 3D model out of it, which not only presents the surface, but also contains the inside structures. What kind of photogrammetry based method can realize that? | How to build a 3d model from 2d pictures | 3d;algorithm;computational geometry | null |
_softwareengineering.194353 | I am wondering about how much time Google Summer of Code typically takes. I do have an internship lined up for this summer, but GSoC seems like quite an awesome experience. I also really want to get into Open Source development. It states in the FAQ that it's not a good idea to attempt both, but it doesn't give any specifics. I'm wondering if it's feasible to do both. Or would I be better off by trying to work on open source in my spare time?Thanks for all your help! | Internship along with Google Summer of Code? | open source;google;internship | Having done both an internship and GSOC, I'd agree with the FAQ that it is not a good idea to attempt to do both at the same time. |
_bioinformatics.676 | Are there any advantages to learning Biopython instead of learning Bioperl?Ideally, we would learn both, but someone starting out in bioinformatics may have to choose what to learn first depending on the kind of problems actually encountered.Are there problems for which Biopython is better than Bioperl (or vice-versa)? | For what bioinformatics tasks is Biopython more adapted than Bioperl? | biopython;perl | null |
_webapps.94745 | In a Google Spreadsheet, I have a column of task IDs, with values like T1, T2, T13 (i.e. all values starting with the same text). I would like to use a formula on the values of these cells (for conditional formatting). Can I somehow apply it only to the numeric part of the value, i.e. 1, 2, 13? Something like =max((A1:A100)[2:end])? | Apply formula to a numeric part of cell value | google spreadsheets | null |
_softwareengineering.253897 | I'm making an API that will return data in JSON.I also wanted on client side to make an utility class to call this API.Something like :JSONObject sendGetRequest(Url url);JSONObject sendPostRequest(Url url, HashMap postData);However sometimes the API send back array of object [{id:1},{id:2}]I now got four choices ():Make the method test for JSONArray or JSONObject and send back an Object that I will have to cast in the callerMake a method that returns JSONObject and one for JSONArray (like sendGetRequestAndReturnAsJSONArray)Make the server always send Arrays even for one elementMake the server always send Objects wrapping my ArrayI going for the two last methods since I think it would be a good thing to force the API to send consistent type of data.But what would be the best practice (if one exist).Always send arrays? or always send objects? | API always returns JSONObject or JSONArray Best practices | java;api;json | That should depend on what it is actually doing. If it is retrieving one or more objects, it makes logical sense to always return an array containing the results, even if it is an array with only one element. This makes it easy to then do a foreach on the returned array, for example.If the format of the request causes it to return completely different kinds of data though, it would be clearer to have a different method for each context.How this would work as a method is a good analogy. If you have some collection foo, and a function searchFoo that searches the collection for elements, you are not going to write it such that it returns an element if only one element matches, and otherwise it returns a list of elements. Either it always only finds one elements (like if the search is based on a unique key) in which case it also returns an object of the appropriate type, or it will find a variable number of elements in which case it will always return a list, regardless of how many elements were found. |
_unix.316707 | I use rsync to copy my files to a external usb hdd:rsync -av --max-size=4G --exclude *.ini --exclude Thumbs.db --delete /sourcefiles/ /destination/This works so far, but when I run the command a second time, the same files are copied again. This should not be the case since the were copied a few moments ago. | rsync copies identical files | rsync;fat32 | null |
_webmaster.76375 | I have recently started with a small company that is having pretty bad problems with mail ending up in peoples junk folders. They used to send large bursts of newsletters from the one address every 2 months, but I have now convinced them to stop, and use MailChimp.Ive checked our domain to make sure we are not Blacklisted anywhere and chased up with our mail service provider that we have reverse DNS and SPF set up.I have started including Opt-Out options in newsletters to reduce the chance of more people marking them as junk. But the problem seems to be persisting and we are not really in a position to keep on going like this, as several important mails are not arriving, even after people add us to their contacts.So. onto the actual questions! Is there anything else that I can do to quickly repair our reputation, or reduce the risk of being flagged as spam?Also, is there any credence to the suggestion to opt for a business package like those google offer? Would they make any difference to the problem?Sorry for the wordy question! | Problems with bad mail reputation | spam;reputation;mail | Most anti-spam solutions (whether hosted or in-house, might be installed software or hardware appliance for example) have an element of learning to them - for example if they have received what looks like spam then the anti-spam systems will have a reputation against your SMTP server's IP address and/or domain name and unfortunately it is very difficult to have a reputation improved upon with systems like this.Your options as I see them are (these could work well in combination!):Ask your customers to white-list your domain name to ensure they receive your emails (not ideal or practical really in my opinion);Register a new domain name and start using that for your email instead, redirecting messages from the old domain to your new one. For example, if you had an address [email protected], you might use [email protected]. A domain that has not been used for email before will not have historical spamming reputations on anti-spam systems.Change your sender IP address. Most Internet Service Providers (ISPs) can change your IP address upon request, especially if you are a business - or you could request an additional IP address if they won't and use that instead, or you could use an SMTP relay service (there actually are some companies out there that offer this). If your email server is a hosted solution rather than on your own premises then you could change provider and will therefore end up with a new sender IP address.Ensure that emails you send out do not appear to be like spam due to lack of appropriate email signature, very poor spellings, use of common spam phrases or words etc.While not all anti-spam systems will acknowledge newer technology, as @Martijn has suggested you should ensure you have an appropriate SPF record setup for your domain which allows mail only from your approved SMTP server sender IP addresses. Using DKIM may help too.When any of your customers tell you that your messages are getting marked as Spam ask them to send you an MX Toolbox report so that you can investigate why and address the root cause. Leaving issues unaddressed over time can leave you with a poor reputation. |
_unix.90262 | Does anyone know how (if it is possible) to change Android files stored in root directory, particularly logo.rle? I want to change my boot splashscreen, changing the file, which is stored in /. I have managed to change the file with root browser. But after phone reboot, all files in / and /system revert back to their original state.I know from embedded boards, that you have to execute saveenv command, so that the changes you make remain after reboot...but Android doesn't have that command, even with buisybox installed :( | Changing Android files in root directory | root;embedded;android | null |
_unix.223458 | This is frustrating, I try:service crond statusAnd get this:Redirecting to /bin/systemctl status crond.servicecrond.service - Command SchedulerLoaded: loaded (/usr/lib/systemd/system/crond.service; enabled)Active: active (running) since Thu 2015-06-25 07:44:35 UTC; 1 months 21 days agoMain PID: 2557 (crond)CGroup: /system.slice/crond.service2557 /usr/sbin/crond -nAug 14 21:18:37 li958-202.members.linode.com crond[2557]: 2015-08-14 21:18:37 1ZQMLV-0004ER-HX User 0 set for local_delivery transport is on the neve...ers listAug 14 21:18:37 li958-202.members.linode.com crond[2557]: 2015-08-14 21:18:37 1ZQMN3-0004ST-Nr User 0 set for local_delivery transport is on the neve...ers listAug 15 21:18:19 li958-202.members.linode.com crond[2557]: 2015-08-15 21:18:19 1ZQip4-0005iq-BH User 0 set for local_delivery transport is on the neve...ers listAug 15 21:18:19 li958-202.members.linode.com crond[2557]: 2015-08-15 21:18:19 1ZQiqJ-0005va-CF User 0 set for local_delivery transport is on the neve...ers listAug 16 00:35:01 li958-202.members.linode.com crond[2557]: (CRON) OPENDIR FAILED (/var/spool/cron): No such file or directoryAug 16 01:49:57 li958-202.members.linode.com systemd[1]: Started Command Scheduler.Aug 16 01:50:09 li958-202.members.linode.com systemd[1]: Started Command Scheduler.Aug 16 02:08:01 li958-202.members.linode.com crond[2557]: (CRON) INFO (running with inotify support)Aug 16 02:09:01 li958-202.members.linode.com crond[2557]: (CRON) INFO (running with inotify support)Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.Hint: Some lines were ellipsized, use -l to show in full.Then I have tried all these per searching on SO and elsewhere:kill -1 2557kill -HUP 2557service crond stopNOTHING works. Can anyone help with this? | I cannot kill crond - trying to stop cron service | cron;kill;start stop daemon | null |
_webapps.89237 | This seems to be a trivia question, but I can't find a button to add a movie into my watch list, in that movie page. The only button I can find is in the recommendation box:I know that I can add a movie through my watch list page, but that's not what I'm looking for: | How to add a movie to my watchlist in IMDb, in the movie page? | imdb | If it is the new site of IMDB then the Add to watchlist icon is just in front of the movie title. See the image below: |
_unix.10548 | I install GRML on my USB disk with the grml2usb tool. But when I boot from the USB, it first boots to a blank screen with boot: text on it. I must type the boot options myself to boot the system. I want it to boot to the system automatically. How can I do it? I am new to GRML, and I checked their wiki, but did not find the solution. | GRML will not boot automatically | linux;boot;live usb;grml | Finally I found the problem is caused by syslinux.You must have the right version to work with grml2usb. The best bet is to execute the grml2usb from the live system boot from the ISO. It must work, or blame the grml team :) |
_unix.71667 | While reading about the Linux kernel I came across the notion of kernel data structures. I tried to find more information via Google, but couldn't find anything.What are kernel data structures? What are their requirements, usage, and access?What's the organization of data structure inside the kernel?Examples of kernel data structures might be file_operations or c_dev. | What are kernel data structures? | linux;kernel | The kernel is written in C. Kernel data structures would just refer to various formations (trees, lists, arrays, etc.) of mostly compound types (structs and unions) defined in the source, which C code is normally filled with stuff like that. If you don't understand C, they will not be meaningful to you.Data structures structure the storage of information in memory or address space. There is nothing particularly special about the ones used by the linux kernel. Some of them can/must be used if you are writing a kernel module, but their use is completely internal to the kernel. Kernel memory is only accessed by the kernel and it's structure has no relevance to anything else. |
_softwareengineering.187849 | Been writing code since about 18 years now. Lately, I've got into the habit of not indenting elses and when I look at the code it does worry me a bit mostly that someone who might look at the code might cry foul.The snippet below explains the need for the styleif(condition) { ...} //1 if(condition) { // Don't want this second block to be entered unnecessarily ...}So I put an else where the comment labelled 1 isif(condition) { ...} elseif(condition) { ...}Putting an else there helps maintain readability especially when forgetting to put one there doesn't necessarily break anything. What I'm uneasy with is that it doesn't strictly follow conventions (Sun's in this case) in two different ways - 1) proper indentation 2) having an open brace after the elseI guess what I'm trying to do is prevent having massive indents which really makes a difference in blocks that have a lot of conditions - 5 or more although only three are showcased below. if(condition) { ...} else { if(condition) { ... } else { if(condition) { ... } else { ... } }}I find it a lot neater to have the else unindented and without a brace following. What are your thoughts? | Unindented elses | java;coding style | I usually see this solved by not putting the if inside a code block if it's the only statement in the else-part and putting the if one the same line.This effectively emulates the elseif or elif of other languages.if (condition1) { ...} else if (condition2) { ...} else { ...}This way there's no useless indentation and every code block has its braces, as it should be.I also never had any code quality tool nag at me for this, so I assume it's widely accepted. |
_webmaster.61766 | We sometimes send out links to one part of our site that is password protected, at the moment what we are doing to check if the recipient clicks on it, is to not give them the password and when they email back asking 'whats the password ?' we know they have tried to look at it and are keen to look at it.There are several problems with the above, is there a better way we can track this ? We use Google Analytics on our site which would currently track 'direct' visit from the email but really what id like to be tracking is to be able to set a value, perhaps in the query string something like example.com/?=sam and then i can see that the /?=sam link was clicked on, I would only send out this link to sam so I know it was he who clicked it. Obviously they could remove the query string, but I plan to hide it by using a hyperlink with anchor text. Is there something like that in Google Anaytics or another way to do it? | Tracking clicks to my site from a link in an email (normal email, not a newsletter) using Google Analytics | google analytics;email;tracking;click tracking | You can build campaign tracking with this Google Analytics tool. However, having it trackable at an individual level is a contravention of Google Analytics' ToS. You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, email address or billing information), or other data which can be reasonably linked to such information by Google.Even without that limitation, you have the additional consideration of legality in whatever jurisdictions are concerned. |
_opensource.5648 | I currently have a project which I'm planning in the not too distant future to open source on GitHub. The question I have is regarding how open source projects are released if they have encryption keys. Basically, the project consists of an android app (not being open sourced) and a PHP API. The PHP API can potentially send/receive confidential information such as authentication details. Obviously, the API should be run under HTTPS to offer some security, but on top of that, the android app, will encrypt all the data, then once encrypted and it sends the request to the PHP API. The PHP API decrypts the request and then generates a response, which is then encrypted and the response is sent back to the android app to decrypt and process. My question is, the encryption between the android app and the PHP API has a hard coded encryption key (I'm using 256 AES encryption). It doesn't seem right that this key is kept in the open source code as then if someone managed to find a way to do a man in the middle attack between the app and the API, they have the key, potentially exposing the user authentication details. What's the recommended way for doing this, should I just not offer encryption, and just rely on the user using HTTPS, and if they don't, it's their problem or is there an alternative method I could use. | Open Source Projects with Encryption Keys | github;source code;api;cryptography | You should not include keys in your open source project. You should include a file location where your code expects a key, and the user (or an included utility) creates or copies their own unique key into the expected location. Imagine a thousand people download your project and stand up their own versions of your open-source server -- what's the point of having encryption if all of those servers are simply using the same key?Including one specific encryption key is like drawing up a blueprint of a house that includes the specific tooth-sizes of the lock and key to the front door. It's completely the wrong approach: whenever a builder constructs a house from your blueprints, the builder should grab a totally new, unique lock and key and put that in the front door. It's not necessary that your blueprints specify an exact lock in your blueprints. It's merely important that the house has a lock; each separate construction project will supply its own lock.Your own deployment of your open source server will have its own unique key, just like all other deployments that you don't control will have their own unique keys. The public, open-source project itself should have no key, because the entire point of a secret key is to keep it local to a particular deployment.That said, using encryption within HTTPS seems unnecessary. HTTPS is sufficient to keep the user's traffic private and unaltered -- that's the exact scope what HTTPS was designed to do. As for if they don't [use HTTPS] its their problem, simply don't offer an unencrypted HTTP service on your server.Are you hoping to implement this as a kind of DRM to keep the traffic secret from the original user? If so, this will work about as well as any DRM, which is to say: it will work well enough for users who don't care about it, and not well enough to keep out tech-savvy users. |
_softwareengineering.258431 | What does exactly make reading from the process memory a pure operation? Suppose I created an array of 100 integers in the global memory and then took the 42th element of this array. It is not a side effect, right? So why is reading the same array of 100 integers from a file a side-effect? | Why is reading from memory not a side-effect but reading from a file is? | functional programming;side effect | If the memory you access can change, then it is indeed a side effect.For example, in Haskell, the function to access a mutable array (IOArray) has typeIx i => IOArray i e -> i -> IO e(slightly simplified for our purposes). While accessing an immutable array has typeIx i => Array i e -> i -> eThe first version returns something of type IO e which means it has I/O side effects. The second version simply returns an element of type e without any side effects.In case of accessing a file, you simply cannot know at compile time whether the file will ever change during a run of the program. Therefore, you have to always treat it as an operation with potential side effects. |
_unix.163548 | I have a strange problem, when I connect an old printer (HP, Epson, at last 4 years old printers) on my linux embedded board, when I type the command echo test > /dev/usb/lp0 it prints correctly. However if I connect a new printer (HP deskjet 1510 all in one series) when I type this command it do nothing and I don't know why. | Cannot print text via /dev/usb/lp0 on recent printers | usb;printer;parallel port | null |
_softwareengineering.348633 | This question is an extension of my previous question - Counting function points In a form meant for maintaining a business entity we provide functionality to add/update/delete an entity. In order to update an entity we first pull it using some identifying fields and then update it. Should we count such entity as both External Input and External inquiry? Moreover same entity is output on form when pulled for update so it is an output as well. Are there any specific guidelines for counting transaction functions for such forms? | External Input Vs External Inquiry | estimation;fpa | null |
_hardwarecs.6344 | I'm looking for an All-in-One device. It should have Win10 Pro installed. I would prefer an Intel i5 or i3 processor.The special requirement is the wall mount. The only device I found weights 12kg. Maybe someone knows a lighter device. It should have VESA for an easy installation.What is your budget? 400-900What are you planning on doing with it (video editing, gaming, running some server applications, etc)? Casual Office work and using RDP.How big should the screen be, and what resolution would you like? 20-24 | Intel i3/i5 AIO with wall mount | wifi;windows;all in one | null |
_softwareengineering.301393 | In our game project we currently have 2 teams that work in 2 week iterations. In the past we've repeatedly had issues with larger features (bad planning/estimates, unforseen issues before code freeze causing the stories to not getting closed, etc), and we've discussed those problems in many retrospectives.Since the features we're supposed to implement are not getting any smaller or easier (actually quite the opposite), we've been thinking about ways to help us reduce the risk of each iteration. One such idea I had, was going with a setup similar to what ArenaNet does with Guild Wars 2:[...] And theyre all staggered, so even though we ship every two weeks, the development time for any one of these releases is around four months, its just that its a smaller team working for an extended period of time which allows them to give it the level of polish that players have come to expect. But it is intense! [...]The basic idea was to stick with the 2 week release cycle, but move the teams out of phase with each other, so that each individual team would have a total of 4 weeks to work on content. So basically, the setup would change from this:to this:Of course, the releases would be bigger than before, but at a first glance it seems at least somewhat beneficial:More time to react to unforseen issues (bugs, system failures, bus factor, ad-hoc design changes, ...) without endangering the whole sprintQA could focus on one team/feature/release at a time, instead of having to check everything from both teams at onceAbility to work on larger features without having to chunk/split them into artificial segments to fit the sprintsNow I wonder if this was actually a good idea, or if I'm missing something obvious and it would just screw up everything. Are there any other resources on this topic? Are async scrum teams workable, or is it generally just a bad idea? | What are the possible/likely pitfalls of having async scrum teams? | scrum;teamwork | In the past we've repeatedly had issues with larger features (bad planning/estimates)If you encounter planning/estimation problems just for two week sprints in advance, do you really believe this will get better if you now have to estimate your team's work for four weeks instead of two? Honestly, I think this will make things worse, not better (and it does not make a difference if your teams work synchronously or not).Ability to work on larger features without having to chunk/split them into artificial segmentsThe need for splitting big features into smaller slices is IMHO a strength of the process - if you sacrifice this, your planning/estimation will become worse, your testing cycles will get longer and your ability to control the process will decrease. Thus I would heavily recommend against this. Better try to make the splitting of features not-so-artificial. If you have bigger features to work on which cannot be completed in one sprint, split them up into smaller ones, but do not make those partly completed features available to your users immediately at the end of each sprint. Better, learn to utilize feature branches and feature toggles for your needs. A better branching/merging strategy might also be an approach to untie your teams from the fixed two weeks sprint cycle - if the next feature slice fits better in 9 days instead of 14, whilst the other team needs 16 days, this should be perfectly possible. And your QA team can still get a new version every 14 days. You have to establish a strategy for this which allows you to prohibit the delivery of half-baked features from the development branch to staging in the middle of a sprint, without stopping your teams from work. There are different approaches how to accomplish this with Git, and of course, your configuration management effort will probably increase, but that is probably outweight by the benefits you get from this. |
_unix.118758 | I'm using a raspberry pi to capture some audio, but I only want it to do it when the noise level goes above a certain level, and then the device will record until two seconds after it falls below that level again.I have a python program, audioserver.py which starts and stops another program, arecord, from recording from the microphone input.However, it appears that one program cannot have the audio device open while the other already does - is there a way I could overcome this problem and open my ALSA Microphone device more than once? | Opening ALSA Microphone in two programs? | audio;alsa;recording | null |
_unix.322146 | I was able to connect using smb to my server via a redhat vm and nautilus then went to a term, typed mount, and could see where the mount point was exactly (like /run/user/1000/gvfs/???/????/) but when I try to do the same thing in a deb vm it mounts fine in nautilus but then the mount only shows up to /run/user/1000 and when I look in the gvfs dir its empty, there is nothing in there hidden or otherwise). I wasn't sure why in RH there was a mounted dir in the gvfs subdir and nada in the gvfs subdir on the deb vm? I noticed that in other forums they have said its normally supposed to mount something like /run/user//gvfs/?? but in my RHVM I got 1000 instead of my loginid (a Qubes thing perhaps?) and in my dbvm I got the 1000 as well. I have an app that does not let me put in a full path but I have to click through a tree so I'd really like to find where the mount point is. Thoughts? | Where does DebVM (In Qubes OS) put the smb mounted drive? | debian;rhel;mount;smb;qubes | null |
_unix.171803 | I'm always connected to a wireless network in my home from my Ubuntu 14.04 laptop (via routers)Now I am in another place where there's an iMac sharing internet connection.My phone and other's, and a Windows laptop are connect to that network but I cannot from this laptop.I've created a new DHCP connection with the correct SSID and left other default settings, same as the home connection.ifconfig displays info about eth0, lo and wlan0.Network manager doesn't recognize wlan0.Network is unreachable What can I do to get connected to that network?Edit: I finally solved replacing Network Manager by Wicd | Changed to another wi-fi network does not connect | networking;wifi | null |
_datascience.5373 | I have a large dataset with characters and 90000 intances and I have the error ValueError: array is too big when I have the following code before the plot_kmeans_digits.py code:data2=list(csv.DictReader(open('C:\diabeticdata.csv', 'rU')))vec = DictVectorizer()data = vec.fit_transform(data2).toarray()Do you know how I can solve this error?Thanks in advance. | sk-learn - ValueError: array is too big. | bigdata;scikit learn | null |
_unix.153239 | A little extended problem from cat line x to line y on a huge file:I have a huge file (2-3 GB). I'd like to cat/print only from the line having foo: to the line having goo:. Assume that foo: and goo: only appear once in a file; foo: proceeds goo:.So far this is my approach:First, find the line with foo: and goo:: grep -nr foo: bigfileReturns 123456: foo: hello world! and 654321: goo: good bye!Once I know these starting and ending line numbers, and the difference (654321-123456=530865) I can do selective cat:tail -n+123456 bigfile | head -n 530865My question is that how can I effectively substitute the line number constants with expressions (e.g., grep ...)?I can write a simple Python script but want to achieve it using only combining commands. | Only cat from specific line X (with a pattern) to other specific line Y (with a pattern) | sed;awk;grep;tail;head | null |
_datascience.10083 | I'm new to machine learning but am interested in decoding applications like the Higgs Boson challenge on Kaggle. I just wondered, what are the best algorithms or approaches for classifying such a small signal in large amounts of noise? I think supervised and unsupervised are equally fine to use for my project, but hearing about your thoughts in general would help a lot! I wanted to start with the Higgs Boson challenge to explore machine learning methods for improving discovery significance of scientific data. The experiment and data are available at https://www.kaggle.com/c/higgs-boson . The code used by the winner was released here: https://www.kaggle.com/c/higgs-boson/forums/t/10425/code-release . I know the basic theory of supervised and unsupervised learning, and have studied and used Linear Regression and SVM. I've read about neural networks also but on a basic approach level. I'm just learning about deep learning coming from the natural sciences, to improve data analysis, and found SVM very useful but otherwise don't know more advanced techniques. | Classification in noise | machine learning | null |
_webmaster.58916 | I have a small hobby web site that acts as a friend finder for folks with similar hobby interests. So far I have avoided advertising of any kind to keep from having a negative impact. But recently my user list has started growing nicely.My goal is to pay for the site's hosting costs and other small costs that went into site development: domain registration, html template and some graphics. None of it was very expensive. Hosting is the main cost.How many registered users or regular user traffic should the site have before some simple advertising. I'm thinking no more than a single ad in any page. | How many users should a site have before using advertising? | advertising;cost | There is no minimum traffic needed for ads. I have ads on my websites and I have for the past 10 years. I now make my living from those advertisements. My traffic started out small, paying for the hosting and keeping the site alive. You talk of negative effects, but there are not many. Users that really don't like ads use ad blockers and don't see the ads. Other users don't seem to mind. When I first started putting ads on, I expected to see lots of complaints. Those complaints never materialized. Google is now penalizing sites that obscure the content with ads, or otherwise use too many ads. One ad on a page is certainly not going to trigger this penalty.My guidelines for ads would be:Use no more than three per page, and only one above the fold.Don't put ads around the edges of the page. Put the ad in between content where it will be noticed by users. Ads above all the content are summarily ignored. Ads in the right sidebar are not effective.Be careful of ads that mimic site functionality. Stay away from link bar ads that mimic navigation and advertisers that try to match their ads to buttons on your site such as download buttons.Try different layouts to figure out where ads get noticed the most. |
_codereview.8650 | I am trying to create a stamp order / preview form for a site and have gotten fairly far on my own, with a little help from Google and of course you all. If you can suggest any other method of going about this, please guide me in the right direction. Also, I need to figure out how to put a border, the same colour as has been chosen in the dropdown selection, around the containing div. <SCRIPT LANGUAGE=JavaScript> function setColor() { var color = document.getElementById(color).value; document.getElementById(myDiv).style.color = color; } function addContent(divName, content) { document.getElementById(divName).innerHTML = content; } function fontSize(size) { document.getElementById(lineOne).style.fontSize = size } function fontFamily(family) { document.getElementById(lineOne).style.fontFamily = family } function fontStyle(style) { document.getElementById(lineOne).style.fontStyle = style } function fontWeight(weight) { document.getElementById(lineOne).style.fontWeight = weight } function align(align) { document.getElementById(lineOne).style.textAlign = align; } function fontSize1(size1) { document.getElementById(lineTwo).style.fontSize = size1 } function fontFamily1(family1) { document.getElementById(lineTwo).style.fontFamily = family1 } function fontStyle1(style1) { document.getElementById(lineTwo).style.fontStyle = style1 } function fontWeight1(weight1) { document.getElementById(lineTwo).style.fontWeight = weight1 } function align1(align1) { document.getElementById(lineTwo).style.textAlign = align1; } function fontSize2(size2) { document.getElementById(lineThree).style.fontSize = size2 } function fontFamily2(family2) { document.getElementById(lineThree).style.fontFamily = family2 } function fontStyle2(style2) { document.getElementById(lineThree).style.fontStyle = style2 } function fontWeight2(weight2) { document.getElementById(lineThree).style.fontWeight = weight2 } function align2(align2) { document.getElementById(lineThree).style.textAlign = align2; } function fontSize3(size3) { document.getElementById(lineFour).style.fontSize = size3 } function fontFamily3(family3) { document.getElementById(lineFour).style.fontFamily = family3 } function fontStyle3(style3) { document.getElementById(lineFour).style.fontStyle = style3 } function fontWeight3(weight3) { document.getElementById(lineFour).style.fontWeight = weight3 } function align3(align3) { document.getElementById(lineFour).style.textAlign = align3; } function border(border) { document.getElementById(myDiv).style.border = border; } function boldText(checkBox,target) { if(checkBox.checked) { document.getElementById(target).style.fontWeight = bold; } else { document.getElementById(target).style.fontWeight = normal; } } function underlineText(checkBox,target) { if(checkBox.checked) { document.getElementById(target).style.textDecoration = underline; } else { document.getElementById(target).style.textDecoration = none; } } function italic(checkBox,target) { if(checkBox.checked){ document.getElementById(target).style.fontStyle = italic; } else { document.getElementById(target).style.fontStyle = normal; } } </SCRIPT></head><body> <div id=edit> <h1>Edit text as needed</h1> <form name=myForm enctype=multipart/form-data> <table border=0 width=100% style=border-collapse: collapse> <tr> <td width=278>Text</td> <td width=165>Font Family</td> <td width=74>Size</td> <td width=86>Align</td> <td><b>B</b></td> <td><u>U</u></td> <td><i>I</i></td> </tr> <tr> <td> <input name=myContent></input> <input type=button value=Add content onClick=addContent('lineOne', document.myForm.myContent.value); setCookie('content', document.myForm.myContent.value, 7);> </td> <td width=165> <select id=fontFamilyChanger onchange=fontFamily(this.value)> <option value=Arial>Arial</option> <option value=Comic Sans MS>Comic Sans MS</option> <option value=serif selected=selected>Times New Roman</option> <option value=Verdana>Verdana</option> </select> </td> <td width=74> <select name=fontSizeChanger onchange=fontSize(this.value)> <option value=6>6</option> <option value=8>8</option> <option value=10>10</option> <option value=12 selected=selected>12</option> <option value=14>14</option> <option value=16>16</option> <option value=18>18</option> <option value=20>20</option> </select> </td> <td width=75> <select id=textAlignChanger onchange=align(this.value);> <option value=left>left</option> <option value=center selected=selected>center</option> <option value=right>right</option> </select> </td> <td> <input type=checkbox onclick=boldText(this,'lineOne')> </td> <td> <input type=checkbox onclick=underlineText(this,'lineOne')> </td> <td> <input type=checkbox onclick=italic(this,'lineOne')> </td> </tr> <tr> <td> <input name=myContent1></input> <input type=button value=Add content onClick=addContent('lineTwo', document.myForm.myContent1.value); setCookie('content', document.myForm.myContent1.value, 7);> </td> <td width=165> <select id=fontFamilyChanger onchange=fontFamily1(this.value)> <option value=Arial>Arial</option> <option value=Comic Sans MS>Comic Sans MS</option> <option value=serif selected=selected>Times New Roman</option> <option value=Verdana>Verdana</option> </select> </td> <td width=74> <select name=fontSizeChanger onchange=fontSize1(this.value)> <option value=6>6</option> <option value=8>8</option> <option value=10>10</option> <option value=12 selected=selected>12</option> <option value=14>14</option> <option value=16>16</option> <option value=18>18</option> <option value=20>20</option> </select> </td> <td width=75> <select id=textAlignChanger onchange=align1(this.value);> <option value=left>left</option> <option value=center selected=selected>center</option> <option value=right>right</option> </select> </td> <td> <input type=checkbox onclick=boldText(this,'lineTwo')> </td> <td> <input type=checkbox onclick=underlineText(this,'lineTwo')> </td> <td> <input type=checkbox onclick=italic(this,'lineTwo')> </td> </tr> <tr> <td> <input name=myContent2></input> <input type=button value=Add content onClick=addContent('lineThree', document.myForm.myContent2.value); setCookie('content', document.myForm.myContent2.value, 7);> </td> <td width=165> <select id=fontFamilyChanger onchange=fontFamily2(this.value)> <option value=Arial>Arial</option> <option value=Comic Sans MS>Comic Sans MS</option> <option value=serif selected=selected>Times New Roman</option> <option value=Verdana>Verdana</option> </select> </td> <td width=74> <select name=fontSizeChanger onchange=fontSize2(this.value)> <option value=6>6</option> <option value=8>8</option> <option value=10>10</option> <option value=12 selected=selected>12</option> <option value=14>14</option> <option value=16>16</option> <option value=18>18</option> <option value=20>20</option> </select> </td> <td width=75> <select id=textAlignChanger onchange=align2(this.value);> <option value=left>left</option> <option value=center selected=selected>center</option> <option value=right>right</option> </select> </td> <td> <input type=checkbox onclick=boldText(this,'lineThree')> </td> <td> <input type=checkbox onclick=underlineText(this,'lineThree')> </td> <td> <input type=checkbox onclick=italic(this,'lineThree')> </td> </tr> <tr> <td> <input name=myContent3></input> <input type=button value=Add content onClick=addContent('lineFour', document.myForm.myContent3.value); setCookie('content', document.myForm.myContent3.value, 7);> </td> <td width=165> <select id=fontFamilyChanger onchange=fontFamily3(this.value)> <option value=Arial>Arial</option> <option value=Comic Sans MS>Comic Sans MS</option> <option value=serif selected=selected>Times New Roman</option> <option value=Verdana>Verdana</option> </select> </td> <td width=74> <select name=fontSizeChanger onchange=fontSize3(this.value)> <option value=6>6</option> <option value=8>8</option> <option value=10>10</option> <option value=12 selected=selected>12</option> <option value=14>14</option> <option value=16>16</option> <option value=18>18</option> <option value=20>20</option> </select> </td> <td width=75> <select id=textAlignChanger onchange=align3(this.value);> <option value=left>left</option> <option value=center selected=selected>center</option> <option value=right>right</option> </select> </td> <td> <input type=checkbox onclick=boldText(this,'lineFour')> </td> <td> <input type=checkbox onclick=underlineText(this,'lineFour')> </td> <td> <input type=checkbox onclick=italic(this,'lineFour')> </td> </tr> </table> </div> <br> Colour: <select id=color onclick=setColor();> <option value=white>white</option> <option value=black selected=selected>black</option> <option value=red>red</option> <option value=lightblue>light blue</option> <option value=darkblue>dark blue</option> <option value=lightgreen>light green</option> <option value=darkgreen>dark green</option> <option value=yellow>yellow</option> <option value=orange>orange</option> <option value=pink>pink</option> <option value=purple>purple</option> <option value=gray>gray</option> </select> <select id=border onchange=border(this.value);> <option value=1px solid selected=selected>1px</option> <option value=2px solid>2px</option> <option value=3px solid>3px</option> <option value=4px solid>4px</option> <option value=5px solid>5px</option> </select> </form> <br> <div id=myDiv> <div id=lineOne></div> <div id=lineTwo></div> <div id=lineThree></div> <div id=lineFour></div> </div>http://jsfiddle.net/ShauniD/ELER2/Have a look and let me know!I need coding advice with this code. Please go easy as this is my first code in JavaScript, and I need good criticism. | Stamp order / preview form for a site | javascript;beginner | It is my first code review, I hope I'll be clear enough to explain why I would have done things like that.Here is how I would have it done - I removed the setCookie part because it was not used in what you show to us - :<html> <head> <meta http-equiv=Content-Type content=text/html; charset=windows-1252> <link rel=stylesheet type=text/css href=style.css> </head> <body> <div id=edit> <h1>Edit text as needed</h1> <form name=myForm enctype=multipart/form-data> <table border=0 width=100% style=border-collapse: collapse> <tr> <td width=278>Text</td> <td width=165>Font Family</td> <td width=74>Size</td> <td width=86>Align</td> <td><b>B</b></td> <td><u>U</u></td> <td><i>I</i></td> </tr> <tr> <td> <input name=myContent></input> <input type=button value=Set content onclick=DOMModifier.setContent('lineOne', document.myForm.myContent.value);> </td> <td width=165> <select id=fontFamilyChanger onchange=DOMModifier.setFontFamily('lineOne', this.value);> <option value=Arial>Arial</option> <option value=Comic Sans MS>Comic Sans MS</option> <option value=serif selected=selected>Times New Roman</option> <option value=Verdana>Verdana</option> </select> </td> <td width=74> <select name=fontSizeChanger onchange=DOMModifier.setFontSize('lineOne', this.value);> <option value=6>6</option> <option value=8>8</option> <option value=10>10</option> <option value=12 selected=selected>12</option> <option value=14>14</option> <option value=16>16</option> <option value=18>18</option> <option value=20>20</option> </select> </td> <td width=75> <select id=textAlignChanger onchange=DOMModifier.setAlign('lineOne', this.value);> <option value=left>left</option> <option value=center selected=selected>center</option> <option value=right>right</option> </select> </td> <td> <input type=checkbox onclick=DOMModifier.toggleBold('lineOne', this);> </td> <td> <input type=checkbox onclick=DOMModifier.toggleUnderline('lineOne', this);> </td> <td> <input type=checkbox onclick=DOMModifier.toggleItalic('lineOne', this);> </td> </tr> <tr> <td> <input name=myContent1></input> <input type=button value=Set content onclick=DOMModifier.setContent('lineTwo', document.myForm.myContent1.value);> </td> <td width=165> <select id=fontFamilyChanger onchange=DOMModifier.setFontFamily('lineTwo', this.value);> <option value=Arial>Arial</option> <option value=Comic Sans MS>Comic Sans MS</option> <option value=serif selected=selected>Times New Roman</option> <option value=Verdana>Verdana</option> </select> </td> <td width=74> <select name=fontSizeChanger onchange=DOMModifier.setFontSize('lineTwo', this.value);> <option value=6>6</option> <option value=8>8</option> <option value=10>10</option> <option value=12 selected=selected>12</option> <option value=14>14</option> <option value=16>16</option> <option value=18>18</option> <option value=20>20</option> </select> </td> <td width=75> <select id=textAlignChanger onchange=DOMModifier.setAlign('lineTwo', this.value);> <option value=left>left</option> <option value=center selected=selected>center</option> <option value=right>right</option> </select> </td> <td> <input type=checkbox onclick=DOMModifier.toggleBold('lineTwo', this)> </td> <td> <input type=checkbox onclick=DOMModifier.toggleUnderline('lineTwo', this)> </td> <td> <input type=checkbox onclick=DOMModifier.toggleItalic('lineTwo', this)> </td> </tr> <tr> <td> <input name=myContent2></input> <input type=button value=Set content onclick=DOMModifier.setContent('lineThree', document.myForm.myContent2.value);> </td> <td width=165> <select id=fontFamilyChanger onchange=DOMModifier.setFontFamily('lineThree', this.value);> <option value=Arial>Arial</option> <option value=Comic Sans MS>Comic Sans MS</option> <option value=serif selected=selected>Times New Roman</option> <option value=Verdana>Verdana</option> </select> </td> <td width=74> <select name=fontSizeChanger onchange=DOMModifier.setFontSize('lineThree', this.value);> <option value=6>6</option> <option value=8>8</option> <option value=10>10</option> <option value=12 selected=selected>12</option> <option value=14>14</option> <option value=16>16</option> <option value=18>18</option> <option value=20>20</option> </select> </td> <td width=75> <select id=textAlignChanger onchange=DOMModifier.setAlign('lineThree', this.value);> <option value=left>left</option> <option value=center selected=selected>center</option> <option value=right>right</option> </select> </td> <td> <input type=checkbox onclick=DOMModifier.toggleBold('lineThree', this);> </td> <td> <input type=checkbox onclick=DOMModifier.toggleUnderline('lineThree', this);> </td> <td> <input type=checkbox onclick=DOMModifier.toggleItalic('lineThree', this);> </td> </tr> <tr> <td> <input name=myContent3></input> <input type=button value=Set content onclick=DOMModifier.setContent('lineFour', document.myForm.myContent3.value);> </td> <td width=165> <select id=fontFamilyChanger onchange=DOMModifier.setFontFamily('lineFour', this.value);> <option value=Arial>Arial</option> <option value=Comic Sans MS>Comic Sans MS</option> <option value=serif selected=selected>Times New Roman</option> <option value=Verdana>Verdana</option> </select> </td> <td width=74> <select name=fontSizeChanger onchange=DOMModifier.setFontSize('lineFour', this.value);> <option value=6>6</option> <option value=8>8</option> <option value=10>10</option> <option value=12 selected=selected>12</option> <option value=14>14</option> <option value=16>16</option> <option value=18>18</option> <option value=20>20</option> </select> </td> <td width=75> <select id=textAlignChanger onchange=DOMModifier.setAlign('lineFour', this.value);> <option value=left>left</option> <option value=center selected=selected>center</option> <option value=right>right</option> </select> </td> <td> <input type=checkbox onclick=DOMModifier.toggleBold('lineFour', this);> </td> <td> <input type=checkbox onclick=DOMModifier.toggleUnderline('lineFour', this);> </td> <td> <input type=checkbox onclick=DOMModifier.toggleItalic('lineFour', this);> </td> </tr> </table> <br/> <span>Colour:</span> <select id=color onchange=DOMModifier.setColor('myDiv', this.value);> <option value=white>white</option> <option value=black selected=selected>black</option> <option value=red>red</option> <option value=lightblue>light blue</option> <option value=darkblue>dark blue</option> <option value=lightgreen>light green</option> <option value=darkgreen>dark green</option> <option value=yellow>yellow</option> <option value=orange>orange</option> <option value=pink>pink</option> <option value=purple>purple</option> <option value=gray>gray</option> </select> <select id=border onchange=DOMModifier.setBorder('myDiv', this.value);> <option value=1px solid selected=selected>1px</option> <option value=2px solid>2px</option> <option value=3px solid>3px</option> <option value=4px solid>4px</option> <option value=5px solid>5px</option> </select> </form> </div> <br/> <div id=myDiv> <div id=lineOne></div> <div id=lineTwo></div> <div id=lineThree></div> <div id=lineFour></div> </div> <script type=text/javascript> var DOMModifier = { // method that get an element by is identifier - don't repeat document.getElementById hundred times in your code // the method cache elements already retrieven from the DOM // throw error if element does not exists getElement : (function() { var elements = {}; // private - element collection, allow to cache DOM acces to div return function(identifier) { // check if element was alredy retrieved if ( typeof elements[identifier] === 'undefined' || elements[identifier] === null) { // if not, store it elements[identifier] = document.getElementById(identifier); if ( elements[identifier] === null ) // throw an error if it do not exists throw new Error('Element ' + identifier + ' does not exists'); } return elements[identifier]; }; }()), // set content setContent: function(targetIdentifier, content) { this.getElement(targetIdentifier).innerHTML = content; // innerHTML on some elements is readonly in IE ! }, // add content addContent: function(targetIdentifier, content) { this.getElement(targetIdentifier).innerHTML += content; }, // set style setStyle: function(targetIdentifier, style, value) { this.getElement(targetIdentifier).style[style] = value; }, //modifiers - could have used content of thoses functions directly in onchange proprerty //but using functions is more maintainable and evoluable // ie : add check functions before doing a setStyle setColor: function(target, value) { this.setStyle(target, 'color', value); }, setBorder: function(target, value) { this.setStyle(target, 'border', value); }, setFontSize: function(target, value) { this.setStyle(target, 'fontSize', value); }, setFontFamily: function(target, value) { this.setStyle(target, 'fontFamily', value); }, setFontStyle: function(target, value) { this.setStyle(target, 'fontStyle', value); }, setFontWeight: function(target, value) { this.setStyle(target, 'fontWeight', value); }, setAlign: function(target, value) { this.setStyle(target, 'textAlign', value); }, setBold: function(target, value) { this.setStyle(target, 'fontWeight', value); }, setUnderline: function(target, value) { this.setStyle(target, 'textDecoration', value); }, setItalic: function(target, value) { this.setStyle(target, 'fontStyle', value); }, toggleBold: function(target, element) { this.setBold(target, element.checked === true ? 'bold' : 'normal'); }, toggleUnderline: function(target, element) { this.setUnderline(target, element.checked === true ? 'underline' : 'none'); }, toggleItalic: function(target, element) { this.setItalic(target, element.checked === true ? 'italic' : 'normal'); } }; </script> </body></html>Just check at the more important thing, the JavaScript code:var DOMModifier = { // Method that get an element by is identifier - don't repeat document.getElementById hundred times in your code. // The method cache elements already retrieved from the DOM. // It throws an error if an element does not exist. getElement : (function() { var elements = {}; // private - element collection, allow to cache DOM acces to div return function(identifier) { // check if element was alredy retrieved if ( typeof elements[identifier] === 'undefined' || elements[identifier] === null) { // if not, store it elements[identifier] = document.getElementById(identifier); if ( elements[identifier] === null ) // throw an error if requested element does not exists throw new Error('Element ' + identifier + ' does not exists'); } return elements[identifier]; }; }()), // Set content setContent: function(targetIdentifier, content) { this.getElement(targetIdentifier).innerHTML = content; // innerHTML on some elements is read-only in Internet Explorer! }, // Add content addContent: function(targetIdentifier, content) { this.getElement(targetIdentifier).innerHTML += content; }, // Set style setStyle: function(targetIdentifier, style, value) { this.getElement(targetIdentifier).style[style] = value; }, //Modifiers - could have used content of thoses functions directly in the onchange proprerty, //but using functions is more maintainable and evolvable. // ie: add check functions before doing a setStyle setColor: function(target, value) { this.setStyle(target, 'color', value); }, setBorder: function(target, value) { this.setStyle(target, 'border', value); }, setFontSize: function(target, value) { this.setStyle(target, 'fontSize', value); }, setFontFamily: function(target, value) { this.setStyle(target, 'fontFamily', value); }, setFontStyle: function(target, value) { this.setStyle(target, 'fontStyle', value); }, setFontWeight: function(target, value) { this.setStyle(target, 'fontWeight', value); }, setAlign: function(target, value) { this.setStyle(target, 'textAlign', value); }, setBold: function(target, value) { this.setStyle(target, 'fontWeight', value); }, setUnderline: function(target, value) { this.setStyle(target, 'textDecoration', value); }, setItalic: function(target, value) { this.setStyle(target, 'fontStyle', value); }, toggleBold: function(target, element) { this.setBold(target, element.checked === true ? 'bold' : 'normal'); }, toggleUnderline: function(target, element) { this.setUnderline(target, element.checked === true ? 'underline' : 'none'); }, toggleItalic: function(target, element) { this.setItalic(target, element.checked === true ? 'italic' : 'normal'); }};Let's talk about what differs from yours:I declared one global object (DOMModifier) containing all the functions. This, in order to not populate the Global scope with a lot of functions.I made the functions generics like you did with yours boldText, italic and underlineText. To do that, we just have to pass the target identifier to the function instead of creating one function by target.I created a generic function getElement which cache the DOM elements access. So, for one identifier, it will only call the DOM function getElementById the first time, and store the result (or throw an error if it does not exist). Every other call in order to retrieve this element will just return the cached one.I created a generic function setStyle that is used by all the others function which are made to change a style.I changed some function names:addContent become setContent because it was, in fact, setting content. I added an addContent that add content.I added the keyword set before a lot of function names to make the code speaking about what it is doing.I added three functions: toggleBold, toggleUnderline and toggleItalic and I used them on the checkbox click event, beacause those event don't just set a style, but set or unset -litterally speaking- according to the state of the checkbox.I putted the JavaScript part at the end of the HTML, just before the body close, to ensure that all DOM elements are loaded before adding JavaScript features.Now let's talk about the JavaScript part in the onchange and onclick properties:Now that I have a global object instead of global functions, I call every function on the object - that is, DOMModifier.setFontFamily() with required arguments (target, value, etc.)Now what I did can really be improved by:Adding JavaScript EventListeners to elements when the DOM is loaded instead of using the onchange and onclick properties. It will separate HTML and JavaScript code, be more flexible, avoid errors, add features only when the DOM is ready to handle them...Modify some functions to make it cross-browser (that is, innerHTML on some elements won't work in Internet Explorer)Test and modify it to add features, make some actions more generics, etc...Just remember:What I changed here is good (I hope) for what I wanted it to do, in an other context, maybe I would have make it different, more flexible, more generic, more intrusive for objects nature, etc... |
_cs.29508 | Suppose we're given two numbers $l$ and $r$ and that we want to find $\max{(i\oplus j)}$ for $l\le i,\,j\le r$.The nave algorithm simply checks all possible pairs; for instance in ruby we'd have:def max_xor(l, r) max = 0 (l..r).each do |i| (i..r).each do |j| if (i ^ j > max) max = i ^ j end end end maxendI sense that we can do better than quadratic. Is there a better algorithm for this problem? | Finding the max XOR of two numbers in an interval: can we do better than quadratic? | algorithms | We can achieve linear runtime in the length $n$ of the binary representation of $l$ and $r$:The prefix $p$ in the binary representation of $l$ and $r$, that is the same for both values, is also the same for all values between them. So these bits will always be $0$.Since $r>l$, the bit following this prefix will be $1$ in $r$ and $0$ in $l$. Furthermore, the numbers $p10^{n-|p|-1}$ and $p01^{n-|p|-1}$ are both in the interval.So the max we are looking for is $0^{|p|}1^{n-|p|}$. |
_cs.40094 | Say I have two simple graphs, $A$ and $B$In $A$, I know:one node has 3 nodes at distance of 1, 4 nodes at distance 2, etc.one node has 4 nodes at distance of 1, 1 nodes at distance 2, etc.etc.In $B$, I know:one node has 3 nodes at distance of 1, 4 nodes at distance 2, etc.one node has 4 nodes at distance of 1, 1 nodes at distance 2, etc.etc.Can I derive that graph $A$ and $B$ are isomorphic to each other? Or is there a counter-example where two graphs look the same from this distance point of view, but are not isomorphic?It is a necessary condition, so if these simple graphs are isomorphic, they will share these distances. I am wondering if this is a sufficient condition as well. | Sufficient condition for simple graph isomorphism? | graph theory | There are two non-isomorphic graphs with 16 vertices in which each vertex has 6 neighbors and 9 vertices at distance 2: the Shrikhande graph and the $4\times 4$ rook's graph. |
_unix.181307 | I have a similar question running on serverfault, but i have a followup question that is more suited here, in my humble(likely uninformed) opinion.I have been trying to validate users in my Debian Wheezy server against the company AD(windows 2008 server).The main challenge is that this AD does not supply any Unix attributes (uid, gid, homedir, shell).I have gotten around homedir and shell by using sssd and its fallback mechanisms. However, i am currently stuck on the uid, gid.When i attempt to sync using the configuration (i cut it down to the relevant parts)id_provider = adaccess_provider = adauth_provider = krb5chpass_provider = krb5ldap_schema = adldap_id_mapping = truedebug_level = 7I get the following error:(Tue Jan 27 10:39:05 2015) [sssd[be[thecompany.dk]]] [sbus_dispatch] (0x0080): Connection is not open for dispatching.(Tue Jan 27 10:39:05 2015) [sssd[be[thecompany.dk]]] [be_client_destructor] (0x0400): Removed PAM client(Tue Jan 27 10:39:05 2015) [sssd[be[thecompany.dk]]] [sbus_dispatch] (0x0080): Connection is not open for dispatching.(Tue Jan 27 10:39:05 2015) [sssd[be[thecompany.dk]]] [be_client_destructor] (0x0400): Removed NSS client(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [server_setup] (0x0080): CONFDB: /var/lib/sss/db/config.ldb(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [recreate_ares_channel] (0x0100): Initializing new c-ares channel(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [resolv_get_family_order] (0x1000): Lookup order: ipv4_first(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [fo_context_init] (0x0080): Created new fail over context, retry timeout is 30(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [confdb_get_domain_internal] (0x0020): No enumeration for [thecompany.dk]!(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sysdb_domain_init_internal] (0x0200): DB File for thecompany.dk: /var/lib/sss/db/cache_thecompany.dk.ldb(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [ldb] (0x0400): asq: Unable to register control with rootdse!(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sbus_init_connection] (0x0200): Adding connection FB1630(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [monitor_common_send_id] (0x0100): Sending ID: (%BE_thecompany.dk,1)(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [create_socket_symlink] (0x1000): Symlinking the dbus path /var/lib/sss/pipes/private/sbus-dp_thecompany.dk.4798 to a link /var/lib/sss/pipes/private/sbus-dp_thecompany.dk(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sbus_new_server] (0x0080): D-BUS Server listening on unix:path=/var/lib/sss/pipes/private/sbus-dp_thecompany.dk.4798,guid=84361ff4e288ffa9288b858f54c75cba(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [load_backend_module] (0x1000): Loading backend [ad] with path [/usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so].(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [load_backend_module] (0x0010): Unable to load ad module with path (/usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so), error: /usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so: cannot open shared object file: No such file or directory(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [be_process_init] (0x0010): fatal error initializing data providers(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [main] (0x0010): Could not initialize backend [79](Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [server_setup] (0x0080): CONFDB: /var/lib/sss/db/config.ldb(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [recreate_ares_channel] (0x0100): Initializing new c-ares channel(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [resolv_get_family_order] (0x1000): Lookup order: ipv4_first(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [fo_context_init] (0x0080): Created new fail over context, retry timeout is 30(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [confdb_get_domain_internal] (0x0020): No enumeration for [thecompany.dk]!(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sysdb_domain_init_internal] (0x0200): DB File for thecompany.dk: /var/lib/sss/db/cache_thecompany.dk.ldb(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [ldb] (0x0400): asq: Unable to register control with rootdse!(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sbus_init_connection] (0x0200): Adding connection 1A3D630(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [monitor_common_send_id] (0x0100): Sending ID: (%BE_thecompany.dk,1)(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [create_socket_symlink] (0x1000): Symlinking the dbus path /var/lib/sss/pipes/private/sbus-dp_thecompany.dk.4799 to a link /var/lib/sss/pipes/private/sbus-dp_thecompany.dk(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sbus_new_server] (0x0080): D-BUS Server listening on unix:path=/var/lib/sss/pipes/private/sbus-dp_thecompany.dk.4799,guid=f69da63ecb7352f94fee01df54c75cba(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [load_backend_module] (0x1000): Loading backend [ad] with path [/usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so].(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [load_backend_module] (0x0010): Unable to load ad module with path (/usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so), error: /usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so: cannot open shared object file: No such file or directory(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [be_process_init] (0x0010): fatal error initializing data providers(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [main] (0x0010): Could not initialize backend [79](Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [server_setup] (0x0080): CONFDB: /var/lib/sss/db/config.ldb(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [recreate_ares_channel] (0x0100): Initializing new c-ares channel(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [resolv_get_family_order] (0x1000): Lookup order: ipv4_first(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [fo_context_init] (0x0080): Created new fail over context, retry timeout is 30(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [confdb_get_domain_internal] (0x0020): No enumeration for [thecompany.dk]!(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sysdb_domain_init_internal] (0x0200): DB File for thecompany.dk: /var/lib/sss/db/cache_thecompany.dk.ldb(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [ldb] (0x0400): asq: Unable to register control with rootdse!(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sbus_init_connection] (0x0200): Adding connection 210B630(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [monitor_common_send_id] (0x0100): Sending ID: (%BE_thecompany.dk,1)(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [create_socket_symlink] (0x1000): Symlinking the dbus path /var/lib/sss/pipes/private/sbus-dp_thecompany.dk.4800 to a link /var/lib/sss/pipes/private/sbus-dp_thecompany.dk(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sbus_new_server] (0x0080): D-BUS Server listening on unix:path=/var/lib/sss/pipes/private/sbus-dp_thecompany.dk.4800,guid=466e1c905c470ad8c00455f754c75cba(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [load_backend_module] (0x1000): Loading backend [ad] with path [/usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so].(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [load_backend_module] (0x0010): Unable to load ad module with path (/usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so), error: /usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so: cannot open shared object file: No such file or directory(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [be_process_init] (0x0010): fatal error initializing data providers(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [main] (0x0010): Could not initialize backend [79](Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [server_setup] (0x0080): CONFDB: /var/lib/sss/db/config.ldb(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [recreate_ares_channel] (0x0100): Initializing new c-ares channel(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [resolv_get_family_order] (0x1000): Lookup order: ipv4_first(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [fo_context_init] (0x0080): Created new fail over context, retry timeout is 30(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [confdb_get_domain_internal] (0x0020): No enumeration for [thecompany.dk]!(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sysdb_domain_init_internal] (0x0200): DB File for thecompany.dk: /var/lib/sss/db/cache_thecompany.dk.ldb(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [ldb] (0x0400): asq: Unable to register control with rootdse!(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sbus_init_connection] (0x0200): Adding connection 1811630(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [monitor_common_send_id] (0x0100): Sending ID: (%BE_thecompany.dk,1)(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [create_socket_symlink] (0x1000): Symlinking the dbus path /var/lib/sss/pipes/private/sbus-dp_thecompany.dk.4801 to a link /var/lib/sss/pipes/private/sbus-dp_thecompany.dk(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [sbus_new_server] (0x0080): D-BUS Server listening on unix:path=/var/lib/sss/pipes/private/sbus-dp_thecompany.dk.4801,guid=7410c96282fd44c81ae85d5454c75cba(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [load_backend_module] (0x1000): Loading backend [ad] with path [/usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so].(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [load_backend_module] (0x0010): Unable to load ad module with path (/usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so), error: /usr/lib/x86_64-linux-gnu/sssd/libsss_ad.so: cannot open shared object file: No such file or directory(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [be_process_init] (0x0010): fatal error initializing data providers(Tue Jan 27 10:39:06 2015) [sssd[be[thecompany.dk]]] [main] (0x0010): Could not initialize backend [79]The files are actually missing:/usr/lib/x86_64-linux-gnu/sssd$ ls -latotal 3884drwxr-xr-x 3 root root 4096 Jan 26 15:05 .drwxr-xr-x 11 root root 12288 Jan 26 15:05 ..-rw-r--r-- 1 root root 1405048 Mar 4 2013 libsss_ipa.so-rw-r--r-- 1 root root 585784 Mar 4 2013 libsss_krb5.so-rw-r--r-- 1 root root 1081880 Mar 4 2013 libsss_ldap.so-rw-r--r-- 1 root root 479160 Mar 4 2013 libsss_proxy.so-rw-r--r-- 1 root root 389400 Mar 4 2013 libsss_simple.sodrwxr-xr-x 2 root root 4096 Jan 26 15:05 modulesHow do i get hold of the sssd ad provider for sssd on Debian Wheezy? I have seen numerous examples of it in use. Is it really not included in the wheezy distribution? Can i get around it by using the ldap provider somehow? Or do i have to smuss up my server and add the unstable repository to my sources? | sssd-ad in wheezy | debian;active directory;sssd | Version 1.11.7-2 from testing works for me in a production environment.You don't need to upgrade your entire system from stable, just add a testing repository:deb http://ftp.uk.debian.org/debian/ testing main contrib non-freedeb http://ftp.uk.debian.org/debian/ testing-updates main contrib non-freeYou may need to tell apt that you prefer the Stable release. You do this by adding this section to a file such as /etc/apt/apt.conf.d/00localAPT { Default-Release stable; // Cache-Limit 50000000; // only if needed};Then run aptitude update and you should find that aptitude install -t testing sssd-ad offers to install that and upgrade sssd, etc.Just for completeness here is my (redacted) sssd.conf[sssd]config_file_version = 2reconnection_retries = 3sbus_timeout = 30services = nss, pamdomains = example.org[nss]filter_groups = rootfilter_users = rootreconnection_retries = 3[pam]reconnection_retries = 3offline_credentials_expiration = 7offline_failed_login_delay = 1[domain/example.org]enumerate = falseldap_group_nesting_level = 5ldap_use_tokengroups = falsecache_credentials = trueaccount_cache_expiration = 10entry_cache_timeout = 14400lookup_family_order = ipv4_onlydns_resolver_timeout = 3dns_discovery_domain = example.orgfallback_homedir = /home/%d/%udefault_shell = /bin/bashid_provider = ad |
_unix.215676 | I am trying to automate the installation of Ubuntu from a network repository. I am now successfully able to configure the ISO image and it does the installation automatically.My requirement:I would like to know if there is a method in the initial installation stage of Ubuntu, where I can tell if the OS is being installed in VirtualBox or a physical desktop. I want this check to be performed as I want to automate the installation of the VirtualBox guest additions if the installation is being performed in VirtualBox.How can I do this? | Check if Ubuntu is being installed in VirtualBox VM | linux;ubuntu;virtualbox;virtual machine | If you're only checking for VirtualBox and don't need to cater for all hypervisors, there's a quick and dirty way - check for the presence of VirtualBox devices.lshw | grep VirtualBoxlspci | grep VirtualBoxI'm not sure if you'll have either or both of lshw and lspci but you can always install them as part of your custom installation (or, check the contents of /proc/pci instead of using lspci). |
_unix.136784 | Is it possible to use Linux (el6) clustered computer can be used as a hypervisor for RHEV 3.3/Ovirt 3.3?Cause, we can not combine RAM/CPU from two or more hypervisores to be considered as a one source of resource while creating a huge guest on RHEV. I know it support Baloonig and 150% for server and 200% for Desktop RAM aloocation but if I want to allocate RAM even more than that just to a one guest then?Any input for such situation! | Is it possible to install RHEV on el6 clustered computer | linux;virtual machine;virtualization;cluster;rhev | null |
_unix.269363 | For example, we have the content001002004008010in a text file named file, how to extract the missing 3 5 6 7 9? | What is the most concise script to list the missing ones in a digit sequence? | bash;shell script;text processing | An awk way:$ awk 'NR != $1 { for (i = prev + 1; i < $1; i++) {print i} } { prev = $1 + 1 }' file35679More clearly:awk 'NR != $1 { for (i = prev + 1; i < $1; i++) { print i }} { prev = $1}'For each line, I check if the line number matches the number, and if not, prints every number between the previous number (prev) and the current number (exclusive, hence i = prev + 1). |
_unix.361185 | I have a CentOS 7 box running KVM with all the usuals installed (bridge-utils etc).I have created a bridge which should in theory connect the guest to our private office network (192.168.99.X). The host is using DHCP rather than a static IP address, I'm not sure if that could be the issue or if it's just me not knowing what I'm doing.The NIC is currently set up as follows:ifcfg-enp30s0TYPE=EthernetBOOTPROTO=dhcpDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noNAME=enp30s0UUID=25962652-d1df-469b-885b-376a0604f333DEVICE=enp30s0NM_CONTROLLED=noBRIDGE=bridge0ONBOOT=yesAnd the bride is ifcfg-bridge0DEVICE=bridge0ONBOOT=yesTYPE=BridgeBOOTPROTO=dhcpNM_CONTROLLED=noDNS1=8.8.8.8DNS2=8.8.4.4DEFROUTE=yesFrom what I can tell this should work. I don't want to use virbr0 as it will assign something in the .122 range, we need to be able to access VMs via SSH without tunnelling through the host machine.Any help is much appreciated! | Bridge private & public network to guest in KVM | networking;virtual machine;kvm;dhcp;bridge | null |
_unix.160364 | I am trying to configure Exim to reject any $local_part that match a pattern.For example, I know that none of the local_parts for any of the myriad of domains I host will ever contains numbers. So, I know if someone send an email to [email protected], I know it is spam and can safely reject it.What would be the best ACL for this? | exim reject all local_part matching a pattern | exim;mail transport agent | ACL line could be the next:deny condition = ${lookup{$localpart}nwildlsearch{/path/to/the/black.list}{yes}{no}}While black.list contains PCRE regexes one per line like that:^.*[0-9].*^.*[!@#$%^&*()_+].*^.*sales.* |
_softwareengineering.92081 | We are planing to introduce Help Desk and Support Desk in our project.Our current development team would be divided into two smaller teams:Support Desk and Development team.Support Desk would be responsible only for bug fixing. Development team would be responsible for making enhancements and new features development.What value do you see from such responsibilities and teams segregation?Can we find a differences between bug and new features in terms of development activities? Is there any real value of doing such things? | What is the difference between bug and new feature in terms of segregation of responsibilities? | teamwork;division of labor | null |
_cseducators.206 | One of my goals is to minimize homework. My high school students are high performing, grade conscious, and constantly stressed out as it is. Many of them fall into the Ivy League or bust camp, which is a tremendous amount of pressure.So, when I give labs, I try to give sufficient class time that a majority of kids will be able to finish it with no more than a couple of hours of outside work. That means that I provide lab periods.Certain students have a lot of natural acuity for CS, and seem to finish labs far faster than the rest of the group. If I provide seven lab periods for a lab in AP Computer Science, I may reach my homework time target goals, but there will often be one kid who gets the lab done by the middle of the second period. What strategies do you use to deal with these kids? | Dealing with students who complete labs very quickly | high school;labs;best practice;differentiation | null |
_unix.351215 | I am trying to make a alias for mv so it does its normal behavioer in normal folders and is replaced by git mv inside git repositories. I tried many ways. the if statement works, only the command git mv will not run correctly.alias mv='$(if [ x`git rev-parse --show-toplevel 2> /dev/null` = x ]; echo mv; else echo git mv; fi)' | if-then-else inside Bash Alias | bash;git;alias | I would use a function for that, like so:gitmv(){ if [ x`git rev-parse --show-toplevel 2> /dev/null` = x ]; mv $@ else git mv $@ fi}Edit:alias mv=gitmv |
_unix.231534 | When we start some GUI apps from the terminal, it gets started up. For instance I run nautilus from terminal. I type: user@system ~$: nautilusIt gets started. But the terminal keeps printing its logs and errors. Is it possible to avoid this and start the process seperately, keeping the terminal for other use? I have many programs to start from the terminal with command line options. This brings many terminals and it all become clumpsy and hard to switch between apps. So how to start a GUI process/app seperately from terminal. Running GNOME 3. | Starting GUI Apps from Terminal, keeping the same terminal for other use | bash;terminal;gnome | null |
_codereview.87799 | I have tried to simulate a cart (only partially completed). I just wanted to see how the code upto this point can be enhanced. I am trying to learn about the usage of directives.Here I have used 2 directives:msgpallette- to show the messages when something is added to the cartitem-container - to show each item in menuA demo of the same is provided at plunkrDo tell me whether I have used directives properly. If not, do suggest code changes with explanations.HTML<body ng-controller=MainCtrl><div id=msger> <msgpallete msg=message ng-show='show'>{{message}} </msgpallete></div><p ng-repeat = item in items> <item-container startcounter = 1 resetter = 'reset' name = {{item.name}} > {{item.name}} </item-container><br><br></p><p ng-repeat = order in orders> <order-container > {{order.name}} </order-container><br><br></p></body>JSangular.module('myApp',[]).controller('MainCtrl', function($scope, $timeout) { $scope.items = [ {'name':'kabab'}, {'name':'noodles'}, {'name':'chicken'}, {'name':'egg'} ] $scope.resettrigger = function () { $scope.reset = true; $timeout(function() { $scope.reset = false; },100)} $scope.show=0; $scope.addMsg = function (qty,item) { $timeout.cancel($scope.promise); $scope.show = true; msg = Added +qty+ +item+ to the cart; $scope.message = msg; $scope.promise = $timeout(function() { $scope.show = false; },3000)}}).directive('msgpallete',function(){ return{restrict:E,transclude:true,scope:{},template:<h4 ng-transclude ></h4>}}).directive('itemContainer',function(){return {controller: function() {return {}}, restrict:'E', scope:{ resetter:= },transclude:true, link:function(scope,elem,attr){ scope.qty = attr.startcounter scope.add = function(){ scope.qty++; } scope.remove = function(){ scope.qty--; } scope.reset = function(){ console.log(attr.item:+attr.name); scope.$parent.addOrder(attr.name) scope.$parent.addMsg(scope.qty,attr.name) console.log(value when submitted: + scope.qty + name:+ attr.name); scope.qty = attr.startcounter; scope.$parent.resettrigger(); } scope.$watch(function(attr){ return attr.resetter }, function(newValue){ if(newValue === true){ scope.qty = attr.startcounter; } }); }, template:<button ng-click='reset();'>Add to cart</button>  + <button ng-click='remove();' >-</button> + {{qty}}  + <button ng-click='add();'>+</button>  + <a ng-transclude> </a> }}); | Shopping cart simulator | javascript;angular.js;e commerce | null |
_unix.233107 | I'm attempting to loop through an array of strings, and do something a little different with one of the values. The string comparison fails on every element.arr[0]='red'arr[1]='blue'arr[2]='yellow'arr[3]='green'## now loop through the above arrayfor i in ${arr[@]}do if [ $i=green ]; then echo i('$i') is equal to green else echo i('$i') is not equal to green fidoneI've also tried (with the same result): if [ $i='green' ];and if [ $i='green' ];and if [ $i=green ];Output of each of the above: i('red') is equal to greeni('blue') is equal to greeni('yellow') is equal to greeni('green') is equal to greenWhat am I doing wrong with the comparison? | String comparison failing in bash | bash | Missing whitespace.[ $i=green ] means [ -n $i=green ]you need[ $i = green ]or even[ green = $i ]which works even for i=-n.If you don't need portability to other shells, you can use double square brackets in bash. [[ $i = green ]]Quotes are not needed (in fact, on the right hand side they have a special meaning - they prevent expansion). You can use == instead of =, too. |
_softwareengineering.277711 | I normally avoid sProcs as much as possible. I dont like the language be it TSQL or PL/SQL; they seem archaic against Java/Dot-Net which I use. I go for them when a routine needs to fetch a lot of data, crunch it and generate a small set of output. Sitting inside the DB makes the fetching process a lot fast, no network hit. But that is all.I recently came across a DAL design where absolutely all of the CURD operations were implemented in Stored Procedures. Actually one giant sProc to be precise. Here is the skeleton:PROCEDURE myGenericProc(int QueryNo, varchar genericParam1, ..., varchar genericParamN)BEGIN SWITCH queryNo CASE 1 SELECT * FROM table1 INNER JOIN table 2 ON ... CASE 2 DELETE FROM table 3 WHERE ... ... CASE n UPDATE table4 SET a=b WHERE ...ENDThe designer's logic behind this is: if I do these things in code, then the database-connection needs to have full rights on all the tables. The connection credentials are generally in connection string, which is on the application server. If the application server is compromised, inevitably the entire DB is also compromised.As an alternative, have all the queries in the sProc, then grant that sProc full rights. Call only that sProc. This way, even if the application server is compromised, only the sProc interface can be attacked. No one can do DROP users_master. While I agree with the principle, I hate the implementation. Unfortunately, some security paranoid clients (banks) want us to do exactly that. Also, the DBAs hate tuning access privileges on 200+ sProcs, they want as-few-as-possible items to audit.Question:Is there any other implementation that provides same level of security, but is more cleaner ? | Secure DAL Design using Stored Procedures | security;database design;stored procedures | Sprocs are very good for implementing a secure data access layer - you write sprocs for reading and writing data, and give the client execute access to the sprocs only - no access to the underlying tables or views. This gives your DB an API that clients use, in much the same way as any class implemented in your business logic code would, but much more secure. It prevents the kind of exploits we keep reading about in the news where some hacker has gained access to every user's password - if the only way to access a password was via a sproc, the attacker who gained access to the DB could only retrieve 1 password at a time, running select * from users just isn't possible once he's bypassed your publicly-facing servers.In addition, you can partition your back-end DB into schemas so that some sprocs cannot even access other parts of the DB. In short, its a nice way of implementing a controlled API for the DB rather than just letting anyone run whatever query that feel like against it. You can obviously improve performance using sprocs for data access that requires complex queries, and you can re-implement your back-end schema without any client realising its changed. I worked in a highly secure system a few times (financial) that required the front-end web site access business logic in a middle-tier service, the service was secured so only the web server could access it, it in turn called sprocs on the db that were in turn secured so only the middle tier services that needed access to them were allowed. It might seem over complex but once you'd done the first example of each part it was very easy to understand where to put other features. It also meant specialists could write the relevant parts of the application (ie web, service or sql) and they'd come together later in integration.I wouldn't like to write a single sproc that caters to all API calls - that's total pants. The DBAs should be happy with several sprocs, they can review and audit only changes then - and not audit the entire thing for 1 piddly change. |
_unix.224008 | I work with people from multiple timezones and I loved how I could have several displayed under my main time in gnome2 (I was using scientific linux). I happen to have a screenshot of it as you can see below.However on Fedora 22 (KDE 5.12) the timezone panel sucks. It doesn't even show when one time is for a different date. How could I go about getting something like the first picture on KDE? Or at least something better than what is there now. | Looking for something like the gnome2 weather clock for KDE | fedora;kde;plasma | null |
_softwareengineering.188903 | I'm developing a board game that has a game class that controls the game flow, and players attached to the game class. The board is just a visual class, but the control of the movements is all by the game.The player can try to make false movements that lead to the game telling the player that this kind of movement is not allowed (and tell the reason behind it). But in some cases, the player can just make a movement and realize it's not the best move, or just miss click the board, or just want to try another approach.The game can be saved and loaded, so an approach could be storing all the data before the movement and not allow a rollback, but allow the user to load the last autosaved turn. This looks like a nice approach, but involves user interaction, and the redrawing of the board could be tedious to the user. Is there a better way to do this kind of things or the architecture really matters on this thing?The game class and player class are not complicate so it's cloning the classes a good idea, or separate the game data from the game rules a better approach, or the saving/loading (even automatic on an asked rollback) is ok?UPDATE: how this game works:It has a main board where you make moves (simple moves) and a player board that react on the moves makes on the main board. It also has reaction moves according to other player moves and on yourself moves.You can also react when is not your turn, doing things on your board. Maybe I can't undo every move, but I like the undo/redo idea floating in one of the current answers. | What would be the best way to store movements on a game to allow a rollback? | game development;class design | Why not store the history of all moves made (as well as any other non-deterministic events)? That way you can always reconstruct any given game state.This will take significantly less storage space than storing all of the game states, and it would be fairly simple to implement. |
_scicomp.25471 | I'm developing my own generic Runge-Kutta solver, and I'm currently implementing the adaptive step-size routine. I say generic because I want to be able to test different RK implementations by only passing the solver a Butcher tableau, such as the following.\begin{array}{c|cccc}c_{1}&a_{11}&a_{12}&\dots &a_{1s}\\c_{2}&a_{21}&a_{22}&\dots &a_{2s}\\\vdots &\vdots &\vdots &\ddots &\vdots\\c_{s}&a_{s1}&a_{s2}&\dots &a_{ss}\\\hline &b_{1}&b_{2}&\dots &b_{s}\\&b_{1}^*&b_{2}^*&\dots &b_{s}^*\\\end{array}Currently, I'm only focused on adaptive-explicit methods. As far as I understand it, a non-adaptive method would only have only the first row of $b$, and an explicit method would be zero on the diagonal and upper triangle.Essentially what I'm doing within a single iteration of my solver is passing a timestep span [$t_0, t_1$], and initial guess of the step ($h$), and an initial value of $y_0$, which could be a vector, and the function $\frac{dy}{dt} = f(t, y)$.I calculate $y(t_0 + h)$ and $y^*(t_0 + h)$ using coefficients of the Butcher tableau, calculate the element-wise error between them, and then calculate a scaling factor of the step using the maximum absolute error. The scaling factor is used to determine if $h$ is too small, a good size, or too big, and is adjusted accordingly. Currently, I'm calculating the scaling factor like this (described in this youtube video):$$ s = \frac{\epsilon \cdot h}{2 \cdot (t_1 - t_0) \cdot max(|y-y^*|)}$$where $t_0$ and $t_1$ are the beginning and end of the time step of interest, and epsilon is some error parameter set previously (e.g. 1e-8).The resulting value of $h$ would be scaled using $s$:$$h = sh$$If s is larger than 2, then I assume the error between $y(t_0 + h)$ and $y^*(t_0 + h)$ is small and I can continue with the next step. If s is less than 1, then I adjust h without moving forward and try the same timestep again. If $s$ is between 1 and 2, then I move on as well, but I don't adjust h because it's good enough.What as not readily obvious to me at the start, but now becomes so as the $tspan$ increases ($t_1-t_0$ goes up), is that the acceptable h is kept really far down. This also seems to be greatly influenced by the RK method used.For example, the following system takes about 2 seconds on my laptop with 100 pts between [0, $4\pi$]:\begin{array} {rl}y_1'(t) &= y_2 \\y_2'(t) &= -y_1 \\y_1(0) &= 0 \\y_2(0) &= 0.1 \\\end{array}Decreasing the number of sampling points to 10 within the same range ([0, $4\pi$]) now takes 16 seconds because I think the value of s is too small, due to the $t_1-t_0$ term.It may be that I'm only interested in a very few number of points (or even the final value), but this is causing the solution time to increase, even for this relatively small problem.Can someone point me to a reference that goes into more detail about this scaling ($s$) parameter? Or is there another way to solve this approach this problem? | Scaling step size in adaptive runge-kutta method | ode;runge kutta | null |
_cstheory.7207 | Being a software engineer for the most part of my life I have absolutley no idea how to start with publishing an academic kind of paper. During my latest research I've found an interesting algorithm for the task I've been solving (related to some calculations on financial markets). It's not some great result but I think it can be interesting for people doing the similar tasks and I'd like to publish it. I'm of course familar with a style of research papers since I use them extensivly at my job (thanks to Google Scholar and all the good people out there) and I'm able to google for free manuals on academic writing style and how to use LaTeX and I have a lot of friends mathematicians who will check my paper and help to make it look ok. But I have absolutely no idea what to do next! I don't belong to any academic institution or recognizable research entity, I work in a small local company, which will be happy to have its name on some paper published but this name will say nothing to anybody. I don't know anybody who is doing research in this area, I mean I've never communicated with anybody. How can I found the right place to send paper to? Do I need some sort of recommendation or review and how and where can I try to get them? What are my steps?.. I realize that all these are absolutely obvious things for you if you are a professional sceintist but I have no idea where to start :) | How to publish a paper? | soft question;research practice;paper review | Something to consider: try to figure out if you want to present your work at a scientific conference, or if you would prefer to publish it in a scientific journal.Pros of conferences:A conference talk will typically get more visibility than a journal paper, at least in short term. I guess fairly few researchers read journals regularly, but many of them take part in the main conferences of the field almost every year. At a conference you can also more easily discuss your work with other researchers.Pros of journals:Journal reviews are usually much more thorough than conference reviews. If you submit to a journal, you will get useful feedback on your work, regardless of whether it is accepted for publication. If you submit to a conference, this is not necessarily the case.A conference talk will also mean a nontrivial amount of expenses: flights, hotels, conference registration fees, per diem allowances, etc. can easily be in the ballpark of 1000-2000 EUR, and it might be a good idea to first check if your company is willing to support you. Submitting to a journal is much easier from that perspective: typically, it is 100% free. |
_codereview.51726 | I have this JavaScript excerpt, and I was wondering if this (primarily the usage of switch case) would be considered good practice. One item of note is that I have it separated into two similar parts to not evaluate the same boolean check over and over again when it is static the whole time.if (strict) { for (var i = 0, len = node.properties.length; i < len; ++i) { var other = node.properties[i]; if (other.key.name !== prop.key.name) continue; var otherKind = other.kind; switch (kind) { // used as a kind of goto case init: case get: case set: if (otherKind === get || otherKind === set || otherKind === init) raise(prop.key.start, Redefinition of property); }} else if (sawGetSet)) { loop: for (var i = 0, len = node.properties.length; i < len; ++i) { var other = node.properties[i]; if (other.key.name !== prop.key.name) continue; var otherKind = other.kind; switch (kind) { // used as a kind of goto case get: case set: if (otherKind === init) break; case init: if (otherKind === get || otherKind === set) break; default: continue loop; // skip the below portion, don't throw error } raise(prop.key.start, Redefinition of property); }}Should I rewrite it like this, something else, or leave it as is? (Speed still is important.)if (strict) { for (var i = 0, len = node.properties.length; i < len; ++i) { var other = node.properties[i]; if (other.key.name !== prop.key.name) continue; var otherKind = other.kind; if ((kind === init || kind === get || kind === set) && (otherKind === get || otherKind === set || otherKind === init)) { raise(prop.key.start, Redefinition of property); } }} else if (sawGetSet)) { for (var i = 0, len = node.properties.length; i < len; ++i) { var other = node.properties[i]; if (other.key.name === prop.key.name) continue; var otherKind = other.kind; if ((kind === get || kind === set) && (otherKind === init || otherKind === get || otherKind === set)) { raise(prop.key.start, Redefinition of property); } else if ((kind === init) && (otherKind === get || otherKind === set)) { raise(prop.key.start, Redefinition of property); } }} | Code to initialize, set, or get node properties | javascript;comparative review | null |
_unix.73037 | When I open Gajim and try to connect to my gmail account, it gives me the following:Warns about an insecure connection:When I choose to connect insecurely, authentication fails, although my gmail username and password are correct:Shows a programming error window:The details are:Traceback (most recent call last):File /usr/share/gajim/src/dialogs.py, line 1538, in on_response_okself.user_response_ok(self.is_checked())File gajim.py, line 2238, in on_okgajim.connections[account].connection_accepted(data[0], 'plain')File /usr/share/gajim/src/common/connection.py, line 739, in connection_acceptedon_auth=self.__on_auth)File /usr/share/gajim/src/common/xmpp/client_nb.py, line 445, in authself._on_doc_attrs()File /usr/share/gajim/src/common/xmpp/client_nb.py, line 470, in _on_doc_attrsif not self._sasl or self.SASL.startsasl == 'not-supported':AttributeError: NonBlockingClient instance has no attribute 'SASL'How can I fix this? I'm on Mandriva 2010.1 | Gajim can't connect to gmail anymore | gajim | null |
_softwareengineering.221622 | I'm relatively new to TDD and have been thinking a lot about how to manage the perpetually growing pool of tests that comes with it.One of my biggest concerns is about false positives.In my experience, it's not uncommon at all for a feature to undergo fairly massive changes over time. To implement a change we would first write a test (or many tests) for the new behaviour and then code the change. Ideally, all the tests would pass once the feature change has been correctly implemented.But what about the tests that covered the first incarnation of the feature? There is no guarantee that:they are still relevant;they still pass;their pass/fail status is even correct.Reviewing/updating/deleting these tests in a relatively small pool of tests may be manageable, but what about when you have thousands or tens of thousands of tests? It seems to me that there is a big risk that your collection of tests will eventually contain many false positives. And, considering that these tests are a form of system documentation, this is pretty bad!Question: How do you mitigate the risk of accumulating False Positive tests when applying TDD or BDD (or anything that eventually leads to having a massive collection of tests)? | Managing false positives in TDD or BDD | testing;unit testing;tdd;maintenance;test management | The key is to have all your tests clearly refer to the precise bit of functionality they are supposed to test. It can be via very expressive test names and strict one-assert-per-test discipline, or really clever subdirectory structure in your test suite, or references from test suite to source code, or whatever. The point is that you can quickly identify which tests will become obsolete.Then you delete them.That sounds foolhardy, but every major change deletes some functionality and replaces it with new, different functionality. If you're using TDD, you're going to write new tests for every bit of that anyway, and fixing old tests instead of forging ahead with new tests and production code is just a waste of time. And this is why questions of organization, coupling, coherence etc. etc. are just as important in test code as in production code! |
_scicomp.11323 | I am trying to implement BFGS. The purpose is to approximate Hessian matrix only (not using the quasi-newton optimization steps), so i am using steepest ascent for optimization. What I observe is that the final Hessian approximate is very sensitive to the initial guess of Hessian. If I start with Identity matrix, most of the singular values of final hessian is closed to 1. Similarly if I start with any multiple of identity (let's say 5*I), the singular values of final Hessian is closed to 5.It is a maximization problem, and also the solution is not unique so i expect a negative semi-definite Hessian matrix.I hope my question is clear.Thanks in advance. | Effect of Initial guess B (approximate Hessian) on BFGS algorithm | optimization;approximation algorithms | null |
_unix.61231 | I want to move files from server1 to server2.A producer on server1 will keep generating the files, and a consumer on server2 will keep processing them.I can copy files using the following shell script:rsync path/*.txt server2:/pathThe extension of the files on the destination (server2) will be changed from .txt to .done once they are processed, so if I run the command again, the files will once again copied (and processed) to the destination.Hence, I want to delete (or rename or move) the original files so that they won't be transferred again.I am using rsync version 2.6.3, which does not have --remove-source-files option.I am new to shell scripting, so please give an example. | how to move (not copy) files from one server to another? | shell script;rsync | null |
Subsets and Splits