id
stringlengths
5
27
question
stringlengths
19
69.9k
title
stringlengths
1
150
tags
stringlengths
1
118
accepted_answer
stringlengths
4
29.9k
_webmaster.95328
We have just built the official website for our company, but it is not listed in the results returned by google even if users input the full name of our company. Instead,the search results are all news reports about our company from other media outlets and very dated.
The official website of our company is no where to be found on google. How can we put it to the top position among other search results?
seo;google
null
_webmaster.101627
For some malware, google shows this under search result of Duggal Visual Solutions. Fixed all of them on 23rd november, asked for review. No response from them. 3 days ago, I've updated sitemap, submitted on google, updated robots.txt, fetched and rendered all the problematic urls. Those urls shows a 404. But the notice is still there. Google isn't doing anything. What should I do now to remove this? Company is losing customers for this. Is there any way to contact google directly?*It is not duplicate because we still have review option and we check/recheck all the pages every 5 hours. Indexed all pages on google and google shows fetched. However it can be SERP cache or GWT delay but it would be great if I there are any system to contact a google agent directly.
Google showing This site maybe hacked under search result
google search console;hacked site
null
_codereview.85501
I am working on an API that is mostly intended to be used interactively/little scripts. There are some classes with methods that could act slightly differently depending on the intention of the user, I have explored several options and would like to get some feedback on caveats, and alternative options.I will use a simple example:class Motor(object): def __init__(self, name): self.name = name self._blocking = True def move_to(self, position): self.block_until_idle() # protects from conflict in any case #internal move call here if self._blocking: self.block_until_idle() else: self._blocking = True def block_until_idle(self): #internal status query loopI want to use an instance of Motor in two ways (dictated by the value of _blocking attribute)The movement call blocks until idle, because I want to take a picture at that position.The movement call returns ASAP, because I want to do other things meanwhile (for example move a completely different motor).There are many different calls (not only move_to) that would follow this pattern.The wish: Usage like:motor = Motor(A)motor2 = Motor(B)motor.move_to(20)# > wait until donenoblock(motor.move_to(50)) # > returns immediately so I can move anothermotor2.move_to(30)So, in summary, the desire is that it is quick and fast to switch between behaviors, preferably within the same line of code and without lasting side effects.Explored but discarded options:Manually handling the flag variable: potentially dangerous (easy to forget), three liner every time.Duplicate the methods into blocking and not blocking: API duplicates in size.Context manager: Taking care of the flag and cleaning up the logic in the move_to method. Still a bit too verbose for my taste, specially for command line (I skip the context manager code). Note that the advantage of the context manager of being able to unblock many calls is not useful here, since the pre-blocking safety would kick in and only the last call would be affected. Also heavy to combine several unblocked motors.with noblock(motor) as nbmotor: nbmotor.move_to(25)Extra parameter: requires changes on each method, polluting call signature, still the best of the trivial optionsdef move_to(self, position, blocking = True):Decoration / wrapper: I did not make it work so far in a way that would not scare users:# syntax error, decorators do not work this way, and besides two liner@noblock motor.move_to(20) # hi is evaluated before polite is appliednoblock(motor.move_to(15)) # almost, but problems to extract self inside the wrapper, the syntax starts to get trickynoblock(motor.move_to) (20) # this works, but awful!noblock(Motor.move_to) (motor2, 15) My best solution so far:Some twisty implementation, but can be invoked in a single line.class Motor(object): def __init__(self, name): self.name = name self._blocking = True self.noblock = Noblock(self) def move_to(self, position): self.block_until_idle() # protects from conflict in any case #internal move call here if self._blocking: self.block_until_idle() else: self._blocking = Trueclass Noblock(object): def __init__(self, other): self.other = other def __getattribute__(self, name): if name in [move_to]: #list of methods we intercept self.other._blocking = False return self.other.__getattribute__(name) else: return object.__getattribute__(self, name) motor = Motor(A)motor.move_to(20)# > waitmotor.noblock.move_to(20)# > returns ASAPThoughts? Any wrapper/decoration strategy that I missed and does the same?
Synchronous and asynchronous motor movement
python;asynchronous;meta programming;device driver
#almost, but problems to extract self inside the wrapper, the syntax starts to get tricky noblock(motor.move_to) (20) What's tricky? def noblock(motor_method,arg): motor_method.im_self._blocking = False motor_method(arg)Or def noblock(motor_method): motor_method.im_self._blocking = False return motor_methodOr catch non-existing attribute access in the Motor class. def __getattr__(self,attr): if attr == 'unblock': self._blocking = False return self raise AttributeError('{} object has no attribute {}'.format(self.__class__.__name__,attr)) Now, motor.unblock.move_to(20) should work.
_webapps.41341
In Google Analytics, is there a way to view the browser/device information for a specific URL? For example, when I have an URL like /specialoffer, is there a way to view the browser/device usage for only this URL?
Google analytics - View device for specific URL
google analytics
In your Google Analytics Account. Click on the Visitors FlowA nice graphic user interface will be shown and choose your Filter choice, i.e. Browser and the whole analysis will be shown.Besides, this answer might also be what you are looking for.Can I use Google analytics to get page view stats for several pages over time
_softwareengineering.215700
What is the best approach for the following scenario:1) A publicly available app (available in app stores) which is used by end users to make use of services offered by multiple companies.2) These companies maintain their services also using a mobile app.I'm not sure on how to solve the second part. Having one app for both enduser and admin functionality, secured by username/password doesn't sound like a good idea. This would leave the only option of developing a separate admin application for the companies.What is the best approach to deploy admin like mobile apps to companies only, for Android, iOS and Windows Phone?Some additional information:Public App ----> Servers -----> Multiple Company AppsThe public app shows all companies offering their services. An end user uses the public app to order something from a specific company. The order is sent to our servers. Our servers send the order to the associated company. This order is displayed on the company's admin app and given the option to accept the order.
What is the best approach for deploying apps to companies
deployment;appstore
null
_webapps.61308
I have a Google Apps account as part of my school, but I'm going to be graduating shortly. I want to transfer ownership of my documents to my personal Google Drive account. However, when I do so from the sharing dialog, it tells me that I can only transfer ownership of documents to other people inside of my domain. I don't need changes to sync back to my old Apps account, as that will be deleted. Is there any way to do this?
How do I transfer documents from Google Apps to another Google Account outside of that organization?
google drive;google apps;google documents
null
_unix.202698
On Ubuntu 15.04 I have this file: /usr/local/bin/myscript (it's a script I made).If I run this command under my account, it will do what I need it to do as a root user: sudo /usr/local/bin/myscriptI now want to make /usr/local/bin/myscript run on machine startup, but as a root user (as if I was running the sudo command but without having to type any password). How is this done on Ubuntu 15.04?
How can I run a program as a root user when my Ubuntu 15.04 machine starts up?
scripting;startup
null
_unix.120929
Is it possible to set a tabstop (number of spaces per tab) for the more and less commands? In vi, I've added this line to .vimrcset tabstop=4However when I read through a file with more it still uses 8 spaces per tab$ more style.cssdiv { width: 100%;}Would this be something I could configure in .bashrc or a similar file?
Setting tabstop for bash output
bash;shell;bashrc
from man less: -xn,... or --tabs=n,... Sets tab stops. If only one n is specified, tab stops are set at multiples of n. If multiple values separated by commas are specified, tab stops are set at those positions, and then continue with the same spacing as the last two. For example, -x9,17 will set tabs at positions 9, 17, 25, 33, etc. The default for n is 8.The man page also describes how to set default options for less using setenv or export. Adding LESS=-x4;export LESS to your ~/.bashrc should do the trick
_cs.57977
TL;DR: If you have two entangled qubits in the state $|00\rangle + |11\rangle$, what is the result of applying the Hadamard gate on the second qubit, and why?I am trying to understand $\text{PSPACE} \subseteq \text{QIP}(3)$ (Watrous, 2003), and have troubles understanding the following.Hadamard gate: Given some qubit, one can test that it is in a uniform superposition by applying the Hadamard gate on it as it will map it to $|0\rangle$ in this case,$$H(|0\rangle + |1\rangle) = |0\rangle.$$By measuring it, you have some probability to get a $1$ iff. the qubit was not in a perfectly uniform state.With entanglement: Now, the paper claims that you can use the Hadamard gate to detect entanglement as well. Given two qubits, $x,y$, that are perfectly entangled, you can have them in the superposition$$xy = |00\rangle + |11\rangle.$$I understand that if you measure $x$, then apply the Hadamard gate to $y$, it will not map it to $|0\rangle$ as it will be entirely determinated by the measurement made on $x$.What I don't understand: They do not claim to be able to measure/collapse the qubits that are entangled with the qubits they want to test, so how does it work? If you have two entangled qubits in the state $|00\rangle + |11\rangle$, what is the result of applying the Hadamard gate on the second qubit, and why?Where is it in the paper:When skecthing the protocol at the end of the introduction section (End of first paragraph, page 2):If there is significant correlation between the low-index prover responses and the high-index verifier-messages, the uniformity test [Hadamard gate, measure 0s] will fail with high probabilityWhen discussing the completeness of the protocol, in particular step 2. of the verifier (start of page 8):Next, the verifier applies the Hadamard transform to every qubit in each register of $\bar{R^u}$. If $\bar{R^u}$ now contains only 0 values, the verifier accepts, otherwise the verifier rejects. In short, the verifier is projecting the state of $\bar{R^u}$ onto the state where $\bar{R^u}$ is uniformly distributed over all possible values. It is easy to check that in the case of the honest prover the registers $\bar{R^u}$ are not entangled with any other registers, as each register of $P^u$ depends only on those of $R^u$, and are in a uniform superposition over all possible values. Thus, the verifier accepts with certainty in this case.Also in the proof of soundess, same page
Hadamard gate on entangled qubit
quantum computing
If you mean result in terms of state, then you can compute this by applying the matrix $I \otimes H$ to the Bell state.If you mean what happens operationally, then observe that applying a hadamard gate on each qubit of the Bell state results in no change -- the resulting state is again the Bell state. So, if you apply two hadamard gates in parallel or none at all and then you measure both qubits, you will get perfect correlations between the measurement outcomes (measurement outcomes on the qubits are guaranteed to be equal). However, if you apply a hadamard gate to either the second qubit or the first qubit and then measure both qubits, then the measurement outcomes will be completely independent of each other, that is, the measurement result of the first qubit can be $0$ or $1$ with $50\%$ probability and the measurement result of the second qubit can be $0$ or $1$ with $50\%$ probability, regardless of what was seen in the other measurement.Algebra:Given the state $|00\rangle + |11\rangle$, you can not compute the Hadamard gate by factoring the state and applying a Hadamard to only one qubit, as the state is entangled and cannot be factored into two independent qubits. You can, however, apply the result of $I \otimes H$, which is the operation of applying Identity gate on the first qubit and the Hadamard gate on the second. The resulting operation is, with scaling factor $s$,$$ I \otimes H = \left[\begin{matrix}1 & 0 \\0 & 1\end{matrix}\right]\otimes\frac{1}{\sqrt{2}}\left[\begin{matrix}1 & 1 \\1 & -1\end{matrix}\right]= s\left[\begin{matrix}1 & 1 & 0 & 0 \\1 & -1 & 0 & 0 \\0 & 0 & 1 & 1 \\0 & 0 & 1 & -1 \\\end{matrix}\right]$$For more details on this, see the question How to apply a 1-qubit gate to a single qubit from an entangled pair?.Now, you can pass your entangled state, $\left[\begin{matrix}\frac{1}{\sqrt{2}} & 0 & 0 & \frac{1}{\sqrt{2}}\\\end{matrix}\right]^{T}$ for $\frac{1}{\sqrt{2}}|00\rangle + \frac{1}{\sqrt{2}}|11\rangle$, through the gate and get$$s\left[\begin{matrix}1 & 1 & 0 & 0 \\1 & -1 & 0 & 0 \\0 & 0 & 1 & 1 \\0 & 0 & 1 & -1 \\\end{matrix}\right]\left[\begin{matrix}\frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}}\\\end{matrix}\right]= \frac{1}{2}\left[\begin{matrix}1 \\ 1 \\ 1 \\ -1\\\end{matrix}\right]$$Which is the state $$|00\rangle + |01\rangle + |10\rangle - |11\rangle.$$And measurement of the first qubit or the second qubit would be 0 or 1 with equal probability, and give no information on the state of the other qubit.
_unix.314389
I use Kali Linux and I am having a problem in running the CiscoPacketTracer7.0.I have downloaded the PacketTracer70_64bit_linux.tar.gz file from www.netacad.com/group/offerings/packet-tracer/. And then I extracted the tar.gz file by writing the commandtar -zxvf PacketTracer70_64bit_linux.tar.gzThen I got into the folder PacketTracer70 which got created automatically after extraction.The folder contents were as follows:Then I ran the ./install command in the terminal and I got the following:root@hacker:~/PacketTracer70# ./installWelcome to Cisco Packet Tracer 7.0 InstallationRead the following End User License Agreement EULA carefully. You mustaccept the terms of this EULA to install and use Cisco Packet Tracer.Press the Enter key to read the EULA.......Then I accepted the terms and conditions as usual...Then I was asked to install the package in opt/pt folder and I agreed as follows:then I got to the folder /opt/pt and triedroot@hacker:~# cd /opt/pt root@hacker:/opt/pt# packettracerBut nothing happened after that. It just gave me the message Starting Packet Tracer 7.0 and nothing happened.root@hacker:~# cd /opt/ptroot@hacker:/opt/pt# packettracerStarting Packet Tracer 7.0root@hacker:/opt/pt#I am trying this second time and getting the same problem. How can I fix this problem?
Not able to run Cisco Packet Tracer 7.0 even if installation is successful
software installation;kali linux;cisco
null
_webmaster.14264
Working with ~100,000 products. Currently the way I'm using has the following priorites (most to least)Model information such as name and model number of a given product Product line's associated keywordsThe site's global keywordsIs this a good way to generate quality meta tags and content? Should globals be more prominent or is it best to prioritize what makes each page different?
What keyword should come first in a product page's meta tags?
seo;keywords;dynamic;meta tags
Since meta tags have no influence on your page's rankings, but can be used in a page's listing in the search results, I would make sure the description tag is written like a sales piece. It can be the deciding factor for users when deciding which search result to click on. The keywords tag is obsolete so I wouldn't worry about the order of the keywords in there.
_cseducators.64
I'm interested in introducing version control to a HS CS class, and was considering starting with Github since it's a fairly standard tool used by developers.What are pre-requisites for understanding version control that I should make sure students master first?Any suggestions on other ways to introduce this topic to students are definitely welcome!
What are pre-requisites for teaching version control to a high school CS class?
github;version control
null
_webmaster.100788
I have a JS generated page with modal windows. Modal window in this case is a plain popup, which code inserted in main page by the script. Modal window opens by clicking on an anchor link (e.g. <a href=#somewindow>open window</a>). It does not change the url (so when it opens the url still will be mysite.com/home#somewindow ). Window code is not present on original page.Will content of these windows be indexed? Will these windows appear in search results as different pages?Should I include these URLs in sitemap.xml file?
Does google index dynamic content under anchor links?
seo;google search
null
_cs.64870
i already search about FSA implementation, but what i found is FSA implemented to something like fending machine. I want to ask about FSA, it was possible Finite State Automata implemented into a search engine?
Finite State Automata Implementation
algorithms;algorithm analysis;finite automata;search algorithms;exact string matching
null
_codereview.52607
I am aware JavaScript does not have the concept of constant variables, which in traditional languages, you would usually define as being static/class related since there's no point in having them defined in each object instance.So we have to make do with defining regular vars in uppercase, and just treating those like constants.But I wondered whether there's a particular style to make it clearer to other developers that this variable is a constant, other than to define it in uppercase. I have the following plugin I am writing: (function () { var URL_KEY = 'CurrentURL', appName = 'MyApp', directoryName = 'MyAppDir'; function GUID() { function s4() { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1); } return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); } function setURL(domain) { if (!domain) { throw 'domain parameter required'; } localStorage.setItem(URL_KEY, domain); } function getURL() { return localStorage.getItem(URL_KEY) || null; } window.App = window.App || { name: appName, directory: directoryName, createGUID: function () { return GUID(); }, getURL: function () { return getURL(); }, setURL: function (newURL) { setURL(newURL); } };}());My constant currently is URL_KEY - which is blending into the regular variables which is confusing. Is there any particular style recommended to separate the constants and the regular variables?I am aware there is just one variable currently, but as this module grows there will be more.
Defining constants in JavaScript
javascript;constants
You could a least separate the variables declarations into constants and variables:var URL_KEY = 'CurrentURL';var appName = 'MyApp', directoryName = 'MyAppDir';You could alternatively make a function that returns the constant.function URL_KEY() { return 'CurrentURL'; }Replacing a function (like URL_KEY = function() {...}) might be more of a mental barrier for some.
_scicomp.8561
For my series on mechanical systems with Lagrange, I would like to add the double pendulum and a rolling pendulum. I set up the Lagrangian $L$ and solved for the ODE of motions, and got the following:$$ \ddot x = - \frac l{2m} \cos(\phi) \ddot \phi + \frac l{2m} \sin(\phi) \dot \phi^2 $$$$ \ddot \phi = - \frac m{2l} \sin(\phi) \dot \phi + \frac{mg}l \sin(\phi) - \frac{m}{2l} \ddot x \cos(\phi) + \frac{m}{2l} \dot x \sin(\phi) \dot \phi $$I am using the ODE solver scipy.integrate.odeint, and it takes a function $\vec f$ so that:$$ \frac{\mathrm d}{\mathrm dt} \vec y(t) = \vec f\left((\vec y(t), t\right) $$If the functions were not implicit, I would just do the following approach:$$\frac{\mathrm d}{\mathrm dt}\begin{pmatrix}x \\ \phi \\ \dot x \\ \dot \phi\end{pmatrix}=\begin{pmatrix}\dot x \\ \dot \phi \\ \text{RHS of first equation} \\ \text{RHS of second equation}\end{pmatrix}$$My problem is that I do not know $\ddot x$ and $\ddot\phi$ to plug in into the the calculations. So far, I have tried putting the second (hand written) equation into the first, then calculating $\ddot x$. Then I would calculate $\ddot \phi$ with that value of $\ddot x$. The result were strange results and stability issues.How would I integrate this entangled system of equations?Update 2013-09-22 14:56:21+02:00My current function $\vec f$ is the following. I plugged $\ddot \phi$, i. e. the second equation, into the first equation and solved for $\ddot x$ so that I have an equation in $\ddot x$ without any other second derivatives on the RHS. My Python code is the following, where I just divided by $1 - \cos^2(\phi)/4$ in the first equation:x = y[0]phi = y[1]dot_x = y[2]dot_phi = y[3]ddt_x = dot_xddt_phi = dot_phiddt_dot_x = (- self.l / (2 * self.m) * np.cos(phi) * (- self.m / (2 * self.l) * np.sin(phi) * dot_phi + self.m * self.g / self.l * np.sin(phi) + self.m / (2 * self.l) * dot_x * np.sin(phi) * dot_phi) + self.l / (2 * self.m) * np.sin(phi) * dot_phi**2) / (1 - 1/4 * np.cos(phi)**2)ddt_dot_phi = - self.m / (2 * self.l) * np.sin(phi) * dot_phi + self.m * self.g / self.l * np.sin(phi) - self.m / (2 * self.l) * ddt_dot_x * np.sin(phi) + self.m / (2 * self.l) * dot_x * np.sin(phi) * dot_phireturn [ddt_x, ddt_phi, ddt_dot_x, ddt_dot_phi]When I try to integrate this, I get results that do not really reflect any physical effect. You can see that in the animation that does a sudden twitch.
Convert an implicit ODE system to an explicit ODE set to use Runge-Kutta
ode;runge kutta
null
_unix.236336
I need some tool like this one for Linux. I need not a GUI (i.e. GUI/CLI -- this is not so important), but I need to be able to make a server which can listen at any port, receive and send a raw (i.e. a hex dump) data.
Is any solution to make interactive TCP/UDP server under Linux?
linux;tcp;udp
There is a patch for socat v.2.0.0.b8 which makes it possible.Thank all who answered.
_cs.47697
I'm reading CLRS Section 33.4 Finding the closest pair of points. At exercise 33.4-2 they say33.4-2Show that it actually suffices to check only the points in the 5 array positions following each point in the array Y'But I'm getting 4 array positions following each point in the array Y' will be suffice to check. See the fig belowWhich possibility I'm missing. Can anybody point it out.
Understanding Closest Pair Algorithm (CLRS)
algorithms;computational geometry;divide and conquer
Assume that a point exists in every corner in the figure (including the inside corners). If points cannot overlap, then you have 6 points that can reside in the x2 box, and since you must be looking at one of them, you need only compare it to the next 5 in Y'.
_cogsci.13775
I'm writing a research paper and I'm wondering if someone can help me out by throwing out a few terms. I'm looking for a theory that talks about how the more difficult a task is, the more authoritative / appreciated is the person who completed the task.For example, let's say Exam A is only passed by 5% of people that take it. Is there a cognitive theory that says that people who pass the exam will be more appreciated / seen as more authoritative given that they completed a task most fail at?
Does difficulty of task increase perceived authority?
social psychology;terminology
null
_softwareengineering.254717
It is a language agnostic question, e.g. I have a unit test like# Unit testUser user = User.create('john');assertEquals(User name is john, john, user.getName());# Web test start from heregoTo(/user/john);assertTitleEquals(john);Do you think it is an anti-pattern? Although I can write a full selenium test suites to do the same thing, but using the above code save much of my time (e.g. no more click('Login'); waitUntil etc, and I don't need to worry if my UI is changed at all, sound like it is a quick and more stable approach to test?
Is it anti-pattern to mix unit test and web test?
unit testing;testing;tdd;integration tests;acceptance testing
null
_unix.293570
I'm using Debian Jessie as a virtual machine host using libvirt/qemu/kvm.I've set some of the guest virtual machines to automatically start when the host OS boots up, this is working fine.For maintenance purposes, I'm running service libvirt-guests stop to shut all the guests down (but not the host).Once I've done my maintenance, I want to easily boot all the guests up again (without rebooting the host).Is there a single command that will start all the guest VMs up again? I'm interested in knowing about both:a command to start all the autostart-marked guests up againa command to start all the guests up again that were running before I ran service libvirt-guests stopRebooting the host OS would achieve #1, but I don't want to reboot the host. I tried, service libvirt-guests start but it doesn't seem to do it.
libvirt: command to start up all guest virtual machines which have auto-start enabled
virtual machine;kvm;qemu;libvirtd;libvirt
null
_softwareengineering.258725
I am attempting to implement an algorithm that takes in a massive array of data, and iterates through each element in this array. For each element, it will either create an new array and put the element inside it or insert it in some existing array based on qualities of the element. How to decide which language is the best for implementing this algorithm that will iterate through an extremely large array of data?My initial guess would be a high level language such as Java or Python but I am interested if there are advantages to using other languages to implement this algorithm.
How to decide in which language to write an algorithm that iterates through large amounts of data?
algorithms
Don't get hung up on this. It is paralysis by analysis. What if I told you Haskell was the best language? Would that help you? What if you don't know Haskell?That is why this is subjective and off-topic, but it is still an issue that beginners struggle with (Which language is better...)The best language for you, right now, is the language you are most comfortable with, assuming it is compatible with the problem environment. Worrying about language before you start implies you are worried about performance, but since you've written nothing to measure, yet, you don't have a performance problem, so this is a form of premature optimization. Don't optimize prematurely.However, in interest of pragmatism, I cannot honestly think of a top-20 language that is not a good language for what you describe. That is, until you observe a performance problem. And any language has the potential to exhibit a performance problem.
_unix.29086
We have nearly 50 systems with windows XP and have Linux (RHEL6) for server.Also have squid 3.1 , Samba and Apache for local use.Under proxy, VPN and outlook express does not connected. I heard that transparent proxy will fix this problem. I have tried steps from internet and stack-exchange. But i can't fix this issue fully. Please give clear configuration file and configuration for IpTables.Here my squid conf file.## Recommended minimum configuration:#acl manager proto cache_objectacl localhost src 127.0.0.1/32 ::1acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1## Example rule allowing access from your local networks.# Adapt to list your (internal) IP networks from where browsing# should be allowedacl localinternet src 10.1.1.0/24##acl localnet src 10.0.0.0/8 # RFC1918 possible internal network##acl localnet src 172.16.0.0/12 # RFC1918 possible internal network##acl localnet src 192.168.0.0/16 # RFC1918 possible internal network##acl localnet src fc00::/7 # RFC 4193 local private network range##acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines## Special IP Listacl special src /etc/squid/special.txt # All Access IPs# Allowed IP Listacl d_unlimited src /etc/squid/d_unlimited.txt # Full Download accessacl u_unlimited src /etc/squid/u_unlimited.txt # Full Upload accessacl allow_proxy src /etc/squid/allow_proxy.txt # Allow Proxyacl allow_social src /etc/squid/allow_social.txt # Allow Social networkingacl allow_tutorial src /etc/squid/allow_tutorial.txt # Allow Tutorialacl allow_movie src /etc/squid/allow_movie.txt # Allow Jobsacl allow_jobs src /etc/squid/allow_jobs.txt # Allow Movieacl allow_sex src /etc/squid/allow_sex.txt # Allow Sex## Blocked Keys#acl goodkey url_regex /etc/squid/goodkey.txtacl proxy url_regex /etc/squid/proxy.txtacl social url_regex /etc/squid/social.txtacl tutorial url_regex /etc/squid/tutorial.txtacl movie url_regex /etc/squid/movie.txtacl jobs url_regex /etc/squid/jobs.txtacl sex url_regex /etc/squid/sex.txt## Upload/Download Limit#request_body_max_size 2000 KB localinternet !u_unlimitedreply_body_max_size 6000 KB localinternet !d_unlimited##acl SSL_ports port 443acl Safe_ports port 80 # httpacl Safe_ports port 21 # ftpacl Safe_ports port 443 # httpsacl Safe_ports port 70 # gopheracl Safe_ports port 210 # waisacl Safe_ports port 1025-65535 # unregistered portsacl Safe_ports port 280 # http-mgmtacl Safe_ports port 488 # gss-httpacl Safe_ports port 591 # filemakeracl Safe_ports port 777 # multiling httpacl CONNECT method CONNECT## Recommended minimum Access Permission configuration:## Only allow cachemgr access from localhosthttp_access allow manager localhosthttp_access deny manager# Deny requests to certain unsafe portshttp_access deny !Safe_ports# Deny CONNECT to other than secure SSL portshttp_access deny CONNECT !SSL_ports# We strongly recommend the following be uncommented to protect innocent# web applications running on the proxy server who think the only# one who can access services on localhost is a local user#http_access deny to_localhost## INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS## Example rule allowing access from your local networks.# Adapt localnet in the ACL section to list your (internal) IP networks# from where browsing should be allowed#http_access allow localnet## Allow all / Allow Good keyshttp_access allow specialhttp_access allow goodkey## Allow Proxy Sites#http_access allow allow_proxy proxy## Allow Social Networking#http_access allow allow_social social## Allow Tutorialshttp_access allow allow_tutorial tutorial## Allow Moviehttp_access allow allow_movie movie## Allow Jobshttp_access allow allow_jobs jobs## Allow Sexhttp_access allow allow_sex sex## Allow Listhttp_access allow localinternet !proxy !social !tutorial !movie !jobs !sex## Local Hosthttp_access allow localhost# And finally deny all other access to this proxyhttp_access deny all# Squid normally listens to port 3128http_port 3128# We recommend you to use at least the following line.hierarchy_stoplist cgi-bin ?# Uncomment and adjust the following to add a disk cache directory.#cache_dir ufs /var/spool/squid 100 16 256# Leave coredumps in the first cache dircoredump_dir /var/spool/squid# Add any of your own refresh_pattern entries above these.refresh_pattern ^ftp: 1440 20% 10080refresh_pattern ^gopher: 1440 0% 1440refresh_pattern -i (/cgi-bin/|\?) 0 0% 0refresh_pattern . 0 20% 4320
Transparent proxy with squid 3.1 on RHEL 6
linux;rhel;proxy;squid
null
_unix.28443
It looks like currently most OS installers insist on putting /boot on a non-RAID partition (or the kind of RAID1 partition that looks like a non-RAID partition), even the installers that support RAID5 and GRUB2.I'm guessing this limitation is a historical relic leftover from Grub1.My understanding is that Grub1 doesn't know anything about RAID and so can't boot off any kind of RAID array -- except for RAID arrays that look like a non-RAID array.Is this a limitation of Grub2, or of the OS installers?I've heard rumors that Grub2 is able to support /boot onRAID-0, RAID-1 or RAID-5, metadata 0.90, 1.0, 1.1 or 1.2.Does Grub2 really support putting /boot on a software RAID1 partition with 1.2 metadata?Does Grub2 really support putting /boot on a software RAID5 partition?An ideal answer would link to a tutorial that explains how to move a /boot partition (on a non-RAID partition) to a RAID5 partition.By looks like a non-RAID partition, I mean eitherwhen Grub1 reads only one hard drive of a software RAID1 array with a ext3 or ext4 filesystem and ignores the RAID metadata 0.90 or 1.0 at the end of the partition, it looks just like the a non-RAID ext2 file system that Grub1 can handle.OrNot a software or fake-RAID, but a full hardware raid that looks like a normal non-RAID disk.
Does Grub2 support putting /boot on a RAID5 partition?
grub2;software raid
Yes grub2 is fully raid ( and LVM ) aware. In fact you do not need a separate /boot partition at all; you can just put everything on the raid5.Ideally you want to not install with a /boot partition at all, but removing it after the fact simply means copying all of the files to the root partition, and reinstalling grub, like this:umount /bootmount /dev/[bootpart] /mntcp -ax /mnt/* /bootgrub-install /dev/sdaOf course you then need to remove the /boot line from /etc/fstab, and you still have the partition laying around, just unused.Note you can also grub-install to all of the drives in the raid5 so that you can boot from any of them. The Ubuntu grub-pc package will prompt you ( dpkg-reconfigure grub-pc to get it to ask again ) to check off all of the drives you want it installed on and install it for you.
_webmaster.51867
Re: Google's ad placement policyI have noticed that when clicking on some Forbes links, I am taken to a screen with an ad in the middle - at the top there is a link to skip the ad. Upon clicking on the skip link I am taken to the article I want to view.I want to implement something similar on my sites, where, when clicking on a search result, a the results window first displays one AdSense add on the screen with a similar UI as what I saw on Forbes.Currently, when a user clicks on a result, a new tab/window opens with the result. What I am proposing is that before the result appears, the screen displays a Continue to result link at the top in large letters, and in the center of the page, Advertisement with the ad below.This is the only popup that is user initiated and there are no other popups on the site. Navigation elements are not modified in any way.Will I get penalized by Google for implementing this?
Does a lead-to screen with AdSense ad conform to Google's rules?
google adsense;search results
null
_unix.310433
What does the following /dev related syntax do?mv directory /dev/partition/subdirectoryDoes this just make a new 'subdirectory' in the 'partition' device or what? I guess I've never seen a subdirectory in a disk partition. Is there any special behavior or is this just a normal subdirectory?This code is from this 6 year old post which I hope to implement related to dual boot MySQL sharing the same data dictionary.For reference, here is the complete post with instructions, which itself is from an earlier post referenced at the bottom of it:Yes, it works but with some quirks. MySQL uses the same fileformats across platforms so all you need is to share the data directory. One problem is that the data directory need to have mysql as owner and group in ubuntu. And Windows is case-insensitive and Linux is case-sensitive so keep all names uniform: either the whole name lowercase or uppercase but do not mix them.From start to finish; if you already have things set up this might need some tweaking to fit your setup:Install and setup MySQL on both systems.Stop the mysql server if it is running.Make a new NTFS partition. Mark the device name (let's call it sdXN for now).Move the mysql data directory from Ubuntu to the new partition.sudo mv /var/lib/mysql /dev/{sdXN}/mysql_dataMake a new mysql directorysudo mkdir /var/lib/mysqlMount the NTFS partition at /var/lib/mysql. Change the devicename to what it got when you created the NTFS partition.sudo mount /dev/{sdXN} /var/lib/mysql -t ntfs-3g -o uid=mysql,gid=mysql,umask=0077To automount on boot find the partition UUID and locale and edit /etc/fstab.ls -l /dev/disk/by-uuidlocale -asudo gedit /etc/fstab UUID={number_found_with_the_ls-l} /var/lib/mysql ntfs-3g uid=mysql,gid=mysql,umask=0077,locale={your_locale}.utf8 0 0Change the 'datadir' path in /etc/mysql/my.cnf to point to /var/lib/mysql/mysql_dataStart the mysql server and test it.Edit the Windows config file (my.ini) and set 'datadir' to X:/mysql_data (replace X: for where you mount it under Windows).Compiled from topic 1442148 on UF.org.
mv directory to a device partition's subdirectory, e.g. mv directory /dev/partition/subdirectory?
files;mount;devices
Those instructions are wrong, and you'll get an erroreg% ls -l /dev/vda1brw-rw---- 1 root disk 253, 1 Sep 16 17:45 /dev/vda1% mkdir X% sudo mv X /dev/vda1/Xmv: failed to access '/dev/vda1/X': Not a directoryYou just can't do what that says.
_unix.383180
I have a laptop with Ubuntu 16.06. I am able to execute reboot command as a non-root user without sudo. How can I change this behaviour so that I am not able to run reboot without sudo? I tried checking where reboot actually points:user:~$ which reboot/sbin/rebootuser:/sbin$ ls -l rebootreboot -> /bin/systemctlBut I do not know how to change systemctl behaviour.
Make reboot work only with sudo
ubuntu;sudo;reboot
null
_softwareengineering.98392
I've been reading a bit about software licenses, and I'm having trouble getting my head around the idea of what happens when one wants to change the license. I've read a couple of questions here on the topic and it clarifies things some, but there are still a couple of areas that are unclear to me.One example: Suppose I have a project hosted on github with no license specified. If someone contributes a patch to my code base and I merge it in, does that patch still belong to them? If so, would I need their permission to change the license on my project?Another example: Suppose I have my software under some permissive open source license. I understand that I am allowed to change the license on my software at will (barring conflicts with contributors), but does that effect existing copies of the software out there? If I decide to close source my project, do existing copies of the source with packaged OS license remain open source and distributable according to the previous license?I like the idea of working together with others on projects in a flexible manner, and unless a project actually starts to pick up it seems like unnecessary overhead to go about deciding on an appropriate license. It would be nice to be more aware of the potential conflicts that could crop up, though.
What happens when a project switches to a different license?
licensing
Sounds like a legal question and I'm not a lawyer, but I do have to read up on all this so that my projects don't get into trouble when I use free open source code. I don't think it works the way you hope it does. Imagine if people could change license terms after the fact. Nobody could really ever use open source code along with their own code or else they would risk having the rights to it revoked at any moment. So I think the way it works is that whenever somebody gives up some of their legal rights to software by stating they do so under a license, they can not take those rights back.If you fully own the software you can later release it under another license, but you can't take back anything you gave away already.If anyone contributes anything to your code and you have no agreement otherwise, I believe you can't change the license without the consent of every last contributor (whether you can find them or not). So a lot large open source projects make people agree to give up ownership before they can contribute. Usually they do so in part because of a promise the code will be available under one or more specified licenses. So in your github example you might have a problem, yes.Working in a flexible manner is nice, but you may find after the fact that everyone did not have the same assumptions about licenses, ownership, etc. So it isn't a bad idea to spell it out anyway, even if the law didn't push you in that direction.
_cogsci.3681
The question of whether it is better to be an expert in one domain or average in many is too vague.However, instead, I'd like to focus on the following:Are individuals born to prefer being an expert in one domain or average in many domains? Is there any serious research on this? For example I'd very like to be an expert in swimming but after some time of hard training this activity becomes boring for me. I need to run, I need to play ball team games etc. Conversely, Michael Phelps, world swimmer, incline to be an expert in one branch. We can talk about branch of study, hobbies, sport, social interactions, languages, etc.
Does personality imply an inclination to be an expert in one field or average in all fields?
learning;performance;personality;expertise
I imagine there are many ways of looking at this question. Here are just a few ideas:Society and specialisation:One lens for viewing this question is to focus on the reward structure of our society. There are many forces in society which encourage specialisation and the development of specific expertise. Careers are typically built around developing expertise in a particular domain (e.g., doctors, lawyers, computer programmers, etc.). The nature of the reward structure that is facilitated by large economic markets means that the most popular actors, musicians, and politicians, and the most successful athletes get more of the financial and social rewards than those that just dabble in such activities. The flipside of a specialised society is that you don't need to know how to do many things, because you just pay someone else to do it. Thus, from this perspective, in historical terms society appears to be encouraging expertise more than in the past.General individual differences: The concept of need for achievement refers to an individual's desire for significant accomplishment, mastering of skills, control, or high standards. Self-actualising: You could look at research on how people find meaning in their life and how mastery and expertise fits into that experience. In particular, the journey of acquiring mastery in a domain has often been linked to feelings of meaning and purpose. For example, have a look at something like Self Determination Theory and the role of competence in achieving a sense of personal growth.Expertise and deliberate practice research: There's a substantial body of research that has studied people acquiring expertise in particular domains. Ericsson et al (1993) provides a good introduction to this research. A central claim in Ericsson's model is that deliberate practice is key to acquiring expertise. And given that deliberate practice is optimised for improving performance it may not necessarily be intrinsically enjoyable. Thus, this suggests that the motivation to engage in deliberate practice over an extended period of time may be a key differentiator between those who do and do not acquire expertise. ReferencesEricsson, K. A., Krampe, R. T., & Tesch-Rmer, C. (1993). The role of deliberate practice in the acquisition of expert performance. Psychological review, 100(3), 363. PDF
_unix.194688
I've created a database in the remote machine. Currently, the database is empty and I need to import using a backup(.sql) file. The backup file is in my local machine, it is a 40gb file. And the remote machine has an empty space of about 45gb. So, if I try to upload the backup file into the remote machine, then it will be impossible to import into the database(remote machine will be running out of space). The only possible solution looks like, pointing the server to use the location of the local machine's backup file and to import. Is there any command to work on this?I have tried the following commandsbash > mysql -h hostname -u user -pPassword databasename < /Users/path/to/file/backup.sql > update.logBut, it returns an error sayingbash: no such file or directory. I'm sure the file is present within my local machine.Does any one have any idea on how to import sql file. Or is there any alternate ways to do this?Local machine is running on OS XRemote machine is SUN OS.I'm using SSH to connect with remote machine.
import .sql file into a remote server from a local machine
ssh;mysql;remote;database
null
_vi.10040
I am using the vim-better-whitespace plugin to highlight trailing whitespaces. For some buffers, I don't want this behavior and vim-better-whitespace usually provides an option to list the filetypes where it shouldn't apply.However, I am also using nvim-ipy to integrate with ipython and this plugin opens a new buffer for console output, where filetype is empty and buftype is set to nofile.Is there any way to construct an autocmd to call DisableWhitespace once the respective ipython buffer is created?
Disable vim-better-whitespace highlighting for nvim-ipy buffer
neovim;whitespace
null
_softwareengineering.63383
I have a friend that works for a company. They use a software product that is aged, and written in Delphi. There are concerns at this company about the life of the software company that provides the software (which they pay a monthly license to use). It's quite specific software.My friend has spoken to his boss and I am being invited in with the potential opportunity to re-write their windows application with a view to also supplying source-code (C#, is what I plan to provide should this kick off). Giving this some more thought, and even though it could give me some nicely-needed cash, I wonder what is the best option here...The initial requirement would appear to be to replicate this application exactly as it stands. It was not developed in-house and therefore is used by other companies as-well. It's large and complex. While this does not worry me, I am concerned at the cost and time to do this just to bring it in-house. They don't appear to want any new or different functionality, just a code-base they own.So I guess, my real question; now that you have background information - is it worth me suggesting that rather than re-write this thing dot-for-dot, and feature-for-feature, to actually see what parts they use/don't use - and design an application tailored just for them rather than the generic off-the-shelf one they are using?It seems a huge waste to just duplicate the application just to have ownership, but then I'm a programmer and not a business-decision-maker :)Any ideas/thoughts/flames?
Best opinion to give a potential client
project management;design;applications
Yes!In fact if you don't suggest this - or at least bring it up I would hope that they would be a little concerned.You need to help them read between their own lines. When they say that they want all the feature exactly as the previous application - surly what they are actually saying is we don't want to change our workflow... fine - but I am sure they are not trying to say - and yes and please waste months of effort for those features that we never use and are only there for the other companies.Taking on this role you IMO are not just the developer you are now a consultant and you must try to make sure that you add value to them on both capacity - but they are still the boss so don't get too caught up in the consultant role :-)
_codereview.1558
I have a simplified model that looks like this:class Player < ActiveRecord::Base has_many :picks def pick_for_game(game) id = game.instance_of?(Game) ? game.id : game pick = picks.find {|pick| pick.game_id == id} if !pick pick = picks.build(:game_id => id) end pick endendThe pick_for_game method usually is called a bunch of times when an action is executed. What would be a good way to make this code work efficiently with a list of games?
Find associated object if exists, otherwise generate it in ruby
ruby;ruby on rails
You can use find_or_initialize_by dynamic finder, see a guide hereThis would be equivalent to your code:def pick_for_game(game) game_id = game.instance_of?(Game) ? game.id : game picks.find_or_initialize_by_game_id(game_id)endHope it helps you!.
_unix.378641
So I'm switching VPSs, and have already done a backup of all the data files and moved them over. However I still need to move all the old databases over. I've been searching the internet for the best way of doing so, but am undecided. I attempted to use the mysqldump command, then use scp to transfer the file, and import the database on the new server, however I was getting an error from doing that, and it would be more preferable if I could transfer all databases at once. If that isn't possible, then I would do them 1 at a time but I'll need to get this error fixed.mysqldump: Got error: 2002: Can't connect to local MySQL server through socket ' /var/lib/mysql/mysql.sock' (2) when trying to connectThank you <3
Best way to migrate many SQL databases
linux;centos;mysql;database
null
_datascience.13357
We have a deformable mirror controlled by 40 actuators that have input voltages from -1V to 1V.Prior to hitting the mirrors, a pulse of light enters a diffraction grating and then the light is spread over the mirror by wavelength. Each actuator applies a difference phase shift to each wavelength. In the end, the light gets reconverged and read by a CCD. Our goal is to maximize the integral of the spectrum read by the CCD with respect to the 40 variable voltages. This optimization will be done in matlab. I mostly just need to know what type of problem this is...The program will do something like:Measure a spectrum and integrateInput the new spectrum to the optimization toolbox. Output a new set of voltages to tryGo back to 1There is likely multiple local maxima and the positions will change from day to day as our setup is always changing. Any help on where to look for more information would be much appreciated!
What type of optimization problem is this?
optimization;matlab
null
_webapps.71478
Is there a way to get a list of youtube videos with subtitles in a specific language?Let's say, all videos with French subtitles?
Is there a way to list all youtube videos with subtitles in a specific language?
youtube
null
_cstheory.6771
First off, please forgive my ignorance because I am not as well versed in cryptography and mathematics as I would like to be. I may say something obviously wrong/dumb; please point it out!Is there any technique which may reduce the difficulty of recovering plain text from a hash if the attacker knows part of the plain text?Here is an example.Alice writes this letter:Dear Bob, Run!Yours Truly,AliceAlice sends the plaintext to Bob over channel X and the hash over channel Y.Eve intercepts the hash but not the plaintext.Eve knows Alice starts the message with Dear Bob, and ends with Yours Truly, Alice.Eve also knows that Alice sends messages in fixed blocks and will pad the body content with whitespace to meet the required block length.Can Eve use her knowledge of 1)fixed message size and 2)partial plaintext knowledge to reduce the computational difficulty of reversing the hash?I would appreciate any help on this topic, even if your answer is just read this whitepaper.
Can one reverse a hash with partial plaintext knowledge?
cr.crypto security;hash function;cryptographic attack
For an ideal hash function, the fastest way to compute a first or second preimage is through a brute-force attack. That is, if there's no structural weaknesses in the design of the hash function, your best bet is to mount a brute-force attack.The knowledge of the message size (n bits) and some parts of it (m bits) will certainly reduce the complexity of finding a preimage under the brute force attack: The worst-case complexity will reduce from 2n to 2n-m. A space-time trade-off over the brute-force attack is by exploiting rainbow tables. I believe the partial knowledge of the preimage may prove useful in mounting this attack too.
_softwareengineering.67696
I was wondering about performance issues when parsing a source file that is being edited by the user (for example, when you need to give a syntax highlight).I think that the simplest approach is to parse every time the code changes, get the results, and replace the current code with the highlighted one. With large files this may be a problem though. Is there a better way to do that?I suppose a solution may be to parse just the area where there was the last edit. Is this a good idea?
Performance issues when parsing code
performance;parsing
null
_softwareengineering.319334
I have a program which generates events. They are ordered with a Lamport clock and sent over the network. They may arrive in a different order. On the receiving end I have an object which re-orders the events. This object can be popped like a queue and either returns the next event according to the Lamport clock or fails. It can filter the duplicate events out if any. It is thread-safe so that events can be pushed and popped in parallel.This sounds like a well-known pattern. Is it the case, and if so is there a standard name for this object?
Name for object to re-order events received in arbitrary order?
event;queue;order
null
_unix.192029
The main reason I want this is my heavy use of dircolors, especially for ls --color=auto.For example, whenever a .mp3 file is copied from NTFS, it will have permissions set by umask 022 which ought to be standard value in most modern distros.However, for audio files this makes no sense: due to the fact that their permissions get set to 755 (rwxr-xr-x), they will get the same color as an executable shell script, while I'd really like to have this color reserved for true executables. This is not Windows; even with the x permission set for owner/group/other you cannot expect ./track1.mp3 to work in terminal so that it make an attempt to pick a default console player.So I'd like to have a certain umask ONLY for audio files, i. e. that any files like .mp3, .wav, .ogg and so on would always get set their mode to 644, while leaving all other files copied to this place at their default umask of 022.Is there any way to accomplish this?(NOTE: cp --preserve will NOT preserve original permissions on NTFS either, since NTFS is notoriously ignorant about *NIX permission systematic.)
Setting correct permissions automatically for certain file type when file is copied from non-Linux file system
permissions;chmod;ntfs;file transfer;umask
I would use the install tool to copy from NTFS.install -m644 file1 ... fileN destination_directory
_codereview.165685
I've recently written a Java program that displays a list of Word objects using a ListView and a custom ArrayAdapter.I also want to set an OnClickListener on the items that plays an audio file (specified in the Word class).This is the code I've written for it:WordAdapter.java:/* Set OnClickListener on item */ // Create MediaPlayer for the audio file final MediaPlayer audio = MediaPlayer.create(getContext(), currentWord.getAudioResourceId()); // Set OnClickListener listItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!audio.isPlaying()) { audio.start(); } } });Is there a more efficient way to accomplish this behaviour?
ListView + ArrayAdapter: Setting OnClickListener to items
java;performance;beginner;android
Well it's not about performance in this case, but you could use dependency injection, which means you could pass the instance of the listener outside to the Adapter. Then just saylistItem.setOnClickListener(onClickListner);This could make your code more readable UPDATEExample shows, how to pass an OnClickListener outside from the class. So, I would like to add more code, to make sure we can learn from it together:public class Malacka{ private OnClickListener callbackListener; public Malacka(OnClickListener callback){ this.callbackListener = callback; } public void getView(View view, int position, View parent){ // apply viewHolder pattern here and do your stuff itemView.setOnClickListener(callbackListener); }}
_codereview.14596
I want to get just the first line of a big string. Currently, here's how I do it:def getFirstParagraph(txt: String) = { val newLineIdx = txt.indexOf(\n) match { case i: Int if i > 0 => i case _ => txt.length } txt.substring(0, newLineIdx)}But my friend sees some downfall: if txt is null, there will be an exception. His suggestion involved using var:def getFirstParagraph(txt: String) = { var result = txt scala.util.control.Exception.ignoring(classOf[Exception]) { result = result.substring(0, result.indexOf(\n)) } result}Which will handle the null value fine. Thing is, I'm quite uncomfortable using var. How can I handle this case without using var (aka the Scala / functional way)?
A safer way to cut a string
strings;functional programming;scala;exception handling
scala> def getFirstParagraph(txt: String) = { Option(txt).map(_.takeWhile(c => c != '\n')).orNull }getFirstParagraph: (txt: String)Stringscala> getFirstParagraph(null)res2: String = nullscala> getFirstParagraph(fsdfasf)res3: String = fsdfasfscala> getFirstParagraph(fsdfasf\nxxxxxxx)res4: String = fsdfasfOption(txt) converts txt into an Option[String] which will be None if txt is null.map will execute the takeWhile only if the Option is Some. Finally orNull will pull the value out of the Option if it is Some or evaluate to null otherwise.
_unix.77850
I'm trying to get a launcher working for the WikidPad (python) program.I already have a python program, so I looked into the file /usr/share/applications/taskcoach.desktop. The exec line was simply taskcoach.py.But I cannot start WikidPad just typing WikidPad.py, I have to write python WikidPad.py, then it starts correctly from the command line.So I made the .desktop file for wikidpad, in the exec line I wrote python /home/abc/wikidpad/WikidPad.py.But it seems that you have to be in the same directory in order to get correct results, otherwise there is the error No module named pwiki.Enum.So I changed the exec line into cd /home/abc/wikidpad;python WikidPad.py.But that did also not work, the error message was cd could not be executed, file or directory not found.If I want to execute a Linux command in a bash script and I get an error command/file not found, I adjust the PATH variable or write the full path of the command. That normally helps.But in this case, cd is a built in bash command, and I cannot write whereis cd in order to get the full path of the command.I do not have any idea to get this going.
Launcher for a Python program that requires extra libraries
gnome3;python;path;cd command
null
_unix.216162
I am using Linux RHEL6 and not able to install any package. [root@linux6 Python-2.7.9]# uname -aLinux linux6.4 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux[root@linux6 Python-2.7.9]# ./configurechecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking for --enable-universalsdk... nochecking for --with-universal-archs... 32-bitchecking MACHDEP... linux2checking EXTRAPLATDIR... checking for --without-gcc... nochecking for gcc... nochecking for cc... nochecking for cl.exe... noconfigure: error: in `/usr/src/Python-2.7.9':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details[root@linux6 Python-2.7.9]# Tried with linux32 but no luck:[root@linux6 Python-2.7.9]# linux32 ./configurechecking build system type... i686-pc-linux-gnuchecking host system type... i686-pc-linux-gnuchecking for --enable-universalsdk... nochecking for --with-universal-archs... 32-bitchecking MACHDEP... linux2checking EXTRAPLATDIR... checking for --without-gcc... nochecking for gcc... nochecking for cc... nochecking for cl.exe... noconfigure: error: in `/usr/src/Python-2.7.9':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details
Not able to install any package or software on Linux 64-bit
linux;command line
null
_softwareengineering.6827
This includes architecture decisions, platform choices or any situation where a such a bad choice led to negative consequences.
What's the worst technology decision you have ever seen?
technology;architect
null
_softwareengineering.180798
Note: after writing this I realize that this question is perhaps philosophical, but I'm interested in how the industry handles this scenario regardless.I have recently been working with a code base that is not yet as testable as it should be. I've seen some junior developers check in code that breaks use cases, which is usually identified by another developer a few days after the check-in.Assuming that we can't achieve code coverage yet, are there technical solutions for holding developers accountable for bad check-ins in addition to a non-technical approach; discussing the commit and having the dev address the issue in a new commit.
what is the best way to ensure accountability in code checkins?
code quality;management;teamwork;code reviews
Two simple measures:Code reviews (already mentioned by others) before each check in. You do not need to explain every detail of what you check in, but the reviewer should get an idea of the changes that are being checked in. You can program your RCS to reject check-ins whose check-in text does not contain a tag REVIEWED BY: ....Agree with the rest of the team that if a check-in breaks any unit tests, the developer who has performed the check-in must fix the code until those unit tests are green again (possible measure: write a bug and assign it to him / her). As an alternative: if a team member detects a check-in that breaks the unit tests, he or she can revert the changes. The author of the wrong check-in is not allowed to check-in again as long as the problem is not fixed locally (unit tests are green locally).NOTEPoint 2 has been edited taking into account gnat's comment.
_unix.211375
I have a shell script withstring=<deploymentTargets xmi:type=appdeployment:ClusteredTarget xmi:id=ClusteredTarget_1433783657353 name=cluster1/>I want the value between name= and /> which is cluster1. This output should be stored to another variable.
sed or awk to get a string
bash;sed;awk;string
For the specific example you show, all of these will save cluster1 in the variable $name:sedname=$(sed 's/.*=\(.*\).*/\1/' <<<$string )GNU grep (compiled with PCRE support)name=$(grep -oP '[^]+(?=/>)'<<<$string )Perlname=$(perl -pe 's/.*=(.*).*/\1/' <<<$string )If your shall doesn't support the <<< operator, change your preferred approach to using printf or echo instead:name=$(printf '%s' $string | sed 's/.*=\(.*\).*/\1/')name=$(printf '%s' $string | grep -oP '[^]+(?=/>)')name=$(printf '%s' $string | perl -pe 's/.*=(.*).*/\1/')IMPORTANT: this will only work on the example you show. For more complex XML structures, including nested tags etc, you really should use a dedicated XML parser.
_softwareengineering.141766
First of all please be aware this post contains some abusive language but I hope it will not bother anyone. I apologize for the bad language but that's what the name is.As I've been doing documentation on existing programming languages attempting to make a complete list of them I stumbled across terrible programming languages, which were clearly not made for actual use and implementation due to their insane difficulty. Languages such as Brainfu*k and LOLCODE or Whitespace are fool languages because they have no real use.For example, a Hello world program written in BrainFu*k. Taken from Wikipedia:The following program prints Hello World! and a newline to the screen:+++++ +++++ initialize counter (cell #0) to 10[ use loop to set the next four cells to 70/100/30/10 > +++++ ++ add 7 to cell #1 > +++++ +++++ add 10 to cell #2 > +++ add 3 to cell #3 > + add 1 to cell #4 <<<< - decrement counter (cell #0)] > ++ . print 'H'> + . print 'e'+++++ ++ . print 'l'. print 'l'+++ . print 'o'> ++ . print ' '<< +++++ +++++ +++++ . print 'W'> . print 'o'+++ . print 'r'----- - . print 'l'----- --- . print 'd'> + . print '!'> . print '\n'or another example taken from LOLCODE language: HAI CAN HAS STDIO? PLZ OPEN FILE LOLCATS.TXT? AWSUM THX VISIBLE FILE O NOES INVISIBLE ERROR! KTHXBYEThese languages are very difficult to learn/read/work with. My question is - Why do they exist? What is the purpose of them? Also, is there an official name for these type of languages?
Why do Joke programming languages exist?
programming languages
Esoteric Programming languages, also known as Turing Tarpits due to the difficulty of writing anything useful with them, are mostly built for fun or to see how far a particular idea can be taken. Whitespace for instance, privileges a lexical item typically ignored in most languages. Shakespeare on the other hand is designed to mimic Shakespearean Drama. Brainfuck actually has a practical purpose. It is designed to employ the smallest possible compiler at under 200 Bytes.There is a second category of the actual joke languages such as Malebolge and INTERCAL, neither of which is designed to be practical in any way whatsoever and have features that actively make them harder to use.
_webapps.1953
I want to play with interpreted code on my iPhone without jailbreaking. I'm familiar with tryruby for ruby. Are there any other online interpreters out there that I can use.
What online computer language interpreters are available, so I can practice programming from my iPhone?
webapp rec
Taken from Is there a web application that can replace an IDE like Eclipse?You will want to check out http://ideone.com/ It is a mini IDE and debugging tool mainly used as a clipboard.Example The following counts from 1 to 10class ForDemo { public static void main(String[] args){ for(int i=1; i<11; i++){ System.out.println(Count is: + i) } }}Selecting Java in the side bar of ideone will give usMain.java:4: ';' expected System.out.println(Count is: + i) ^1 errorThen fixing that gives us the following shortlink http://ideone.com/gGqZy which you can shareI posted the output below# 1: hide edit 3 seconds agoresult: success time: 0.03s memory: 213312 kB returned value: 0input: nooutput:Count is: 1Count is: 2Count is: 3Count is: 4Count is: 5Count is: 6Count is: 7Count is: 8Count is: 9Count is: 10
_unix.2879
I have a bash script that needs to run with root privileges, but must be invoked by the normal user. Difficult part is that the script should not ask for a password, and I don't want to use the sudoers file. I'd like to avoid using sudo or su. Is this possible?
How to get a program running with root privileges without using su or sudo
bash;permissions
If it wasn't a bash script but a regular application, you would give ownership of it to root and set the setuid bit on the application. Then upon execution, the effective user the application is running under is root. Due to security concerns however this is in many systems prohibited for shell scripts. This question here on unix.stackexchange.com does handle ways how to overcome this.
_cs.68145
Is the Minimum Steiner Tree problem NP-hard even on (2D, unweighted) grid graph ? A proof (for either case) will be very appreciated.Thank YouGilad
Hardness of the Minimum Steiner Tree problem on grid
complexity theory;np complete
null
_unix.126159
I am using tcplay to work with a Truecrypt volume with a 4 GB hidden volume located at the final gigabyte. When I mount either the normal volume or the hidden volume, they mount just fine. However, when I mount the normal volume with hidden volume protection (option --protect-hidden, or in short form, -e), this is what I get:[root@oc2222167007 /media]# tcplay -m truecrypt2 -e -d /dev/loop0Passphrase: <password of external volume>Passphrase for hidden volume: <password of hidden volume>All ok![root@oc2222167007 /media]# parted -l | grep -B1 -A5 truecryptError: /dev/mapper/truecrypt2: unrecognised disk label<output ommited>When I mount the filesystem with -e, it won't pick it up...[root@oc2222167007 /media]# cryptsetup remove truecrypt2[root@oc2222167007 /media]# tcplay -m truecrypt2 -d /dev/loop0Passphrase: <password of external volume>All ok![root@oc2222167007 /media]# parted -l | grep -B1 -A5 truecryptModel: Linux device-mapper (crypt) (dm)Disk /dev/mapper/truecrypt2: 4295MBSector size (logical/physical): 512B/512BPartition Table: loopNumber Start End Size File system Flags 1 0.00B 4295MB 4295MB ext4...but if I mount the external volume just like that, it works fine.What's happening?
tcplay: cannot mount filesystem on TrueCrypt volume with hidden volume protection after mapping it
linux;truecrypt
null
_unix.231556
I want to enumerate my USB-UART bridges with my own script. The script shall be called with some attributes and return a new devfs node name.I tested the script on console:./rc3e.py -d get-devfs-node tty --vendor 10C4 --product EA60 --driver cp210x --serial Board=KC705;Serial=5081a76781f40229d39e6c9802400fd2KC705_0/ttyUSBI implemented a static udev rule:# Silicon Labs - CP2103 USB to UART Bridge ControllerSUBSYSTEM==tty, SUBSYSTEMS==usb, ATTRS{idProduct}==ea60, ATTRS{idVendor}==10c4, ATTRS{serial}==Board=KC705;Serial=5081a76781f40229d39e6c9802400fd2, SYMLINK+=KC705_0/ttyUSBI'm testing the udev rule with /usr/bin/logger:SUBSYSTEM==tty, SUBSYSTEMS==usb, PROGRAM=/usr/bin/logger -p user.error 'product=%attr{idProduct} vendor=$attr{idVendor} drivers=$driver serial=$attr{serial}'Here I'm stuck.The reported line in /var/log/syslog is this:Sep 23 15:12:26 xxxxxx root: product= vendor= drivers=cp210x serial=$driver gets replaced, but $att{key} is always empty.This is my udevadm info -a -n /dev/ttyUSB2 output:udevadm info -a -n /dev/ttyUSB2Udevadm info starts with the device specified by the devpath and thenwalks up the chain of parent devices. It prints for every devicefound, all possible attributes in the udev rules key format.A rule to match, can be composed by the attributes of the deviceand the attributes from one single parent device. looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/ttyUSB2/tty/ttyUSB2': KERNEL==ttyUSB2 SUBSYSTEM==tty DRIVER== looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/ttyUSB2': KERNELS==ttyUSB2 SUBSYSTEMS==usb-serial DRIVERS==cp210x <-- key of interrest ATTRS{port_number}==0 looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0': KERNELS==1-3:1.0 SUBSYSTEMS==usb DRIVERS==cp210x ATTRS{bAlternateSetting}== 0 ATTRS{bInterfaceClass}==ff ATTRS{bInterfaceNumber}==00 ATTRS{bInterfaceProtocol}==00 ATTRS{bInterfaceSubClass}==00 ATTRS{bNumEndpoints}==02 ATTRS{interface}==CP2103 USB to UART Bridge Controller ATTRS{supports_autosuspend}==1 looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-3': KERNELS==1-3 SUBSYSTEMS==usb DRIVERS==usb ATTRS{authorized}==1 ATTRS{avoid_reset_quirk}==0 ATTRS{bConfigurationValue}==1 ATTRS{bDeviceClass}==00 ATTRS{bDeviceProtocol}==00 ATTRS{bDeviceSubClass}==00 ATTRS{bMaxPacketSize0}==64 ATTRS{bMaxPower}==100mA ATTRS{bNumConfigurations}==1 ATTRS{bNumInterfaces}== 1 ATTRS{bcdDevice}==0100 ATTRS{bmAttributes}==80 ATTRS{busnum}==1 ATTRS{configuration}== ATTRS{devnum}==2 ATTRS{devpath}==3 ATTRS{idProduct}==ea60 <-- key of interrest ATTRS{idVendor}==10c4 <-- key of interrest ATTRS{ltm_capable}==no ATTRS{manufacturer}==Silicon Labs ATTRS{maxchild}==0 ATTRS{product}==CP2103 USB to UART Bridge Controller ATTRS{quirks}==0x0 ATTRS{removable}==unknown ATTRS{serial}==Board=KC705;Serial=5081a76781f40229d39e6c9802400fd2 <-- key of interrest ATTRS{speed}==12 ATTRS{urbnum}==258427 ATTRS{version}== 1.10What should I change to pass these parameters to my script?EDIT 1:root@fpga-cloud:/dev# udevadm info /dev/ttyUSB2P: /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/ttyUSB2/tty/ttyUSB2N: ttyUSB2S: KC705_0/ttyUSBS: serial/by-id/usb-Silicon_Labs_CP2103_USB_to_UART_Bridge_Controller_Board=KC705_Serial=5081a76781f40229d39e6c9802400fd2-if00-port0S: serial/by-path/pci-0000:00:14.0-usb-0:3:1.0-port0S: ttyUSB.KC705E: DEVLINKS=/dev/KC705_2/ttyUSB /dev/serial/by-id/usb-Silicon_Labs_CP2103_USB_to_UART_Bridge_Controller_Board=KC705_Serial=5081a76781f40229d39e6c9802400fd2-if00-port0 /dev/KC705_1/ttyUSB /dev/ttyUSB.KC705 /dev/serial/by-path/pci-0000:00:14.0-usb-0:3:1.0-port0E: DEVNAME=/dev/ttyUSB2E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/ttyUSB2/tty/ttyUSB2E: ID_BUS=usbE: ID_MM_CANDIDATE=1E: ID_MODEL=CP2103_USB_to_UART_Bridge_ControllerE: ID_MODEL_ENC=CP2103\x20USB\x20to\x20UART\x20Bridge\x20ControllerE: ID_MODEL_FROM_DATABASE=CP210x UART Bridge / myAVR mySmartUSB lightE: ID_MODEL_ID=ea60E: ID_PATH=pci-0000:00:14.0-usb-0:3:1.0E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_3_1_0E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controllerE: ID_PCI_INTERFACE_FROM_DATABASE=XHCIE: ID_PCI_SUBCLASS_FROM_DATABASE=USB controllerE: ID_REVISION=0100E: ID_SERIAL=Silicon_Labs_CP2103_USB_to_UART_Bridge_Controller_Board=KC705_Serial=5081a76781f40229d39e6c9802400fd2E: ID_SERIAL_SHORT=Board=KC705_Serial=5081a76781f40229d39e6c9802400fd2E: ID_TYPE=genericE: ID_USB_DRIVER=cp210xE: ID_USB_INTERFACES=:ff0000:E: ID_USB_INTERFACE_NUM=00E: ID_VENDOR=Silicon_LabsE: ID_VENDOR_ENC=Silicon\x20LabsE: ID_VENDOR_FROM_DATABASE=Cygnal Integrated Products, Inc.E: ID_VENDOR_ID=10c4E: MAJOR=188E: MINOR=2E: SUBSYSTEM=ttyE: TAGS=:systemd:E: USEC_INITIALIZED=7849322
udev: Passing parameters via $attr{key} does not work. How to solve it?
debian;udev;devices
null
_unix.350829
I'm trying to create a wifi hotspot without encryption on my Raspberry Pi 3, by using Hostapd.How can I show a window with my own web page every time someone connects to it?I think the closest example of that I need is, then you connect to a wifi in a hotel - it ask you to authorise. I need the same but with my own web page.Thank you.
Show a web page, once connected to an open wifi hotspot
raspberry pi;wifi hotspot;hostapd;authorization
null
_webapps.63197
I have a Google spreadsheet that contains 30 sheets (each day for the month of September). I want to add cell K36 from each sheet, but I dont know how. How can I do this?
Add cell from multiple spreadsheets in Google Spreadsheets
google spreadsheets
null
_codereview.124800
This may be rather basic, but I wanted to experiment and learn with some of the upcoming CSS3 techniques. I wasn't able to come up with an HTML/CSS only solution, and I had to work longer than I'd like to admit to get to a point where this menu works as intended on desktop or mobile.The main lesson I learned is forget about using :hover to control actions. It's worthless on mobile, and having the function on click in desktop isn't that bad, and is probably the better practice anyway.I haven't tested in a lot of env, but more than a few. It seems to work pretty well in modern browsers. Let me know how I can improve!GitHubWorking demo//click to open menu$('.follow button').click(function(){ $('.addClass').toggleClass(profile-container);});/*RESET*/ /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain) */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; } *{ letter-spacing: normal; }/* END RESET *//*Disables text selection*/body{ -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none; display: table; height: 100%; width: 100%; background-image: url(https://i.imgsafe.org/100dde0.png); }/* Text Center class */.center{ text-align: center;}/*Class that centers img elements in their container*/img.centerImg{ display: block; margin: 0 auto;}/*profileDropdown*/ /* PROFILE STYLES */ ul, li { margin: 0; padding: 0; list-style-type: none; } .container { margin: 0px auto 0; width: 378px; } .profile-container { position: relative; width: 378px; float: left; } .profile { width: 370px; background: #f6f6f6; float: left; padding: 4px; border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -ms-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } .avatar img { display: block; border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; } #portraitCaption{ font-style: italic; color: #b9b9b9; font-size: .75em; } .follow { margin: 0px 0 0 0; } .follow button { display: block; width: 100%; border: 0; background: #268cde; color: white; font-weight: bold; font-size: 1.25em; padding: 7px 0; margin: 0; border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -ms-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; cursor: pointer; } .follow button:hover { background: #3096e8; } .follow button:active { background: #2085d6; } .profile-list { overflow: hidden; width: 100%; box-sizing: border-box; color: #767b7e; font-size: 13px; } .profile-list li { cursor: pointer; background: #ffffff; border-top: 1px solid #e5e6e6; } .profile-list li:last-child { border-radius: 0 0 3px 3px;; -o-border-radius: 0 0 3px 3px; -ms-border-radius: 0 0 3px 3px; -moz-border-radius: 0 0 3px 3px; -webkit-border-radius: 0 0 3px 3px; } .profile-list .profile { border-radius: 3px 3px 0 0; position: relative; } .profile-list li { -webkit-transform-origin: 50% 0%; -o-transform-origin: 50% 0%; transform-origin: 50% 0%; -webkit-transform: perspective(60px) rotateX(-90deg); -o-transform: perspective(60px) rotateX(-90deg); transform: perspective(60px) rotateX(-90deg); -moz-box-shadow: 0px 2px 10px rgba(0,0,0,0.05); } .profile-list li a{ display: block; padding: 15px 10px; } .profile-container .profile-list .fourth { transition-delay: 0.6s; -o-transition-delay: 0.6s; transition-delay: 0.6s; } .profile-list .first { -webkit-transition: 0.2s linear 0.8s; -o-transition: 0.2s linear 0.8s; transition: 0.2s linear 0.8s; } .profile-list .second { -webkit-transition: 0.2s linear 0.6s; -o-transition: 0.2s linear 0.6s; transition: 0.2s linear 0.6s; } .profile-list .third { -webkit-transition: 0.2s linear 0.4s; -o-transition: 0.2s linear 0.4s; transition: 0.2s linear 0.4s; } .profile-list .fourth { -webkit-transition: 0.2s linear 0.2s; -o-transition: 0.2s linear 0.2s; transition: 0.2s linear 0.2s; } .profile-container .profile-list li { -webkit-transform: perspective(350px) rotateX(0deg); -o-transform: perspective(350px) rotateX(0deg); transform: perspective(350px) rotateX(0deg); -webkit-transition: 0.2s linear 0s; -o-transition: 0.2s linear 0s; transition: 0.2s linear 0s; } .profile-container .profile-list .second { -webkit-transition-delay: 0.2s; -o-transition-delay: 0.2s; transition-delay: 0.2s; } .profile-container .profile-list .third { -webkit-transition-delay: 0.4s; -o-transition-delay: 0.4s; transition-delay: 0.4s; } .profile-list li a{ color: #268CDE; text-decoration: none; text-transform: uppercase; letter-spacing: 2px; } .follow p{ text-transform: uppercase; font-family: Times New Roman, Serif; font-size: 1.25em; } .profile-list li a:hover{ background-color: #e0e0e0; }<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script>!DOCTYPE HTML><html lang=en-US> <head> <meta CHARSET=UTF-8> <meta name=viewport content=width=device-width, initial-scale=1> <title>Title</title> <meta name=Keywords content=> <meta name=Description content=> <link rel=stylesheet href=css/style.css> </head> <body id=profileDropdown> <div class=container> <div class=profile> <img id=profilePicture class=avatar src=# alt=Your Name Portrait height=416 width=370 > <span id=portraitCaption>Your Name</span> </div><!-- END PROFILE SECTION --> <div class=addClass> <div class=follow><button id=dropdownButton>Follow</button></div> <nav id=dropDown class=profile-list> <ul class=center> <li id=gitHubProfile class=first > <a href=https://github.com/agraymd title=Follow me on GitHub! target=_blank>GitHub</a> </li> <li class=second> <a href= title=Connect on LinkedIn target=_blank>LinkedIn</a> </li> <li class=third> <a href= title=Email Me target=_blank>Google</a> </li> <li class=fourth> <a href= title=My Resume target=_blank>Resume</a> </li> </ul> </nav> </div> </div> <script src=js/jquery.js type=text/javascript></script> <script src=js/main.js type=text/javascript></script> </body></html>
CSS3 Dropdown Menu (touch device or mouse compatible)
jquery;html;css;animation;touch
null
_cstheory.34806
The Tseitin formulas are as follows: Given a connected graph and a function $\alpha: V \rightarrow \{0,1\}$. Associate each edge $e$ with a variable $x_e$. The Tseitin formula $G(\alpha)$ is defined to be$$\bigwedge_{v \in V} \big(\sum_{(u,v) \in E(G)} x_{(u,v)} = \alpha(v) \mod 2 \big)$$It's easy to see that the Tseitin formula $G(\alpha)$ is satisfiable iff $\sum_{v \in V} \alpha(v) = 0 \mod 2$.This gives a nice characterization of the satisfiability of a system of random mod2 equations ($k$-XORs) $Ax = b \mod 2$ where each variable occurs in exactly 2 equations in the system which is connected (we cannot partition the rows of $A$ into two sets $A_1$ and $A_2$ so that $A_1 \cap A_2 = \emptyset$). Push the negation of any variable in a constraint into $b$ so that all variables occur positively in $A$. $Ax = b$ is then satisfiable iff $$\sum_{i = 1}^{|b|} b_i= 0 \mod 2.$$This is because $Ax = b$ is equivalent to the Tseitin formulas where for each constraint $a_ix = b_i$ we create a vertex $v_i$ where $\alpha(v_i) = b_i$ and each variable $x_i$ corresponds to an edge between the two constraints in which $x_i$ appears. My question is, if we relax the requirement that each variable occurs in 2 equations (to say at most $k$ equations), is there a similar nice combinatorial characterization of the satisfiability of the system of equations? This corresponds to a hypergraph version of the Tseitin formulas. It's easy to see that in this case if $\sum_{i=1}^{|b|} = 1\mod 2$ is odd then the system is unsatisfiable, but the other direction does not hold. Is there a nice sufficient condition for the satisfiability of such a system?
Combinatorial characterization of hypergraph Tseitin satisfiability
cc.complexity theory;proof complexity
null
_unix.219120
When using a vi session within VirtualBox, how can I send the Escape Key to change modes from input mode to command mode? I have tried many combinations which do not work: Ctrl-Esc, Atl-Esc, Shift-Esc, Alt-Ctrl-Esc, Shift-Ctrl-Esc, and so forth in every combination.
How to send the Escape Key inside VirtualBox vi session?
virtualbox;vi
null
_vi.5886
I have a rather long chat transcript that I copied out of a window, and when I pasted it into vim, it put two line breaks after every username, and then what the user typing said. I'd like to:Search for the > characterGo to the top of the file.Start recording the macroMove to the next match.Press the delete key twice to move to move the text up to the same line as the user's nameFinish recording the macro.Run the previously recorded macro for every match in the file.How would one go about this in VIM?
How to move to the next matching string and then hit delete twice in a macro?
macro
As steve pointed out, :%s/>\n\n/> / is useful here (although the g flag he used is superfluous.)I want to mention another command that is applicable here: the join command, which is J.So for a macro you could use:ggqq/>$EnterJJq999@qExplanation:gg # Move to start of file qq # Start recording macro into register q />$^M # Search for the > character at the end of a line JJ # Join the next two lines onto the current line q # Stop recording macro 999@q # Play macro back 999 times. # (It will stop when > is no longer found at the end of any line.)
_unix.238565
When launching an application through the command line I successfully use:gourmet --gourmet-directory $HOME/my/custom/path/But it does not work when trying to replicate this behaviour on a .desktop file with:Exec=gourmet --gourmet-directory $HOME/my/custom/path/ %F I am probably missing something very basic here, but I cannot get my head around this. Any help would be much appreciated.
How to pass argument in .desktop file
linux;.desktop
Only command line options with one hyphen are possible in the Exec field.Exec=sh -c gourmet --gourmet-directory $HOME/my/custom/path/ %Fshould work.
_codereview.87562
The assignment is to create a login system secured for SQL injections and XSS.It's in PHP and I'm using PDO with prepared statements obviously. Which from my point of view should protect against the simplest injections at least. The ones I'm throwing at the system are ineffectual.If you believe it's not secure against SQL injection I would gladly take comments and an example of what should work against it.With regards to XSS I haven't done anything to protect against it yet. From the school I believe it was mostly about html or url-encode the inputs. But would that be enough? From google I also have some articles about sql escaping.Comments or help on XSS protection could be nice. Or is it only a matter of escaping the inputs before it reaches the SQL query?<form method=post> <input type=text name=username id=username> <input type=password name=password id=password> <button type=submit name=submit class=login-button>Login</button> <a href=register.php>Register!</a> <p class=forgot-password><a href=forgot.php>Forgot login?</a></p></form>function Log_in($username, $password) { $db = new PDO(host;dbname, user, password); $login = $db -> prepare(SELECT * FROM Users WHERE Username =:username and Password =:password); $login->bindValue(':username', $username, PDO::PARAM_STR); $login->bindValue(':password', $password, PDO::PARAM_STR); $login->execute(); global $count; $count = $login->rowCount(); global $data; $data=$login->fetchColumn(2); return $count; return $data;}$username = trim($_POST[username]);$password = trim($_POST[password]);if (isset($_POST['submit'])) { getSalt($username); foreach ($rowset as $row) { $salt = $row[0]; } $hashpassword = sha1($password.$salt); Log_in($username, $hashpassword); if($count==1){ session_start(); $_SESSION['email'] = $data; header(location:index.php); } else { echo Wrong; }}
Secure login system
php;pdo;authentication;sql injection
SecurityYes, your code is secure against SQL injection, that's good.You don't echo any variable data, so your code is also not vulnerable to XSS. You left out your form (and possibly other code), so there might be an XSS vulnerability there though. To protect against XSS, you should definitely read this cheat sheet.is [XSS] only a matter of escaping the inputs before it reaches the sql query?No, definitely not. XSS is a vulnerability that happens when printing something to the user, so that is when it should be defended against (in PHP eg by using htmlspecialchars). Also, sha1 isn't really recommended for hashing anymore, you should use something like bcrypt. This also has the added advantage that you don't have to take care of salts, etc. The relevant function in PHP is password_hash.Structureglobals are evil (not necessarily always, but definitely in this case). If you have to return more than one value return an array, do not set it as global. I personally would choose a more OOP oriented different approach of having a user object and setting the email there, and then returning true/false instead of an integer from Log_in (because either the login is successful or not, there are no other states). Miscyour indentation is off, which makes your code harder to read.function names should start with a lowercase character.all SQL keywords should be all uppercase (and -> AND).data isn't a very good variable name. What is it? If it's just an email address, call it email. count is also very generic (especially for global), rowCount would be better.you shouldn't have two returns, especially if you use none of them (in that case, you should have no return).it's unclear what $rowset is, but it seems odd that you have to iterate over it to get the salt. You could just access the last item of the array and safe the loop, but it still doesn't seem right.don't select * if you don't need all columns, only fetch those that you actually need. If you do select *, I would fetch each column by name, not by an integer, in case a column is added later on.
_unix.305802
Can anybody explain me what does this script in each line?I can not run this because I think the syntax is incorrect.#! /bin/bashv=`echo $@|gawk '{print $NF}'`if[-d $v];thenfor v2 in $@;doif test $2 != $v;thenln $v2 $v/$v2rm $v2fidone
GAWK script explained
awk;gawk
Most of it is shell, and that's incorrect because of missing blanks on the first if-statement. Alsothe first if-statement lacks a balancing fithe $@ should be quoted $@the $2 probably should be $v2The -d test anyway is suspect, since gawk should be printing a number (not a directory name). Still, you could be testing for a directory named for a number...As suggested in a comment, if you made those corrections, the script would try to remove everything that is not the same as the last parameter of the script, and make link to those removed files under the directory named by the final parameter. (Just using mv would be more straightforward).Here's a suggested fixed script:#! /bin/bashv=`echo $@|gawk '{print $NF}'`if [ -d $v ];then for v2 in $@;do if test $v2 != $v;then ln $v2 $v/$v2 rm $v2 fi donefi
_unix.48601
In the grub.conf configuration file I can specify command line parameters that the kernel will use, i.e.:kernel /boot/kernel-3-2-1-gentoo root=/dev/sda1 vga=791After booting a given kernel, is there a way to display the command line parameters that were passed to the kernel in the first place? I've found sysctl,sysctl --allbut sysctl shows up all possible kernel parameters.
How to display kernel command line parameters?
command line;linux kernel;parameter
$ cat /proc/cmdlineroot=/dev/xvda xencons=tty console=tty1 console=hvc0 nosep nodevfs ramdisk_size=32768 ip_conntrack.hashsize=8192 nf_conntrack.hashsize=8192 ro devtmpfs.mount=1 $
_unix.162888
I am having issues with process control using the signals available to the process abstraction. In the example below you can see there is a perl script which is the parent of the whole tree with a group i.d. of 25235. This GID is inherited by all the children. However one of the children, a shell with the PID of 4205, starts a new GID of 4205.The reason I am setting a new group id for this branch of the process tree is there are times I want to run kill -9 -4205 killing the sh process and all its children with that share the same GID without affecting the rest of the process tree. I can then restart the shell process and its children. The problem I am having is when I need to kill the whole tree starting with perl script (the parent) If I run kill -9 -25235 (main group i.d.) or kill -9 4678 (parents PID) this will kill the whole tree except the branch which has a different group id. These processes will be re-parented to init.Is there a way to kill the whole tree regardless of the different GIDs? I suspect session ids may come to play but I have not been able to figure that out if so.process tree example:perl(4678,25235)sc_serv(4685,25235){sc_serv}(4691,25235) {sc_serv}(4693,25235) {sc_serv}(4694,25235) sh(4205,4205)ffmpeg(4207,4205) vlc(4208,4205){vlc}(4217,4205) {vlc}(4219,4205) {vlc}(4296,4205)
Kill a whole process tree regardless different GIDs
process;signals
null
_unix.261213
My mouse is broken. How can I use the keyboard as a mouse on Raspbian?I need to resize the terminal window (and other windows in general), plus doing other tasks like I would if using a mouse.
Use the keyboard to emulate a mouse
keyboard shortcuts;mouse
null
_cs.49120
I need to write a context-free grammar for this Language : $\L = {a^nb^k | 1 =< n <= 2k}Please help me solve this problem!Thanks.
Context-free Grammar To Generate $L=\{a^nb^k | 1 =< n =< 2k }
formal languages;context free;automata;formal grammars
You can break up this problem into two parts: starting with the shortest legal string with $n$ a's, you can follow it with zero or more b's and still be legal, so you have a string in your language will be the concatenation of $L$ and $X$, where $L$ generates the smallest legal strings and $X$ generates the extra b's.The $X$ part is easy to produce: $X\rightarrow bX\mid\epsilon$.Now for the $L$ part we have two cases: the number of a's is even or odd. If we have $a^{2k}$ then we need at least $k$ b's. That's easy to generate as well: $E\rightarrow aaEb\mid aab$, since we're not allowed to have zero a's. If, $n$ is odd, then we must have $2k+1$ a's and $k+1$ or more b's, which is to say we need to generate $aa^{2k}b^{k+1}=aa^{2k}b^kb$. That gives us two subcases: either $ab$ or $a..b$ with $a^{2k}b^k$ inside. That's also easy: $O\rightarrow ab\mid aEb$. Putting all this together, a grammar for your language is$$\begin{align}S &\rightarrow LX\\L &\rightarrow E\mid O\\E &\rightarrow aaEb\mid aab\\O &\rightarrow aEb\mid ab\\X &\rightarrow bX \mid \epsilon \end{align}$$Of course we could simplify this a bit. For a more detailed tutorial on this topic, you could look here.
_webapps.86290
Whenever I publish a new public video in my channel, then all the subscribers get a notification. So far that's good, however, there is one video which I would prefer to silently put online.So, is it possible to suppress such a notification for one single video ?
Suppress notification about one new video
youtube
On upload go to advanced features and distribution options uncheck the box that says notify subscribers.
_cs.70847
I'm currently studying formal languages. My lecture states that, while the words of a language are finite, the sentences build with the underlying grammar are not. But I don't get why this should be generally true. I can imagine grammar which leaves me with a finite amount of sentences.I agree that one could create a language with infinite amount of sentences but I can't see why it should be generally the case.
Why is the quantity of sentences not finite?
formal languages
The statement is not true for arbitrary languages and grammars. For example, the grammar $G$ consisting of the rules$$S \to a|b|C\\C \to cD\\D \to d|\epsilon$$can produce the words $a$, $b$, $cd$ and $c$, so $|L(G)| = 4$, therefore $L(G)$ is finite.The alphabet (words of the language) is finite by definition. The language may or may not be finite. A trivial example of a grammar producing an infinite language is $G' = (\{ S \}, \{ a \}, P, S)$ with $P = \left\{ S \to a|aS \right\}$. $G'$ produces the infinite language $L(G') = \{ a^n : n > 0 \}$.Both finite and infinite languages exist and can be generated by grammars.Note that all finite languages can be expressed through regular grammars and are therefore regular languages. However, not all regular languages are finite (see $G'$) The class of regular languages (type 3) is a subset of the class of context-free languages (type 2) which is a subset of the class of context-sensitive languages (type 1) which is a subset of the class of recursively enumerable languages (type 0):$$\text{Finite languages} \subset \text{Type 3} \subset \text{Type 2} \subset \text{Type 1} \subset \text{Type 0}$$(And these are only the languages you can generate using formal grammars, in fact, recursively enumerable languages (type 0) are just a subset of the set of all languages.)
_unix.3284
Sadly, I only learned about this last year by stumbling upon it randomly on the internet. I use it so infrequently that I always forget what it is by the time I need it again.How do you change to your previous directory?
What is the bash shortcut to change to the previous directory?
bash;shell;cd command
The shortcut is -Try cd -If you want to use this in your prompt, you have to refer to it with ~-.See the example:[echox@kaffeesatz ~]$ cd /tmp[echox@kaffeesatz tmp]$ lscron.iddS32 serverauth.CfIgeXuvka[echox@kaffeesatz tmp]$ cd -/home/echox[echox@kaffeesatz ~]$ ls ~-cron.iddS32 serverauth.CfIgeXuvka
_webmaster.25401
How do I schedule the publication of new content (in this case, press releases) on my static site?I am using FTP (FileZilla) on Windows 7 to do the job manually. I am assuming there are some FTP clients that will do scheduling, or maybe there is some other way to do this?
How do I schedule content publication on a static site?
ftp;static content;press releases
You'd need a fully scriptable FTP client to do that, NcFTP, LFTP (not sure if it works on windows), Kermit FTP, would work or CoreFTP as @paulmorriss observed.More info on a similar question over at serverfault which has a few other ideas like using powershell which might interest you.
_computerscience.1557
Photorealistic rendering has the goal of rendering an image as a real camera would capture it. While this is already an ambitious goal, for certain scenarios you might want to take it further: render an image as the human eye would capture it or even as the human being would perceive it. You could call it visiorealistic or perceptiorealistic rendering, but if anyone could come up with a catchier term (or tell me that there is one already in existence) I'd appreciate that.Here are some examples to make my point clear. When you take a picture with a camera at a low illumination level, you either have a good lens or get a noisy image. For a human observer, scotopic vision kicks in and gives rise to the Purkinje effect (colors are shifted towards blue). This effect depends on the HDR luminance information, which are lost when I display the image on a LDR display. In addition, the human brain may use depth information to 'filter' the perceived image - information which are lost in a final (non-stereo) rendering.Assembling an exhaustive list is probably an elusive goal. Could you suggest some of the effects of the eye and the brain that I would need to consider?
Realistic rendering: which processes of the human eye and brain do I need to consider?
human vision
null
_webapps.25983
Search and Filter Cards searches only the cards on the current board, as the name suggests. I would like to be able to search across all the boards of the organization, (subject to board membership and permissions).
In Trello, is there a way to search across all of an organization's boards?
trello
null
_codereview.26573
I have implemented the first coding challenge on http://projecteuler.net/. I would love to get it reviewed by some expert rubyists!# Multiples of 3 and 5## If we list all of the natural numbers below 10 that are multiples of# 3 and 5, we get 3,5,6 and 9. THe sum of these multiples is 23.## Find the sum of all the multiples of 3 or 5 below 1000.class Multiples def multiples numbers = Array(1..999) multiples = Array.new for i in numbers if i%3 == 0 or i%5 == 0 multiples.push(i) end end multiples end def sumMultiples(multiples) total = 0 multiples.each { |i| total+= i } puts(total) endendmultiples = Multiples.newmultiples.sumMultiples(multiples.multiples)
Multiples of 3 and 5 from Euler code challenge
ruby;programming challenge
null
_softwareengineering.296993
amortize mean reduce or extinguish (a debt) by money regularly put aside.i.e. to pay off of debt with a fixed repayment schedule in regular installments over a period of time.In amortized analysis of algorithms, does amortize also mean to reduce something by something else regularly put aside?
What does amortized mean in amortized analysis of algorithms?
algorithms
null
_unix.278253
I would like to find out why the Ubuntu Linux 15.10 Live CD login appears sporadically after I disconnect and reconnect the COMCAST Internet carrier cable at the back of the Lenovo Think Station desktop PC after 15 minutes from selecting the Ubuntu LiveCD, Install Ubuntu Linux GUI item. If I do not disconnect and reconnect the COMCAST Internet carrier cable at the back of the Lenovo, it apparently stays frozen with the Ubuntu logo and 5 red dots blinking on and off forever. We are installing Ubuntu 15.10 Live CD iso on a completely blank hard drive which was erased with the Linux command fdisk. At that time, I wiped out the Grub2 master record and MS-DOS table as well as the password table. Prior to that , I reconfigured GRUB2 so that I could install an open-source GUI package to delete hard diskpartitions.I would also like to know how to make the Ubuntu Linux 15.10 Live CD login appear after 5 minutes consistently. This question may be important to people who buy computers with reformatted hard drives and wish to install Ubuntu Linux from a LiveCD. Any help is greatly appreciated.
Ubuntu 15.10 Live CD login appears sporadically after I disconnect and reconnect the Internet carrier cable for the Lenovo Think Station
ubuntu;grub2;livecd
null
_softwareengineering.269347
ContextI'm designing a database which, simplified, should be able to handle users sending job requests to each other, and after that a job can be started, finished, and reviewed. The design should be scalable (think millions of users).Approaches I've considered:Gargantuan tableOne approach, probably not the best one, would be to simply store ALL jobs in one, huge table jobs. This table would need a state column to represent which state the job is currently in (e.g. ACCEPTED, STARTED, FINISHED, REVIEWED e.t.c.). The biggest problem with this approach that I can see is that jobs in different states have different types of data that are relevant to them. For example, a job request has a preliminary agreed upon price, but that could change before the job is started, and change again before the job is finished. This could of course be solved by just adding more columns to the table and naming them properly, but it will probably become a huge bottleneck performance-wise very early to have one table containing all the different types of possible data for all the different possible states of a job.Different tables for different statesThis approach would be to have multiple tables, for example job_requests, jobs_started, jobs_finished, tables who in turn can have substates, e.g. job_requests could have the sub-states PENDING, ACCEPTED, while the jobs_finished table would have the substates COMPLETED, CANCELLED, REVIEWED.With this approach each table only contains data which is relevant to the current job state, but on the other hand some data might be duplicated (for example the user ids of the job requester, and job receiver -- on the other hand this information could be stored in yet another table?). The problem with this approach is that I can't think of a good solution on how to archive all the information when transitioning between states. For example, once a job request has been accepted, and then started, it should be deleted from the job_requests table and moved into the jobs_started table, but it's just a matter of time before a stakeholder wants to know for example how long the average time is between a job request being created, until it's been started, at which point I'd need the data from the job_requests table to be able to calculate it. It feels like this type of problem should be easy to solve, but I really can't think of any good solution which feels right, any solution I come up with feels ugly and I can immediately think of a number of things which makes the solution bad. Very grateful for any feedback or tips on approaches I could take. Thanks in advance!
Database design for objects with multiple states
architecture;database;database design;enterprise architecture;architectural patterns
Sounds like you have 3 major categories of data you are trying to store:General job data (job id, job requester id, job receiver id etc)State transitions (job started, job finished)State-specific job data(optional) job-related events (price changed, job receiver user reassigned etc)The key is to separate event-like data from everything else.Schema designHere are some details:1. General jobs tableAll of the information that's NOT state-specific goes into the (let's say) jobs table. Auto-generated primary key: job_id2. State transitions tableAll information about state transitions goes into job_state_transitions table, which might have the following columns:job_transition_idjob_idcreated_atfrom_stateto_stateIdeally this table is append-only. Nothing is every updated or removed here.Using such a table, you can find out the latest status of any particular job by selecting the latest row for a given job_id from the job_transitions table. You can further denormalize that and introduce a job_state column, the contents of which are updated every time a new row is inserted in job_transition table (stored procedures might help here if that's your thing).You can also do all sorts of analysis on state transitions, because the timing data is preserved (created_at is a date/time field that can help with that)3. State-specific job dataAll of the state-specific data goes into [state]-jobs tables. Primary key: some sequence id. Main index: job_transition_id4. Optional event dataYou can also introduce an audit trail table that allows you to keep track of various changes that users might request for each job, like your change agreed upon price. This is a generalization of the state transition table: one main table that contains events and a one supplemental table for each event type (for example, price_changes table with job_id, created_at, from_price and to_price columns).Scaling to millions of usersIf the main jobs table grows to be unwieldy, you can shard it by job_id or requesting_user_id or something like that.Likewise, events table should be append-only and can be rotated or purged of events related to jobs that have been finished.
_webapps.80
Is there a way to access Gmail securely over SSL?
Can I access Gmail through SSL?
gmail;https;ssl
Yes, just add an s to the http in the address bar - so to get to Gmail over SSL, type in:https://www.gmail.comYou can also change a setting in Gmail to require your account to use SSL:We've recently made the 'Always use https' setting the default behavior in Gmail (the default used to be http). Here's some background: If you sign in to Gmail via a non-secure Internet connection, like a public wireless or non-encrypted network, your Google account may be more vulnerable to hijacking. Non-secure networks make it easier for someone to impersonate you and gain full access to your Google account, including any sensitive data it may contain like bank statements or online log-in credentials. Accordingly, we enable the 'Always use https' option in Gmail by default. HTTPS, or Hypertext Transfer Protocol Secure, is a secure protocol that provides authenticated and encrypted communication.In your Gmail settings, under the General tab, select Always use https:
_webmaster.24442
I wondered if it's because the homepage's size is big?I only see my stylesheet working on pages other than the homepage.Any ideas?
CSS style is gone on the homepage in IE8
internet explorer 8;css
You can use F12 to bring up the dev console in IE8 and explore the CSS rendering that way. Should be able to track down the exact issue that way.
_unix.382844
The Linux Mint upgrade instructions begin by saying:If your version of Linux Mint is still supported, and you are happy with your current system, then you don't need to upgrade.The situation I sometimes find myself in is that I am happy with my current system, but my version is not supported. In particular, I am leery of doing a giant upgrade that upgrades everything and may disrupt things. But if I don't upgrade, when my version stops being supported, I can no longer install or upgrade individual packages with apt-get.Upgrade instructions for Ubuntu-based distros (such as these older upgrade instructions for Mint) often say that basically what you do is point APT at the new distro, and then upgrade your packages using upgrade or dist-upgrade.What I'm wondering is, is it possible to update my system in the sense of making new packages (or new versions of existing packages) available, but without actually upgrading anything, and in particular without upgrading everything all at once? What I would like to do is to retain the ability to install individual new packages, and new versions of already-installed packages, but without ever doing an overall upgrade of everything on the system.This may seem like a weird goal, but I often use Linux on computers that I use infrequently. It is very frustrating to fire up an old computer to do something, and find that I can't install anything because the apt sources are gone, and then have to cross my fingers and try an upgrade that may break everything. I would prefer to take an incremental approach in which the need to install or upgrade a single program doesn't require taking a leap of faith and upgrading the entire system.I'm also asking this question because, just theoretically, I'm curious what the upgrade process actually does. If everything on the system is defined by packages, what is the difference between upgrading to CoolPackage version X on Mint 17 and upgrading to CoolPackage version X on Mint 18? In what way does the OS version itself actually affect the upgrading of packages? Or, most extremely, if upgrading the OS is just upgrading all the packages, why do you ever need to upgrade the OS per se at all, instead of just upgrading each package (and its dependencies) as needed? I'm also curious if different distros make such incremental upgrading harder or easier.(Note that I'm not talking about ignoring dependencies; I realize that upgrading a package may require upgrading specific other packages. But I wonder why there needs to be the notion of an OS-level upgrade rather than just each individual package's notion of what needs to be done to upgrade that package. Is the answer just that, after enough time, all packages wind up indirectly depending on new versions of fundamental packages, so that upgrading any package would effectively require upgrading everything to keep dependencies satisfied?)
Retaining the ability to upgrade/install packages without actually upgrading Linux Mint
linux mint;upgrade
null
_softwareengineering.216029
I think most of us, programmers, used Stack Overflow to solve every day problems: looked for an efficient algorithm to do something.Now imagine a situation: you have a problem to solve. Googled a bit, found a StackOverflow question but you are not really satisfied with the answers so far. So you have to do your own research: you need to do it because you want it in the company's app. Eventually after some hours you have found the better solution. You're happy, you added it to the company's code base, then you want to submit your answer with a code snippet (just several lines) to the question you've found before to help others too. But wait: the company's software is closed source, and you worked on it on the clock. So does this mean I shouldn't post the answer neither at work nor at home to that question in the rest of my life, because I solved it at work, and the company owns that piece of code?
Found a better solution to a problem at work - should I deter from posting the code snippet online?
legal
Exposing proprietary company information is something you should never do. Most code snippets on Stack Overflow are far more mundane than that, however. Consider this example:public static unsafe void SwapX4(Byte[] Source) { fixed (Byte* pSource = &Source[0]) { Byte* bp = pSource; Byte* bp_stop = bp + Source.Length; while (bp < bp_stop) { *(UInt32*)bp = (UInt32)( (*bp << 24) | (*(bp + 1) << 16) | (*(bp + 2) << 8) | (*(bp + 3) )); bp += 4; } } }This method inverts the endianness of a 32 bit number, by swapping the bytes around. The difference between this implementation and a naive one is that this one runs twice as fast, but you can only run it on a little endian machine. It's being used in a proprietary program, but it describes a general technique, and does not expose anything confidential.
_webapps.46053
I recently joined a research team that uses R and Git/GitHub. The team includes 4 full-time R programmers and 10 social scientists who only run simple analyses.I was told by one of the more experienced programmers on the project that they haven't found a way to use many of GitHub's tools for collaboration (bug reports, to-do lists, code comments, etc.) because they generate emails to everyone who is a contributor to the repo every time.This is incredibly puzzling to me, so I'd love to hear from someone that there are ways to adjust the email settings. I'd expect there would be multiple ways, so that individuals could opt-in or opt-out of certain emails, and also so contributors could explicitly choose whether certain people get certain emails or not.Is it possible to adjust these settings?
How can we stop GitHub from emailing too many people too much?
github
null
_codereview.88709
I'm trying it out just to see if I could solve it. It would be great if I could receive tips on how to improve it.//inputvar decimal = prompt(Please enter a decimal number);if (decimal >= 1 && decimal < 1000000000) { //convert to binary var binConvert = parseInt(decimal, 10).toString(2); //reverse binary number var makeString = binConvert.toString(); var srj = makeString.split().reverse().join(); var makeNumber = Number(srj); //convert back to decimal alert(parseInt(makeNumber, 2));} else { alert(Input number should be: 1 <= N < 1 000 000 000. Please try again.);}jsFiddle
Reversed Binary Numbers in JavaScript
javascript
null
_codereview.121494
I'm a student, and I'm trying to make the product of two square matrix with some threads in the soup. I've already worked on some fast single-threaded product (with some cache-friendly tricks), and I'm interested now on multithreading.The following code works, but I don't fully understand my outputs in terms of performance.I'd like to improve my code a bit and of course, improve my implementation (and in a perfect world, achieving a multithreaded version faster than a naive singlethreaded version).Makefile:CC=gccCCO=# -O3 -march=nativeCCF=-std=gnu11 -Wall -Wextra -pedantic -Wno-unusedLDF=-pthreadEXTRA=-DNB_TH=8all: modular B_bloc K_bloc benchmodular: $(CC) -Dmodular $(EXTRA) $(LDF) $(CCF) $(CCO) ./mat_mult.c -o modularB_bloc: $(CC) -DB_bloc $(EXTRA) $(LDF) $(CCF) $(CCO) ./mat_mult.c -o B_blocK_bloc: $(CC) -DK_bloc $(EXTRA) $(LDF) $(CCF) $(CCO) ./mat_mult.c -o K_blocmr_proper: rm -f modular B_bloc K_blocbench: ./modular 128 ./B_bloc 128 ./K_bloc 128 ./modular 208 ./B_bloc 208 ./K_bloc 208 ./modular 400 ./B_bloc 400 ./K_bloc 400 ./modular 1024 ./B_bloc 1024 ./K_bloc 1024mat_mult.c:#include <stdio.h>#include <assert.h>#include <stdlib.h>#include <unistd.h>#include <pthread.h>// Pick your favorite flavor// #define modular// #define B_bloc// #define K_bloc#ifdef modular #define FOO_TH modular_ #define MALLOC_P_TH default_alloc_#elif defined(B_bloc) #define FOO_TH B_bloc_ #define MALLOC_P_TH default_alloc_#elif defined(K_bloc) #define FOO_TH K_bloc_ #define MALLOC_P_TH K_bloc_alloc_ #ifndef BLK #define BLK 2 #endif#endif#ifndef BLK #define BLK 16#endif#ifndef NB_TH #define NB_TH 8#endif#define THREAD_WAIT 1#define THREAD_OVER 0// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// TOOLS// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// Tool to build a matrixvoid build_mat_(int*** target, int width, int height){ void* origin = malloc(sizeof(int*) * width + sizeof(int) * width * height); int** header = (int**) origin; int* cursor = (int*) (header + width); for(int i = 0; i < width; ++i) { header[i] = cursor; cursor += width; } *target = (int**) origin;}// Tool to allocate a struct-like void* thread parameter (default)void* default_alloc_(){ return malloc(0 + sizeof(int) * 3 + sizeof(int*) * 1 + sizeof(int**) * 3 );}// Tool to allocate a struct-like void* thread parameter (K_bloc only)void* K_bloc_alloc_(){ return malloc(0 + sizeof(int) * 3 + sizeof(int*) * 1 + sizeof(int**) * 3 + sizeof(pthread_mutex_t*) * 1 );}// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// THREADS FOO_TH// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// Split the mult' by picking one-out-of NB_TH column.void* modular_(void* data){ // Data retrieving int* int_p = (int*) data; int width = int_p[0]; int height = int_p[1]; int id_th = int_p[2]; int** vec_p = (int**) (int_p + 3); int* thread_status = vec_p[0]; int*** mat_p = (int***) (vec_p + 1); int** A = mat_p[0]; int** B = mat_p[1]; int** C = mat_p[2]; // Iterating on columns for(int i = 0; i < width; ++i) if(i % NB_TH == id_th) for(int j = 0; j < height; ++j) for(int k = 0; k < width; ++k) C[i][j] += A[i][k] * B[k][j];#ifdef UNJOIN for(;thread_status[-1];sleep(0)) thread_status[id_th] = THREAD_OVER;#else thread_status[id_th] = THREAD_OVER;#endif pthread_exit(NULL);}// Split the mult' in many blocs on j axis. Cache-friendly on B.void* B_bloc_(void* data){ // Data retrieving int* int_p = (int*) data; int width = int_p[0]; int height = int_p[1]; int id_th = int_p[2]; int** vec_p = (int**) (int_p + 3); int* thread_status = vec_p[0]; int*** mat_p = (int***) (vec_p + 1); int** A = mat_p[0]; int** B = mat_p[1]; int** C = mat_p[2]; // Calculating blocs size int blk_width = BLK; int cursor = id_th * blk_width; // Iterating on blocs while(cursor < width) { for(int i = 0; i < width; ++i) for(int j = cursor; j < cursor + blk_width; ++j) for(int k = 0; k < width; ++k) C[i][j] += A[i][k] * B[k][j]; cursor += NB_TH * blk_width; } // Various stuff and exit.#ifdef UNJOIN for(;thread_status[-1];sleep(0)) thread_status[id_th] = THREAD_OVER;#else thread_status[id_th] = THREAD_OVER;#endif pthread_exit(NULL);}// Split the mult' in blocs on i, j, and k axis. Ensure local data.void* K_bloc_(void* data){ // Data retrieving int* int_p = (int*) data; int width = int_p[0]; int height = int_p[1]; int id_th = int_p[2]; int** vec_p = (int**) (int_p + 3); int* thread_status = vec_p[0]; int*** mat_p = (int***) (vec_p + 1); int** A = mat_p[0]; int** B = mat_p[1]; int** C = mat_p[2]; pthread_mutex_t** mut_p = (pthread_mutex_t**) (mat_p + 3); pthread_mutex_t* mutex = mut_p[0]; // Calculating bloc size int blk_width = width / BLK; int blk_i = (id_th % BLK) * blk_width; int blk_j = ((id_th / BLK) % BLK) * blk_width; int blk_k = ((id_th / (BLK * BLK)) % BLK) * blk_width; int blk_id = id_th % (BLK * BLK); // Creating local matrix for saving local results int** C_local; build_mat_(&C_local, blk_width, blk_width); // Initializing matrix to 0 for(int i = 0; i < blk_width; ++i) for(int j = 0; j < blk_width; ++j) C_local[i][j] = 0; // Iterating on the bloc for(int i = blk_i, i_l = 0; i < blk_i + blk_width; ++i, ++i_l) for(int j = blk_j, j_l = 0; j < blk_j + blk_width; ++j, ++j_l) for(int k = blk_k; k < blk_k + blk_width; ++k) C_local[i_l][j_l] += A[i][k] * B[k][j]; // Locking the bloc on targeted matrix to write local results pthread_mutex_lock(mutex + blk_id); for(int i = blk_i, i_l = 0; i < blk_i + blk_width; ++i, ++i_l) for(int j = blk_j, j_l = 0; j < blk_j + blk_width; ++j, ++j_l) C[i][j] += C_local[i_l][j_l]; pthread_mutex_unlock(mutex + blk_id); // Free memory free(C_local); // Various stuff and exit.#ifdef UNJOIN for(;thread_status[-1];sleep(0)) thread_status[id_th] = THREAD_OVER;#else thread_status[id_th] = THREAD_OVER;#endif pthread_exit(NULL);}// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// MAIN// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /int main(int argc, char** argv){#ifdef TM int width = TM; int height = width;#else int width = atoi(argv[1]); int height = width;#endif// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// CREATINGMATRIX// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // Contiguous columns to help the cache int **A, **B, **C, **D; build_mat_(&A, width, height); build_mat_(&B, width, height); build_mat_(&C, width, height); build_mat_(&D, width, height); // Initialize them to various values for(int i = 0; i < width; ++i) for(int j = 0; j < height; ++j) { A[i][j] = (i * i) % (j + 1) + i; B[i][j] = (i * j) % (i + 1) + j; C[i][j] = 0; D[i][j] = 0; }// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// CALCULATEREFERENCE RESULT (NAIVE)// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // Naive calculus of the resulting matrix clock_t naive_start = clock(); for(int i = 0; i < width; ++i) for(int j = 0; j < height; ++j) for(int k = 0; k < width; ++k) D[i][j] += A[i][k] * B[k][j]; clock_t naive_end = clock();// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// PREPARING THREADS// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // / pthread_t thread_id[NB_TH]; void* thread_p[NB_TH]; // Thread status vector, mostly used with -DUNJOIN int* thread_status = (int*) malloc(sizeof(int) * (NB_TH + 1)); for(int i = 0; i < (NB_TH + 1); ++i) thread_status[i] = THREAD_WAIT; ++thread_status; // Checking asserts and execute method-related initializations. assert(width == height);#ifdef B_bloc assert(width % BLK == 0);#elif defined(K_bloc) assert(NB_TH == BLK * BLK * BLK); assert(width % BLK == 0); pthread_mutex_t* K_bloc_mutex = malloc(sizeof(pthread_mutex_t) * (NB_TH / BLK)); for(int i = 0; i < NB_TH / BLK; ++i) pthread_mutex_init(K_bloc_mutex + i, NULL);#endif // Initialize thread's parameters. for(int i = 0; i < NB_TH; ++i) { thread_p[i] = MALLOC_P_TH(); int* int_p = (int*) thread_p[i]; int_p[0] = width; int_p[1] = height; int_p[2] = i; int** vec_p = (int**) (int_p + 3); vec_p[0] = thread_status; int*** mat_p = (int***) (vec_p + 1); mat_p[0] = A; mat_p[1] = B; mat_p[2] = C;#ifdef K_bloc pthread_mutex_t** mut_p = (pthread_mutex_t**) (mat_p + 3); mut_p[0] = K_bloc_mutex;#endif }// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// STARTING THREADS// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // Start the thread's timer clock_t thread_start = clock(); for(int i = 0; i < NB_TH; ++i) pthread_create(&thread_id[i], NULL, FOO_TH, thread_p[i]);// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// WAITINGTHREADS// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /#ifndef UNJOIN for(int i = 0; i < NB_TH; ++i) pthread_join(thread_id[i], NULL);#else for(int i, status = THREAD_WAIT; status == THREAD_WAIT;) for(i = 0, status = THREAD_OVER; i < NB_TH; ++i, sleep(0)) status = status || thread_status[i];#endif // End the thread's timer clock_t thread_end = clock(); for(int i = 0; i < NB_TH; ++i) assert(thread_status[i] == THREAD_OVER); thread_status[-1] = THREAD_OVER;// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// CHECKING THERESULT// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // / for(int i = 0; i < width; ++i) for(int j = 0; j < height; ++j) if(C[i][j] != D[i][j]) return 1;// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /// FREEING MEMORY// / // / // / // / // / // / // / // / // / // / // / // / // / // / // / // /#ifdef K_bloc free(K_bloc_mutex);#endif free(--thread_status); for(int i = 0; i < NB_TH; ++i) free(thread_p[i]); free(A); free(B); free(C); free(D); float naive_time = ((float) naive_end - naive_start) / CLOCKS_PER_SEC; float thread_time = ((float) thread_end - thread_start) / CLOCKS_PER_SEC; printf(%f\n, naive_time); printf(%f\n, thread_time); printf(%f\n, thread_time / naive_time); return 0;}Sample output:gcc -Dmodular -DNB_TH=8 -pthread -std=gnu11 -Wall -Wextra -pedantic -Wno-unused ./mat_mult.c -o modulargcc -DB_bloc -DNB_TH=8 -pthread -std=gnu11 -Wall -Wextra -pedantic -Wno-unused ./mat_mult.c -o B_blocgcc -DK_bloc -DNB_TH=8 -pthread -std=gnu11 -Wall -Wextra -pedantic -Wno-unused ./mat_mult.c -o K_bloc./modular 1280.0099410.0091690.922342./B_bloc 1280.0100690.0084710.841295./K_bloc 1280.0097710.0103461.058848./modular 2080.0386600.0822872.128479./B_bloc 2080.0381760.0483731.267105./K_bloc 2080.0379380.0518021.365438./modular 4000.3297820.5023671.523331./B_bloc 4000.3271450.5018081.533901./K_bloc 4000.3249830.6389291.966038./modular 10249.32289116.2631611.744433./B_bloc 10249.13641416.8749431.846999./K_bloc 10248.65123315.3782311.777577
Multiplying square matrix with C pthreads (POSIX threads)
performance;c;multithreading;matrix;pthreads
Wrong loop orderIn your naive matrix multiplication, you have your loops in a suboptimal ordering. I compared your implementation with this one, where I swapped the second and third loops:for(int i = 0; i < width; ++i) for(int k = 0; k < width; ++k) for(int j = 0; j < height; ++j) D[i][j] += A[i][k] * B[k][j];When I ran B_bloc 1024, I got these numbers (no threads involved):Original loops: 9.89 secSwapped loops : 1.07 secSo clearly you need to think about cache usage a little bit more. The version I listed here is more cache friendly because A[i][k] is constant in the inner loop while the other two matrices are being iterated in memory order. With the original loops where the inner loop iterated on k, the B[k][j] term was jumping cache lines on every loop iteration.Use a struct!The code you use to pass information between the main thread and the pthreads is not good at all. You are reinventing the wheel by constructing your own handcoded struct: // This is what MALLOC_P_TH() calls: void* default_alloc_() { return malloc(0 + sizeof(int) * 3 + sizeof(int*) * 1 + sizeof(int**) * 3 ); } // In main(): thread_p[i] = MALLOC_P_TH(); int* int_p = (int*) thread_p[i]; int_p[0] = width; int_p[1] = height; int_p[2] = i; int** vec_p = (int**) (int_p + 3); vec_p[0] = thread_status; int*** mat_p = (int***) (vec_p + 1); mat_p[0] = A; mat_p[1] = B; mat_p[2] = C;You should be using an actual struct, like this:typedef struct ThreadArgs { int width; int height; int threadNum; int *pStatus; int **matrixA; int **matrixB; int **matrixC;} ThreadArgs;// In main():thread_p[i] = malloc(sizeof(ThreadArgs));thread_p[i]->width = width;thread_p[i]->height = height;thread_p[i]->threadNum = i;thread_p[i]->pStatus = thread_status;thread_p[i]->matrixA = A;thread_p[i]->matrixB = B;thread_p[i]->matrixC = C;As you can see, this improves the code in many ways:You don't have to have a custom function just to compute the size of the struct.Your fields are actually named, so you can refer to each field by name rather than number.If you need to add or remove fields, you simply make modifications to the struct rather than fiddling with the handcoded arrays.Using the wrong clock functionWhen I ran your program, I was surprised to see that none of your multithreaded versions ran faster than the single threaded version. However, I discovered that you were using the wrong function to time your program. The clock() function measures cpu cycles used across all threads. So even if your program ran 8 times faster, you would still get the same reading from clock() as for a single threaded program. What you want is a wall clock measurement. I would suggest using something like clock_gettime() or gettimeofday(). After I modified your program to use clock_gettime() and fixed the loop orders, I ran B_bloc and got the following output, which makes a lot more sense (I have a 4 core system, so 0.25 on the third line is expected):$ B_bloc 10241.1029120.2767520.250928
_datascience.2623
The mnlogit package in R allows for the fast estimation of multinomial logit models.The specification of forumlas is a bit different from most other regression models/packages in R, however. Using the Fish dataset as a reproducible example, > require(mnlogit)Loading required package: mnlogitPackage: mnlogitVersion: 1.1.1Multinomial Logit Choice Models.Scientific Computing Group, Sentrana Inc, 2013.> data(Fish, package ='mnlogit')> head(Fish) mode income alt price catch chid1.beach FALSE 7083.332 beach 157.930 0.0678 11.boat FALSE 7083.332 boat 157.930 0.2601 11.charter TRUE 7083.332 charter 182.930 0.5391 11.pier FALSE 7083.332 pier 157.930 0.0503 12.beach FALSE 1250.000 beach 15.114 0.1049 22.boat FALSE 1250.000 boat 10.534 0.1574 2I'm trying to understand the difference between the model specification of fm <- formula(mode ~ 0 + price | income | catch)andfm <- formula(mode ~ 0 + price | income + catch)while the documentation covers the detail of such changes in the general coeffcient area of the forumla (i.e. where price is), I don't see an explanation of how operators like + affect the alternative-specific area of the formula/code, relative to |.
How to Interpret Multinomial Specification in R's `mnlogit` package
r;logistic regression;regression
null
_unix.123370
Following is what i would like to have.When the tab completion is ambiguous, and bash prints the list of possibilities. I would like it to colour the next character I should press inside every word in the list.Following is what i have done so far.In my .bashrc i have defined the following functionand have called the complete command_colourunique() { local word=${COMP_WORDS[COMP_CWORD]} COMPREPLY=($(compgen -f -- ${word})) if [[ $word ]] && [[ ${#COMPREPLY[@]} -gt 1 ]]; then local w local i=0 for ((i=0;i<${#COMPREPLY[@]};i++)) ; do w=${COMPREPLY[$i]} n=${#word} COMPREPLY[$i]=${w:0:n}\033[91m${w:n:1}\033[0m${w:$((n+1))} done fi}complete -D -F _colouruniqueBut it is not working...When i typels D[TAB]It autocompletes as ls D\033[91mInstead of listing the possibilities Documents, Desktop etc.What could be going wrong here?Or is there some other direct way to accomplish this?UPDATE 1:I think i understand what is happening here. Since i add \033[91m to every word in COMPREPLY, bash sees this part is common to all, and autocompletes that common term into the command prompt itself. (instead of simply printing the list)So I don't think this method of editing COMPREPLY array is the way to do it.Is there any other method?UPDATE 2:To preserve the uniqness, i tried to add a $i and \b in the string.COMPREPLY[$i]=${w:0:n}$i\b\033[91m${w:n:1}\033[0m${w:$((n+1))}Now it prints the possible tab completions as following.D0\b\033[91mo\033[0mwnloads D1\b\033[91me\033[0msktopWhich means, the list is printed as such. There is no evaluation of \b or \033[91m characters. :-( UPDATE 3:Since the replies looks like, there is no way to accomplish what i want in bash (unless i shift to zsh). I decided to settle for another option. I will try to append the next unique key stroke to end of every word, so that it stands out.Following is the code so far.SanitiseString () { local String=$1 local j for j in \\ \! \@ \# \$ \% \^ \& \* \( \) \+ \{ \[ \] \} \| \; \: \ \' \, \? \ ; do String=${String//$j/\\$j} done echo $String}_colourunique() { saveIFS=$IFS IFS=$'\n' local word=${COMP_WORDS[COMP_CWORD]} COMPREPLY=($(compgen -f -- ${word})) if [[ $word ]] ; then local w local i=0 for ((i=0;i<${#COMPREPLY[@]};i++)) ; do w=${COMPREPLY[$i]} n=${#word} w=$(SanitiseString $w) if [[ ${#COMPREPLY[@]} -gt 1 ]] ; then COMPREPLY[$i]=$w :${w:n:1} else COMPREPLY[$i]=$w fi done fi IFS=$saveIFS}complete -D -F _colouruniqueThis will print the options with the next unique keystroke separated by :But the code still has two irritating issues. which i have to solveIt no longer appends the / at the end of autocompleted directoriesIt no longer does the intelligent spacing after the auto complete.Any suggestions?
how to edit and color bash's tab completion list
bash;colors;autocomplete
null
_unix.336423
I'd like to disable the output I get from VLC when calling it from bash. You can see that output on the following picture: So, how do I disable that? Redirecting output to /dev/null like described here doesn't work.Note that, on the picture, I had to send kill sign twice to kill it, why if there is just one process? Or are there two? Maybe there are actually two processes and with my command only the output of the first one is redirected.?If I run it in the background, and I send kill singal, first, it looks like process is no longer running in shell but just in a window, but than, soon I get some messages again. Check out the picture:So anyway, I just want to disable that output.UPDATE:And I want to run it in background too. vlc &> /dev/null The following should work, but right now I've tried and it didn't work well.vlc filename &> /dev/null & And here's what I've got:I play the file, at first it looks okay, then I start changing directories and issuing other commands, and VLC output comes in againBut that was the first time I've tried, now it works, so I guess it'll work in future too.
How to suppress VLC output when calling it from shell
bash;vlc
If you use vlc > /dev/null then standard output will be redirected to /dev/null but standard error will go through to the terminal. You must use the command vlc &> /dev/null which will redirect both standard output and standard error. I've tested this and it works.According to the manual, vlc -q will enable quiet mode (suppress output) - I haven't tested this.EDITI'm not completely sure what you mean by in the background, but the program screen (sudo apt install screen) will allow you to start a command in a terminal, then close the terminal but keep the command running. nohup can also do this.Or, try pressing Alt-F2 at the desktop, you will probably get a prompt to run a command. You can run vlc from there, but unlike screen, you cannot interact with vlc in a terminal later.ANOTHER EDIT This question looks like just what you need. How to disable VLC output in command-line mode?
_unix.251751
I'm colorizing the header of a table formatted with column -ts $'\t'Works well without color codes, but when I add color codes to the first line column doesn't properly align the output.Without colored output it works as expected:printf 1\t2\t3\nasdasdasdasdasdasdasd\tqwe\tqweqwe\n | column -ts $'\t'But when adding color on the first line column doesn't align the text of the colored row:printf \e[7m1\t2\t3\e[0m\nasdasdasdasdasdasdasd\tqwe\tqweqwe\n | column -ts $'\t'Observed this behaviour both on Ubuntu Linux and Mac OS X.
Issue with column command and color escape codes
colors;escape characters;columns;text formatting;table
I imagine that column doesn't know that \e[7m is a v100 escape sequence that takes no space in the output. It seems to asssume character codes 0 to 037 octal take no space. You can get what you want by putting the initial escape sequence on a line of its own, then removing that newline from the output:printf '\e[7m\n1\t2\t3\e[0m\nasdasdasdasdasdasdasd\tqwe\tqweqwe\n' | column -ts $'\t' |sed '1{N;s/\n//}'
_webmaster.25655
Going over quite a bit of Open Source licenses on opensource.org I am still not very clear which one I should aim for. What I want the license to do is the following.Open Source licenseInitial Developer(s)/Contributer(s) are to be credited and all copyright notices, credit notices as well as trademark and/or patten notices to remain in the Source Code and in no way may be altered. Any software based of original Source Code are to be licensed under the same license as the original source and all source code must be available to end-user. Also any copy or re-distribution and/or fork must contain original copyright notices by Initial Developer(s)/Contributer(s)The license is royalty-free for non-commercial use, non-profit organization use and /or any personal use.The source code may be licensed under commercial license for commercial use, but must be done so with first acknowledge the Original Developer and for royalty. Even so any commercial license may not prevent the Initial Developer from continuing of licensing, development and distribution of original Source Code for personal, non-commercial and non-profit use under the original license and without any fee.Commercial license can't and shall not effect or hold any of original Source Code that may prevent the re-use of the original Source Code by 3rd party developers, re-distributer and or forked projects.The license applies internationallyI wish to allow the use of the software for commercial/small-business use but for a small royalty. However I do not want to get screwed into having that commercial institution the sole holder of the original Source Code. I still need to make sure I the Initial Developer and any Contributers retain the source code as there own and not any 3rd party. So what would be the best suggestions for a license close to the 7 points that I made.
a good licence for a CMS?
cms;open source;licenses
null
_unix.74130
I am trying to install the calendar.vim plugin on mac osx snow leopard running gvim. I have pathogen.vim installed, so I followed the instructions on github to install calendar.vim from the terminal:cd ~/.vim/bundlegit clone git://github.com/mattn/calendar-vimI've got it, and everything appears to be where it is supposed to be, as far as I can tell, but it isn't working. I type :Calendar a get the error:E492: Not an editor command: CalendarI've tried :calendar also, I have restarted vim and no luck. What am I missing?
Calendar.vim E492: Not an editor command: Calendar
vim;osx;macintosh;gvim;vimrc
null
_vi.2782
What files do I need to create? What should be inside these files? Is there a default colorscheme file somewhere that I can use and change color values accordingly?
How can I create my own colorscheme?
colorscheme
Colorscheme locationsFirst, Vim looks in its runtime folders for a colors directory. Here is where all the colorschemes should be stored (:help 'runtimepath')This means you will need one file that lives in the ~/.vim/colors folder. Default colorschemes are located in $VIMRUNTIME/colors, where $VIMRUNTIME is usually /usr/share/vim/vim74 or the /usr/local/share/vim/vim74 directories, depending on how Vim is installed (substitute vim74 for vim73 for Vim version 7.3)Now to get to the fun part.Creating a colorschemeTo get started with creating your own colorscheme, I highly suggest taking a look at the default colorschemes and experiment with modifying them.So copy the default colorscheme from $VIMRUNTIME/colors folder to your ~/.vim/colors folder. Name it something that distinguishes itself from the default colorscheme name. So if you copied the desert colorscheme that comes with Vim by default, name the file as default_mod.vim or something to that effect. Open up the colorscheme file and change the let g:colors_name to also distinguish itself from the default colorscheme file. By convention, this should be the same as the colorscheme file name.In the colorscheme, all you have to do is give the colors for ctermbg, ctermfg, guibg, guifg (for terminal background, terminal foreground, gui background, gui foreground colors respectively) for the different built in highlight groups. To check out the list of highlight groups you can modify, check out :help highlight-default. Optionally, you can also use the cterm and gui attributes to specify that you want a highlight group to be bold or italic. For example, this will set a green color for a String:highlight String ctermbg=NONE ctermfg=107 guibg=NONE guifg=#95B47BYou can also use highlight links to link a highlight group to another group. This is useful if you want two highlight groups to be the same colors.For instance, you could link the diffAdded highlight group to the String highlight group defined above:highlight link diffAdded String
_softwareengineering.221446
I am writing a paper on the tension between OOP and Generic programming created by Stepanov. He widely criticizes OOP and says it is technically flawed when compared to Generic Programming. Now I know we have plenty of programming languages that support OOP exclusivley and have no Generic support including Google GO for example, that is a modern language that they chose not to implement Generics because of their complexity. I know we have plenty of languages that support both Generics and OOP, for example C++ and Stepanov's famous STL library.My question is: Do we have any modern programming languages or any at all that support Generics exclusively without OOP?EDIT: I would like to add I tried looking around and cant seem to find much so I figured I would ask here.Just to add that when I refer to Generic vs Object Oriented Programming I am refering to:Generic Vs Object Oriented ProgrammingOn the Tension Between Object-Oriented and Generic Programming in C++
Any programming languages that support Generics exclusively and have no OOP support?
java;c++;object oriented;generics;generic programming
Generic programming encompasses more than just Generics, which in turn is another name for parametric polymorphism. This concept is rather widespread and not constrained to object-oriented languages. It is a distinguishing feature of the ML language family which includes Standard ML, Ocaml (which also supports OOP, but is primarily functional) and Haskell.Parametric polymorphism isn't the only way to do generic programming. For example, macro systems (like templates in C++) or a dynamic type system are other ways.However, OOP in its various flavours is another good and widespread way to do generic programming, e.g through the use of interfaces (or an equivalent concept) or duck typing. In this sense Go is generic, as a function in that language can take an argument that is only defined by its interface.
_unix.385595
I have a USB wireless adapter I want to use in my Kali Linux VM, but it doesn't show under removable devices in VMware, so I can't pass it through. I'm not sure if this is the right place to ask, but does anyone have an idea? I have the VMware tools installed in Kali.
VMware won't recognize my Wi-Fi USB adapter I want to use in my Kali Linux VM
kali linux;vmware
null
_datascience.17287
I've read that some convolution implementations use FFT to calculate the output feature/activation maps and I'm wondering how they're related. I'm familiar with applying CNNs, and (mildly) familiar with the use of FFT in signal processing, but I'm not sure how the 2 work togetherWhen I think of convolutions, I imagine taking a kernel, flipping it, multiplying (and adding) the elements of the kernel with the overlapping input, shifting the kernel and repeating the process. How does a FFT fit into this process?
Convolutional neural network fast fourier transform
machine learning;neural network;convnet
By transforming both your signal and kernel tensors into frequency space, a convolution becomes a single element-wise multiplication, with no shifting or repeating.So you can convert your data and kernel into frequencies using FFT, multiply them once then convert back with an inverse FFT. There are some fiddly details about aligning your data first, and correcting for gain caused by the conversion.If you have a good FFT library, this can be very efficient, but there is overhead cost for running the Fourier transform and its inverse, so your convolution needs to be relatively large before it is worth looking at FFT.I have explored this a while ago in a Ruby gem called convolver. You can see some of the code for an FFT-based convolution here and the project includes unit tests that prove that direct convolution gets same numerical results as FFT-based convolution. There is also code that attempts to estimate when it would be more efficient to calculate convolutions directly by repeated multiplications or use FFT-based solution (that is rough and ready guesswork though, and implementation-dependent).
_codereview.9629
Flash messages are generally composed in the controller. Sometimes we need those flash messages to have links in them (like an undo button).How would you compose such a message?The only sane way I have found to create such messages is by a presenter that includes much of ActionView in it (in order to gain access to most of the view helpers).Right now the code in the controller looks like this:def publish @post.publish! flash[:notice] = Post <a href=\/posts/#{@post.id}\>#{@post.title}</a> + was published successfully redirect_to @postendand in the view I do a <%= raw flash[:notice] %> to display it.
HTML flash messages
ruby;ruby on rails;mvc
You actually have several options. One way to clean this up a bit would be to use Rails' I18n module, e.g.:# config/locales/en.ymlen: post_successful_html: Post <a href=%{url}>%{title}</a> was published successfully.# the `_html` suffix marks the string as HTML-safe automaticallyThen in your controller:flash[:notice] = t :post_successful_html, :url => post_path( @post ), :title => @post.titleAnd the view:<%= flash[:notice] %>(You could also do this the other way around and just put :post_successful_html in flash and then call t flash[:notice], :url => ... in the view but that feels messier to me.) Using I18n for just one thing seems a little like overkill but it is nice and clean (and if you've ever considered localizing your your app it's never too early to start).An alternative is to break what you need out into a partial, e.g. _post_successful_flash.html.erb:Post <%= link_to post.title, post %> was published successfully.And then in your controller:flash[:notice] = render_to_string :partial => 'post_successful_flash', :object => @post, :as => :postFinally, you could do it in a helper instead:module PostsHelper def render_post_successful post Post #{link_to post.title, post} was published successfully. endendThen in the controller:flash[:notice] = :post_successfulAnd the view:<%= render_post_successful @post if flash[:notice] == :post_successful %>Which one you should use is sort of a toss-up to me. I'm fond of the I18n approach but partly because I prefer to keep messages like this in locales anyway. Use whatever makes the most sense to you.
_unix.368859
The w3mimgdisplay program displays images in buffered terminal emulators. This is how: http://blog.z3bra.org/2014/01/images-in-terminal.html . But it is not very well documented. As pointed out in the post, this thread is probably the best you can get.Now, the problem is that the image does not stays when the terminal scrolls up. This post argues that w3m uses it as a persistent process to handle scrolling, but prefixing the command in line 7 with nohup or subfixing with & does not make any change. (And it's hard for me to trace back the use of w3mimgdisplay in w3m.)So the question resumes as how to execute this command line as a persistent process:echo -e 2;3;\n0;1;0;100;0;0;0;0;0;0;./image.png\n4;\n3; | /usr/lib/w3m/w3mimgdisplayUpdate:Tested on gnome-terminal on Lubuntu 16.04.This is the X-face patch by Tamo referred in the post above.
How to display inline images in a terminal that update on scroll with w3mimgdisplay
terminal;scrolling;w3m
null
_cs.30391
Let $\Sigma_n = \{0, 1, ... , n-1\}$. Suppose $L \subseteq$ $\Sigma^*_n$, and let $\qquad\displaystyle\mathcal{B}(L) = \{ x \in L : x = \textrm{lex}\max L_m, m \in \mathbb{N}_0 \}$,where $L_m = L \cap \Sigma_n^m$ and $\mathrm{lex}\max$ denoting the lexicographic maximum.For example, $\mathcal{B}(\{0,1\}^*) = 1^*$ and $\mathcal{B}(\epsilon \cup 1(0 \cup 01)^*) = (10)^*(\epsilon \cup 1)$. Prove that if $L$ is regular, then so is $\mathcal{B}(L)$. Any hints? I was thinking of perfect shuffling $L$ with itself, and then defining a morphism to compare each pair of characters in a shuffle to determine which is the lexicographically greater one.
Prove that REG is closed against removing all but lexicographicaly largest words (per length)
formal languages;closure properties
Here is the basic idea. Suppose that $x0y \in L$. When would $x0y \notin \mathcal{B}(L)$? Exactly when $x1z \in L$ for some $|z| = |y|$. When does that happen? Fix some DFA for $L$, and suppose that after reading $x1$, it is at state $q$. Parikh's theorem shows that the set of lengths $\ell$ such that $x1z \in L$ for some $|z| = \ell$ is eventually periodic, that is, it is of the form $L_0(q) \cup \{k m(q) + a : a \in L_1(q) \text{ and } k \geq 0\}$ for some finite $L_0(q),L_1(q)$. We can further assume that $m(q) = m$ is the same for all states $q$, since there are only finitely many of them and we can take the LCM of the minimal periods.As we read more and more zeroes, we obtain more and more constraints, which can be summarized in the form: the word cannot end in $\ell$ characters for $\ell \in L_0 + \{ km + a : a \in L_1 \}$. Note that there are only finitely many possibilities for $L_0$ and $L_1$, since $\max L_0 \leq \max_q \max L_0(q)$, and similarly for $L_1$. This means that we can store and maintain this information in a finite state automaton, and use it to decide $\mathcal{B}(L)$.
_codereview.48845
As I am relativistically new to programming and lack any sort of formal experience in the matter, I was wondering if any of you with a bit more knowledge in the subject would be willing to tell me if the following code is an acceptable way to accomplish a function binding event handler in Java 8.I admit that the naming conventions in the following code may be slightly off-par, however, it makes sense to me as a free-spirited beginner who cares not for package.thousand_sub-packages.overly_long_class_name_and_full_essay.java.Again, the purpose of this question is to ascertain if my solution is an acceptable one, and if it is not, what a proper one would be.First the main class:package TestingApp;import JGameEngineX.JGameEngineX;import Modes.Main_Game;import Modes.Main_Menu;import java.util.Random;/** * @author RlonRyan * @name JBasicX_TestingApp * @version 1.0.0 * @date Jan 9, 2012 * @info Powered by JBasicX * */public class JBasicX_TestingApp { public static JGameEngineX instance; public static final String[] options = {Lambda Style!, Javaaa!, Spaaaaaace!, Generic!, Automated!, Title goes here.}; public static void main(String args[]) { if (instance != null) { return; } String mode = args.length >= 1 ? args[0] : windowed; int fps = args.length >= 3 ? Integer.parseInt(args[2]) : 100; int width = args.length >= 4 ? Integer.parseInt(args[3]) : 640; int height = args.length >= 5 ? Integer.parseInt(args[4]) : 480; instance = new JGameEngineX(JBasicX Testing Application: + options[new Random().nextInt(options.length)], mode, fps, width, height); instance.registerGameMode(new Main_Menu(instance)); instance.registerGameMode(new Main_Game(instance)); instance.init(); instance.start(main_menu); }}Next the menu mode class:package Modes;import JGameEngineX.JGameEngineX;import JGameEngineX.JGameModeX.JGameModeX;import JIOX.JMenuX.JMenuElementX.JMenuTextElementX;import JIOX.JMenuX.JMenuX;import java.awt.Color;import java.awt.Graphics2D;import java.awt.event.KeyEvent;import java.util.Random;/** * * @author RlonRyan */public class Main_Menu extends JGameModeX { private JMenuX menu; public Main_Menu(JGameEngineX holder) { super(Main_Menu, holder); } @Override public void init() { menu = new JMenuX(Main Menu, 160, 120, 320, 240); menu.addMenuElement(new JMenuTextElementX(Start, () -> (holder.setGameMode(main_game)))); menu.addMenuElement(new JMenuTextElementX(Toggle Game Data, () -> (holder.toggleGameDataVisable()))); menu.addMenuElement(new JMenuTextElementX(Randomize!, () -> (holder.setBackgroundColor(new Color(new Random().nextInt(256),new Random().nextInt(256),new Random().nextInt(256)))))); menu.addMenuElement(new JMenuTextElementX(Reset!, () -> (holder.setBackgroundColor(Color.BLACK)))); menu.addMenuElement(new JMenuTextElementX(Quit, () -> (System.exit(0)))); } @Override public void registerBindings() { bindings.bind(KeyEvent.KEY_PRESSED, KeyEvent.VK_DOWN, (e) -> (menu.incrementHighlight())); bindings.bind(KeyEvent.KEY_PRESSED, KeyEvent.VK_UP, (e) -> (menu.deincrementHighlight())); bindings.bind(KeyEvent.KEY_PRESSED, KeyEvent.VK_ENTER, (e) -> (menu.selectMenuElement())); bindings.bind(KeyEvent.KEY_PRESSED, KeyEvent.VK_ESCAPE, (e) -> (System.exit(0))); bindings.bind(KeyEvent.KEY_PRESSED, (e) -> (System.out.println(Keypress: + ((KeyEvent) e).getKeyChar() + detected with lambda!))); } @Override public void start() { menu.open(); } @Override public void update() { // Update... } @Override public void pause() { // Do nothing } @Override public void stop() { menu.close(); } @Override public void paint(Graphics2D g2d) { menu.paint(g2d); }}Finally the binding class:package JEventX;import java.awt.AWTEvent;import java.awt.event.KeyEvent;import java.awt.event.MouseEvent;import java.util.ArrayList;import java.util.HashMap;import java.util.function.Consumer;import javafx.util.Pair;/** * * @author RlonRyan */public class JEventBinderX { private final HashMap<Pair<Integer, Integer>, ArrayList<Consumer<AWTEvent>>> bindings; public JEventBinderX() { bindings = new HashMap<>(); } public final void bind(int trigger, Consumer<AWTEvent> method) { bind(new Pair<>(trigger, 0), method); } public final void bind(int trigger, int subtrigger, Consumer<AWTEvent> method) { bind(new Pair<>(trigger, subtrigger), method); } public final void bind(Pair<Integer, Integer> trigger, Consumer<AWTEvent> method) { if (!this.bindings.containsKey(trigger)) { this.bindings.put(trigger, new ArrayList<>()); } this.bindings.get(trigger).add(method); } public final void release(int trigger) { release(new Pair<>(trigger, 0)); } public final void release(Pair<Integer, Integer> trigger) { if (this.bindings.containsKey(trigger)) { this.bindings.remove(trigger); } } public final void release(int trigger, Consumer<AWTEvent> method) { release(new Pair<>(trigger, 0), method); } public final void release(Pair<Integer, Integer> trigger, Consumer<AWTEvent> method) { if (this.bindings.containsKey(trigger)) { this.bindings.get(trigger).remove(method); } } public final void fireEvent(AWTEvent e) { Pair<Integer, Integer> id = null; if(e instanceof MouseEvent) { id = new Pair<>(e.getID(), ((MouseEvent)e).getButton()); } else if(e instanceof KeyEvent) { id = new Pair<>(e.getID(), ((KeyEvent)e).getKeyCode()); } if(id != null && this.bindings.containsKey(id)){ bindings.get(id).stream().forEach((c) -> c.accept(e)); } id = new Pair<>(e.getID(), 0); if(this.bindings.containsKey(id)) { bindings.get(id).stream().forEach((c) -> c.accept(e)); } } public final void fireEvent(AWTEvent e, int subid) { Pair<Integer, Integer> id = new Pair<>(e.getID(), subid); if(this.bindings.containsKey(id)){ bindings.get(id).stream().forEach((c) -> c.accept(e)); } }}[Edit] And the JGameModeX classpackage JGameEngineX.JGameModeX;import JEventX.JEventBinderX;import JGameEngineX.JGameEngineX;import java.awt.Graphics2D;/* * public static enum GAME_STATUS { * * GAME_STOPPED, * GAME_INTIALIZING, * GAME_STARTING, * GAME_MENU, * GAME_RUNNING, * GAME_PAUSED; * } *//** * * @author RlonRyan */public abstract class JGameModeX { public final String name; public final JEventBinderX bindings; public final JGameEngineX holder; public JGameModeX(String name, JGameEngineX holder) { this.name = name.toLowerCase(); this.bindings = new JEventBinderX(); this.holder = holder; } public abstract void init(); public abstract void registerBindings(); public abstract void start(); public abstract void update(); public abstract void paint(Graphics2D g2d); public abstract void pause(); public abstract void stop();}
Event Binding in Java employing Lambda
java;beginner
null
_reverseengineering.6755
I have been doing a lot of reading into how to find vulnerabilities in closed source applications. And the term that comes up a lot is fuzzing. I want to get started with fuzzing and I looking for any tips and hints on where and how to start. What tools to use, etc .
Getting started with dynamic reverse engineering
fuzzing
null
_unix.324235
I have a Linux server that's running a custom distro, I have a lot of problems with spam running through my server but I have no idea how. This is the sendmail configuration: divert(0)dnlinclude(`../m4/cf.m4')dnlOSTYPE(linux)dnldefine(`CERT_DIR', `/etc/mail/certs')define(`confCACERT_PATH', `CERT_DIR')define(`confCACERT', `CERT_DIR`'/cacert.pem')define(`confSERVER_CERT', `CERT_DIR`'/smtpcert.pem')define(`confSERVER_KEY', `CERT_DIR`'/smtpkey.pem')define(`confCLIENT_CERT', `CERT_DIR`'/smtpcert.pem')define(`confCLIENT_KEY', `CERT_DIR`'/smtpkey.pem')define(`confCRL', `/etc/ssl/crl.pem')define(`confLDAP_CLUSTER', `XXmail')define(`confLDAP_DEFAULT_SPEC',`-h localhost -bou=sendmail,ou=services,dc=XXXXXXXXXXXXXXXX,dc=XX')define(`confMAX_HEADERS_LENGTH', `32768')define(`QUEUE_DIR', `/srv/sendmail/mqueue')define(`confPRIVACY_FLAGS', `noexpn,novrfy,noverb,noetrn,authwarnings,nobodyreturn,goaway')define(`confLOG_LEVEL',`14')dnl FEATURE(`no_default_msa')dnl DAEMON_OPTIONS(`Family=inet, Port=smtp, Name=MTA')dnldnl DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, Modify=s')dnldnl DAEMON_OPTIONS(`Port=465, Name=MSA, Modify=E')dnldnl DAEMON_OPTIONS(`Port=587, Name=MSA, Modify=E')dnlEXPOSED_USER(`root')FEATURE(`nouucp', `reject')dnlFEATURE(`redirect')dnlFEATURE(`use_cw_file')dnlFEATURE(`access_db', `LDAP')dnlFEATURE(`blacklist_recipients')dnlFEATURE(`compat_check')dnlFEATURE(`nocanonify')dnlFEATURE(`virtusertable', `LDAP')dnlFEATURE(`virtuser_entire_domain')dnlFEATURE(`always_add_domain')dnlFEATURE(`genericstable', `LDAP')dnlFEATURE(`generics_entire_domain')dnlFEATURE(dcc,``F=T, T=C:30s;S:30s;R:30s;E:30s'')dnldnl FEATURE(dnsbl)dnlVIRTUSER_DOMAIN_FILE(`-o /etc/mail/virtuserdomain')dnlINPUT_MAIL_FILTER(`clamav', `S=local:/var/run/clamav/clmilter.sock, F=, T=S:4m;R:4m')dnlINPUT_MAIL_FILTER(`spamassassin', `S=local:/var/run/spamass.sock, F=, T=C:15m;S:4m;R:4m;E:10m')dnldefine(`confINPUT_MAIL_FILTERS', `spamassassin,clamav')dnldefine(`confMILTER_MACROS_CONNECT',`b, j, _, {daemon_name}, {if_name}, {if_addr}')dnldefine(`confMILTER_MACROS_ENVRCPT',`r, v, Z')dnldefine(`confMILTER_MACROS_EOM', `{msg_id}, {mail_addr}, {rcpt_addr}, i')dnldefine(`ALIAS_FILE', `ldap:-k (&(objectClass=sendmailMTAAliasObject)(sendmailMTAKey=%0)) -v sendmailMTAAliasValue -b ou=aliases,ou=sendmail,ou=services,dc=plazapublishing,dc=se')dnldefine(`confLOCAL_MAILER', `cyrusv2')dnldnl set SASL optionsTRUST_AUTH_MECH(`PLAIN')dnldefine(`confAUTH_OPTIONS', `A p')dnldefine(`confAUTH_MECHANISMS', `PLAIN')dnlMAILER(`local')dnlMAILER(`cyrusv2')dnlMAILER(`smtp')dnlI've installed sawmill log analyzer and changed the loglevel to 14. From what I can see, the emails comes outside of the network and is sent to another person outside the network. And it seems like they don't authenticate to use the SMTP server at all. I've tried to find the vulnerability that they use myself without success.Majority of spam emails says that LOCALHOST is the relay..I've tested the server for open relay and all kinds of vulnerabilities.
A lot of spam being sent with sendmail
linux;sendmail
null
_unix.238799
systemctl hybrid-sleep or anything similar is, according to the manual, supposed to execute all scripts found in /lib/systemd/system-sleep and after that continue it's own execution.Instead it completely and utterly ignores every single script I put in there:gnome-terminal -e touch Documents/qwertwhile [ 1 ] do echo hidone^ this should go in an infinite loop after creating a file. I've also tried things like touch /home/u/Documents/qwert etc.I'm pretty puzzled actually. It might actually be caused by the fact that hybrid-sleep, hibernate, etc. all lead to a crash before complete execution, i.e. my laptop is unable to enter any kind of power saving mode and instead goes into a completely frozen state with a blank screen - however, it logs out before that and only crashes after a couple of seconds, so I assume the scripts should be executed just fine; after all those should be executed even before logging out.
systemctl not running scripts under system-sleep
bash;systemd;suspend
gnome-terminal won't run from there as there is no X server for it to connect to (it's running as root, not as your logged in user). gnome-terminal isn't needed and is overkill here anyway. Just run touch /home/u/Documents/qwert without gnome-terminal -ealso:Make sure the script is executable (with chmod +x scriptname).Add #! /bin/sh or (#! /bin/bash if you use any bash-only features) as the first line of the script.