summary
stringlengths
15
147
text
stringlengths
1
19.3k
answer
stringlengths
32
22.6k
labels
float64
0.33
1
answer_summary
stringlengths
5
164
Create and open file with one command?
I want to create a text file and open it in a text editor with a single command. I know touch file.txt creates a file and open file.txt opens the file, but is there a way to do this with a single command?
Like everyone is telling you, this depends on your editor. And if you don't like the way your editor handles this, that can probably be configured, as well. With Emacs, emacs new_file.txt (for a nonexistent new_file.txt in the current directory) will bring up Emacs and display a buffer that refers to a new_file.txt. However, until you save, there will be no such file. If you don't do anything and quit, no file will have been created. While this is certainly one way, I think an even better way is to always have an instance of Emacs running. So, whenever you feel the need for a new file, go to Emacs, hit C-x C-f (or M-x find-file RET), then write the path to the nonexistent file, and you're at the same point as after the CLI command (above, in the second paragraph).
0.888889
emacs new_file.txt will display a buffer that refers to a nonexistent file in the current directory
Is there a good business plan template?
I'm looking for a good business plan LaTeX template for a web startup. In my opinion it shouldn't have a standing out "classic" look - for example, fonts like Caslon, Garamond or Computer Modern ooze too much authority for a small company in my eyes; however, I'm open to everything. Any suggestions / pointers greatly appreciated!
To answer this older question: No, there seems to be no business plan template in LaTeX available. There is nothing on CTAN and I only could find unsuccessful forum / usenet threads about the topic: https://groups.google.com/forum/#!topic/latexusersgroup/Dyz3Vyk7ZVk http://www.latex-community.org/forum/viewtopic.php?f=4&t=4659 http://www.latex-community.org/forum/viewtopic.php?f=4&t=787 In my experience this kind of documents is done by people which hardly use LaTeX. Even so it is normally done by a group of people which collaborate on it and as long not everyone is using LaTeX this doesn't work easily. I know it from my patent submissions where it is a little similar. Even if someone would have written a good business plan with LaTeX it is a lot of work to turn it into a good, general template, which people which just finished a business plan usually don't have. I would recommend you to search for general guidelines about how a business plan should look like and then ask specific questions here if you have trouble getting one of the guidelines implemented.
0.888889
No business plan template in LaTeX
What is another way to put "mistaken about what one saw"?
Is there any more slangy/easy way of saying "mistakenly about what one saw"? Like in the below example what else can be replaced Maybe I was mistaken.? A: I think I heard something in the dark. B: I didn't hear anything. A: Maybe I was mistaken.
mistaken is easy and unambiguous so better use this word only. Still, if you want other ways to say that, here are they... A: I think I heard something in the dark. B: I didn't hear anything. A: Maybe, I was mislead about that sound. OR Maybe, it could be something else! OR Maybe, I misunderstood it as some sound. To avoid ambiguity, I'd prefer the second one - Maybe, it could be something else (not sound).
0.777778
mistaken is easy and unambiguous.
NancyFX - Return custom error response on uncaught exception
I'm trying to get my self-hosted service using Nancy to return json formatted errors upon an uncaught exception. However, I am always getting the response: {"readyState":4,"status":404,"statusText":"error"} (below is the amalgamation of several examples across the net). My bootstrapper contains the following: pipelines.OnError.AddItemToEndOfPipeline((ctx, exc) => { if (exc is Exception) { // this is always executed upon failure to handle an exception. Log.Error("Unhandled error on request: " + context.Request.Url + " : " + exc.Message, exc); JsonResponse response = new JsonResponse(string.Format("{0}:{1}", exc, exc.Message), new DefaultJsonSerializer()); response.StatusCode = HttpStatusCode.InternalServerError; return response; } return HttpStatusCode.InternalServerError; }); I have a StatusCodeHandler: public class JsonErrorStatusCodeHandler : IStatusCodeHandler { public bool HandlesStatusCode(HttpStatusCode statusCode, NancyContext context) { return statusCode == HttpStatusCode.InternalServerError; } public void Handle(HttpStatusCode statusCode, NancyContext context) { var exception = context.GetException(); if (exception != null) { // never executed } // this is executed JsonResponse response = new JsonResponse("wtf"), new DefaultJsonSerializer()); response.StatusCode = HttpStatusCode.InternalServerError; context.Response = response; } Although I've verified that the code in OnError and Handle is executed (see comments), my clients still receive 404. I've also tried using var exception = context.Items[NancyEngine.ERROR_EXCEPTION] as Exception; instead of var exception = context.GetException(); with no luck.
Gah, so this was a CORS issue. I'm automatically adding the CORS headers to the response: protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) { pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) => { ctx.Response.WithHeader("Access-Control-Allow-Origin", "*") .WithHeader("Access-Control-Allow-Methods", "POST,GET") .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type"); }); pipelines.OnError.AddItemToEndOfPipeline((ctx, exc) => { if (exc != null) { throw exc; } return HttpStatusCode.InternalServerError; }); base.RequestStartup(container, pipelines, context); } But when the response is replaced in my status code handler I need to set these headers again: public class JsonErrorStatusCodeHandler : IStatusCodeHandler { public bool HandlesStatusCode(HttpStatusCode statusCode, NancyContext context) { if (statusCode != HttpStatusCode.InternalServerError) { return false; } var exception = context.GetException(); return exception != null; } public void Handle(HttpStatusCode statusCode, NancyContext context) { var exception = context.GetException(); JsonResponse response = new JsonResponse(string.Format("{0}:{1}", exception, exception.Message), new DefaultJsonSerializer()); response.StatusCode = HttpStatusCode.InternalServerError; context.Response = response; context.Response.WithHeader("Access-Control-Allow-Origin", "*") .WithHeader("Access-Control-Allow-Methods", "POST,GET") .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type"); } }
0.888889
Adding CORS headers to response
SQL Server: update table from xml string
this is the first time I am working with an XML input in SQL. I created the following procedure to insert all records from my XML string into my table which works well so far. Can someone tell me how I have to change this so that it only inserts a record as new if the itemID (every record in my XML has this as well) does not yet exist in my table, column itemID - otherwise it should update the existing record with the new data from the XML. I know how to use IF NOT EXISTS and UPDATE in general but am not sure how to realise this with an XML string as the input. My procedure (so far): ALTER PROCEDURE [dbo].[editor_UpdateQuestions] @xml xml AS BEGIN SET NOCOUNT ON; INSERT INTO editor_Questions ( categoryID, question, sortID, modDate, modBy ) SELECT ParamValues.x1.value('categoryID[1]', 'int'), ParamValues.x1.value('question[1]', 'nvarchar(1000)'), ParamValues.x1.value('sortID[1]', 'int'), GETDATE(), ParamValues.x1.value('modBy[1]', 'varchar(50)') FROM @xml.nodes('/ranks/item') AS ParamValues(x1) END Example XML input: <ranks> <item><itemID>25</itemID><categoryID>1</categoryID><question>some text</question><sortID>1</sortID><modBy>abc</modBy></item> <item><itemID>12</itemID><categoryID>1</categoryID><question>some text 2</question><sortID>2</sortID><modBy>abc</modBy></item> <item><itemID>9</itemID><categoryID>1</categoryID><question>some text 3</question><sortID>3</sortID><modBy>abc</modBy></item> </ranks> Many thanks in advance for any help with this, Tim.
You can use merge statement as below MERGE editor_Questions AS Target USING ( SELECT ParamValues.x1.value('categoryID[1]', 'int') AS categoryID, ParamValues.x1.value('question[1]', 'nvarchar(1000)') AS question, ParamValues.x1.value('sortID[1]', 'int') AS sortID, GETDATE() AS [Date], ParamValues.x1.value('modBy[1]', 'varchar(50)') AS ModBy FROM @xml.nodes('/ranks/item') AS ParamValues(x1) ) AS SOURCE ON Target.categoryID =SOURCE.categoryID WHEN MATCHED THEN UPDATE SET Target.question = Source.question, Target.sortID = Source.sortID, Target.modDate=Source.[Date], Target.ModBy = Source.ModBy WHEN NOT MATCHED THEN INSERT ( categoryID, question, sortID, modDate, modBy ) VALUES (categoryID,question,sortID,[Date],ModBy);
0.888889
merge statement AS Target USING
Can I run 64-bit VM guests on a 32-bit host?
Can I run 64-bit VM guests on a 32-bit host? If I have a physical PC with 32 bit can I launch a VM that is 64 bit? What virtual machine software (Virtual PC or VirtualBox or other) would allow this? I read out there that VMware may support this but I am looking for something Open source or free. Host would preferably be a Windows host but could be Linux. Guest needs to be Windows. Thanks
Depends what you mean by a "32-bit host". If you mean hardware with a 32-bit processor that doesn't have 64-bit capabilities, then no, you can't do that through virtualisation - you would need an emulator rather than virtualisation and I'm not aware of one existing. If you mean on a machine with a 32-bit OS, then again, it's not possible to run a 64-bit guest on a 32-bit OS without emulation (something would need to translate the 64-bit instructions into 32-bit instructions) unless either (a) the 32-bit OS allows 64-bit applications (like Mac OS X) or (b) you can bypass the OS with a hypervisor. I'm not aware of a 32-bit type II virtualisation product for the Mac that allows a 64-bit OS to run as a 64-bit app. In fact, I'm not aware of a type II virtualisation product for the Mac at all. If you're using a hypervisor (type I virtualisation) like Hyper-V, VMWare ESX, Virtual Box, etc, then it should be possible, because the guest OS does not run on the host OS, but on the hypervisor. Indeed, the "host" OS actually runs on the hypervisor too.
0.888889
64-bit host on a 32-bit OS without emulation
'Trying to help someone, but the other party doesn't appreciate it'
What is a word that best describes trying to help someone, but the other party doesn't appreciate it? I'm looking for a word.
A thankless task. Not sure there's a single noun that covers it. The obvious adjective would be unappreciated.
0.777778
The obvious adjective would be unappreciated
Why do different pain killers have different effects on people?
I've noticed some pain killers working great for me, while others have no effect. Works for me Aspirin APC † Naproxen Doesn't work for me Paracetamol Diclofenac Tramadol I doubt there is much of a placebo effect at work, since most of these either did or did not work when I first took them, without having expectations either way. Whenever I have a head ache, I take an APC. I suspect it's actually the aspirin in there that does the job, since when I take just paracetamol, it doesn't do squat. As a kid I got children's aspirin, which worked. I once had a severe back ache. I was prescribed diclofenac (a heavier variant than the over the counter one), which didn't work. I was then prescribed tramadol — same results. I then tried naproxen, which worked rightaway. Why do some pain killers work while others don't? Is there an underlying mechanism, that explains why some of these work while others don't? Does that predict if pain killers that I haven't used yet will work? Please note that I'm not looking for medical advice on which pain killers to take; I'm just curious about how my body interacts with the various ones. †: the one consisting of aspirin, paracetamol, and caffeine, not the one containing phenaticin. Think Excedrin.
Short answer: different people have different amount of active receptors. In treatment, combination scores of Pharmacodynamics and Pharmacokinetics determine the final effect of the drug. Receptors determine many effects of the drug in many pathways. Different people also sense pains differently (Psychology). Review answer The purpose of treatment is to relieve pain and maintain function. Your question is biased. You cannot only concentrate on painkilling in maintaining health. These both are the reasons for the complains of the patient, not only the pain. For instance, in rheumatoid arthritis, response to therapy can be quantitated using many measures including American College of Rheumatology system values ACR20, ACR50 and ACR70, which denotes the percentage of patients showing an improvement of 20%, 50% or 70% in a global assessment of signs (maintaining function) and symptoms (pains). Each patient has own health, different from one another. Our body adapts to the environment and individual conditions of the body to maintain homeostasis. Receptors adapt for instance. They can be active or inactive - in short-run and long-run - again depending on the conditions at hand. Painkillers i.e. analgesics have different properties: anti-inflammatory effect - acute and chronic conditions (inflammation is the major mechanism under many pathologies) e.g. nonsteiroidal anti-inflammatory drugs (NSAIDs, please, see this answer about the particular mechanisms and how different people have different effects from NSAID painkillers) and glucocorticoids (most) symptoms relieving specific drugs e.g. disease-modifying antirheumatic drugs (DMARDs) anti-platelet effect - e.g. the older you get, the more platelets stick together. anti-pyretic effect ... which all can be toxic. Note that many drugs alone or/and as combination can work as painkillers i.e. pain relievers. Aspirin for instance has both anti-inflammatory and anti-platelet properties. However, it is rarely anymore used as anti-inflammatory. The anti-platelet property is dependent on the exact dosage of the administration. Aspirin's mechanism of action is to inhibit platelet COX which antiplatelet effect lasts 8-10 days (life of the platelet). In other tissues, synthesis of new COX replaces the inactivated enzyme so that ordinary doses have a duration of 6-12 hours. Please, review any Pharmacology -textbook for more info about aspirin. Each these drug has own Pharmacodynamics and Pharmacokinetics Pharmacodynamics answers to the question What drug does to the body? It stimulates some receptors, activates some pathways, ... Pharmacokinetics - What does body do to the drug? It metabolises it (enzymes, receptors). It distributes it. It excretes it (kidneys, feaces). In treatment, you consider what is the target organ. You need to think what is causing the dysfunction and the pain. You try to restore the function and relieve pain. The component of drug needs to reach the target tissue e.g. your pancreas' beta cells do no produce insulin so your blood glucose is high. Complications of this are polyuria and eventually exodus if untreated. Insulin is injected into the fatty tissue. We do not have long-term acting insulin administered orally - our metabolism start to break the drug so it does not have wanted treatment. If insulin administered to the muscle, the time of action is too times less, again because muscle is metabolising the insulin i.e. a chain of peptides (protein). No all symptoms and diseases have painkillers. For instance, prehemorrhoid and some types of itching related to posthemorrhoids. However, for both, there are some special salvas for proplylaxis but they are not complete. Now, you can start to read something in SuperBest's answer about host's physiological variables and addiction/tolerance which alters the mechanisms (receptors) of pathways in Pharmacodynamics and Pharmacokinetics. Sources Basic and Clinical Pharmacology, 11th edition, 2009, Bertram Katzung. My notes in Pharmacology classes during 2014.
1
Pharmacokinetics - What does body do to the drug?
Should I use the font encoding LY1 with the package libertine?
I normally use \usepackage[T1]{fontenc} without giving it any thought. The package libertine seems to provide more ligatures with the LY1 encoding. \documentclass{article} \usepackage{libertine} \usepackage[LY1,T1]{fontenc} \newcommand{\f}{fb ff fh fi fj fk fl ft} \begin{document} \fontencoding{T1}\selectfont\f \fontencoding{LY1}\selectfont\f \end{document} Are there any drawbacks to using LY1?
It depends on what glyph coverage you want. Here's the font table for the T1 encoding and here is the table for the LY1 encoding You can compare them and decide what suits you best. For English, French or German and some other languages the LY1 coverage seems complete. It's not for the Slavic languages using the Latin alphabet (except perhaps Slovenian).
1
LY1 encoding
Eclipse&Maven - The import org.hibernate.boot.cannot be resolved
I am building an Maven&Spring&Hibernate&JSF project on Eclipse.While compiling the program I have StandardServiceRegistryBuilder cannot be resolved to a type The import org.hibernate.boot.cannot be resolved errors. Main class is as follows: package com.test; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import com.hibernate.data.Person; public class Main { public static void main(String [] args){ Configuration configuration = new Configuration(); System.out.println("CFG and hbm files loaded successfully.");//just to test configuration.configure("hibernate.cfg.xml"); SessionFactory factory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().configure().build()); Session session = factory.openSession(); Transaction tx = session.getTransaction(); tx.begin(); System.out.println("Transaction began");//just to test Person newPerson = new Person(); newPerson.setFirstName("aa"); newPerson.setLastName("bbb"); newPerson.setGender("Male"); newPerson.setAge(2); session.save(newPerson); session.flush(); tx.commit(); session.close(); System.out.println("aaa");//just to test } } pom.xml file is as follows: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>Spring-Hibernate-JSF-MySQL-Example</groupId> <artifactId>Spring-Hibernate-JSF-MySQL-Example</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <properties> <!-- Generic properties --> <java.version>1.6</java.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <!-- Spring --> <spring-framework.version>4.1.6.RELEASE</spring-framework.version> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.test.Main</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <warSourceDirectory>WebContent</warSourceDirectory> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <configuration> <mainClass>com.test.Main</mainClass> </configuration> </plugin> </plugins> </build> <url>http://maven.apache.org</url> <repositories> <repository> <id>prime-repo</id> <name>PrimeFaces Maven Repository</name> <url>http://repository.primefaces.org</url> <layout>default</layout> </repository> </repositories> <dependencies> <dependency> <groupId>org.primefaces</groupId> <artifactId>primefaces</artifactId> <version>5.0</version> </dependency> <dependency> <groupId>org.primefaces.themes</groupId> <artifactId>blitzer</artifactId> <version>1.0.10</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.9</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.18.1-GA</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.1</version> </dependency> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <type>maven-plugin</type> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.12</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.2.10</version> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-impl</artifactId> <version>2.2.10</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>3.6.8.Final</version> </dependency> </dependencies> </project>
It could be because of the broken classpath; Package explorer > Plug-in tools > Update classpath. Or your Hibernate jar is not well extracted from the zip file. For controll, from Project Explorer try to expand your Hibernate jar. If you can't expand probably it's corrupted. Try to add jar again.
0.5
Hibernate jar is not well extracted from the zip file
What version of flash uses Actionscript 3?
I have been given a book on Actionscript 3 and I am looking to get started with learning it. What version of flash uses actionscript 3? Also does anyone know if adobe offer trial versions of their software for OSX? (10.6 snow leapard).
Flash Player 9. The first IDE to export to FP9 was CS3. But you don't need Flash to use ActionScript. You can use the open-source IDE FlashDevelop. It is hugely popular, and totally free. You will also need to get the free Adobe Flex SDK to compile to SWFs, but the install page of FlashDevelop's website gives details on everything you need, and current versions of FlashDevelop will even ask if you want it to get the SDK automatically for you.
0.888889
FlashDevelop IDE to export to FP9
Changing LED color for notifications
I am basically just experimenting with Android development, and a couple of days ago I came across this app called "Go SMS Pro", which, among other things, can set up notifications in different colors (blue, green, orange, pink and light blue). So, I have tried to do this myself in my own app, however I cannot change neiher the color nor the blinking internal of the LED. I currently use this code: public class MainActivity extends Activity { static final int NOTIFICATION_ID = 1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(buttonOnClick); } public OnClickListener buttonOnClick = new OnClickListener() { @Override public void onClick(View v) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); Notification notification = new Notification(R.drawable.icon, "Hello", System.currentTimeMillis()); notification.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL; notification.ledARGB = Color.BLUE; notification.ledOnMS = 1000; notification.ledOffMS = 300; Context context = getApplicationContext(); CharSequence contentTitle = "My notification"; CharSequence contentText = "Hello World!"; Intent notificationIntent = new Intent(MainActivity.this, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); mNotificationManager.notify(NOTIFICATION_ID, notification); } }; } But as I said, it doesn't work the way I want it to; instead it just blinks in regular green with the default delay, and not the one I have set in my code. Can anyone see what is wrong with my code, or know if I have to do something else to achieve this?
You can use this code: private void RedFlashLight() { NotificationManager nm = ( NotificationManager ) getSystemService( NOTIFICATION_SERVICE ); Notification notif = new Notification(); notif.ledARGB = 0xFFff0000; notif.flags = Notification.FLAG_SHOW_LIGHTS; notif.ledOnMS = 100; notif.ledOffMS = 100; nm.notify(LED_NOTIFICATION_ID, notif); } Instead of using ARGB value as the example show, you can use int property inside android.graphics.Color class to get the color as well
1
Int property inside android.graphics.Color class
What is the difference between "section" and "part"?
What is the difference between "section" and "part"? The Longman Dictionary of Contemporary English says for "section": one of the parts that something such as an object or place is divided into and says for "part": a piece or feature of something such as an object, area, event, or period of time I know that "section" is smaller than "part" in size, but I'm totally confused about their usage in sentences. For example, is "the front section of the car was damaged" correct grammatically? Or is "in sections of Canada, French is the first language" correct?
Just to add an example in which you use them differently: In latex, you can divide a document (or a presentation) in several parts, and each part has its own chapters, sections and subsections. So, in this particular case, part is more general. See more about sectioning in latex
1
In latex, you can divide a document (or a presentation) in several parts
How svn checkout and checkin maven multimodule project
im having a problem configuring my eclipse + maven + m2e + svn setup. Lets assume i have project checked in svn trunk with this structure: - Project-parent - pom.xml -- ModuleA --- pom.xml (module A) -- ModuleB --- pom.xml (module B) In my eclipse installation i have: eclipse 3.7.2 64bit Java EE subversive and svn connector for svn 1.6 m2e 1.1 from marketplace m2e-subversive 0.13 (installed from alternative url) My problem begins when i want to add new module to project. So i checkout project and modules by "Import -> Check out Maven projects from SCM". I create it with standard m2e 'Create new maven module' and after completing attributes my workspace looks like this: - Project-parent (in trunk) - pom.xml (in trunk) -- ModuleA (in trunk) --- pom.xml (in trunk) -- ModuleB (in trunk) --- pom.xml (in trunk) -- ModuleC --- pom.xml Project builds with "mvn clean install". So I want to check it ModuleC in into svn but there is no option with functionality "Share module into svn". Finally my questions: How do you check in your new modules into existing repository? Is it through eclipse 'Share project' or external tool like Tortoise? If its through Eclipse, do you automatically have 'connection' between module project and svn (by connection i mean annotation on project about svn url and current revision) When you have 'connection' in your case, can you chage something in commited ModuleC and see 'dirty' svn marker on Project-parent? How to achieve such connection manually? The only way i could do it is through deleting all projects and again performing "Check out Maven projects from SCM" and picking all projects again. When you create submodule sceleton in different location than workspace and then check it into svn, how to import it back to workspace and to m2e from svn?
You must also mount the main project in eclipse, the parent of the module. Then, use this project to check in the new module as you are doing for any change set. This project is only used for SVN synchronization purpose. For your developments, use the module projects. For your last question, this is a maven constraint to have its sub module below the parent project. You won't be able (at least not easily) to create a module somewhere, check it in below the parent and then checkout the whole project with the new module. Try to keep it simple. Use the parent project when you want to synchronize new modules. HIH M.
0.888889
Use the parent project to check in the new module
What is best practice to handle whitespaces when letting the user edit the configuration, the name=value pairs?
For instance, you let the user define the notorious path variable. How do you interpret apppath = C:\Program Files\App? This looks like a programming language adopted practice to ignore the white spaces and you leave them around the equality mark for readability, but it might be a valid variable value with white space in the application (consider, it is a suffix). Even keys can contain whitespaces, can't they? What is the general best practice for my application? If I have: key-example = value-example should I interpret the key being "key-example" or "key-example " and the value as being "value-example" or " value-example"?
It's up to you to define the rules for your app. For instance, you may define that: Whitespace before or after the equality sign is ignored, Whitespace inside the key is forbidden, Whitespace inside the value can be used only if the value is enclosed in quotes, so: say-hello = Hello, World! is forbidden, while: say-hello = "Hello, World!" is allowed, which also makes it possible to have whitespace prefixes: say-hello = " Indentation is sweet." Defining a format may be a complex task. For instance: How do you escape quotes? How do you escape the escape character you use to escape quotes? How do you handle empty values? What is the maximum length of a key? What about a value? How do you handle multiline values? What about whitespace Unicode characters other than a space (such as a non-breaking space character)? What about Unicode characters which are usually not displayed on the screen? For instance, how do you deal with Unicode categories Cf or Zl? What are the characters allowed in the key? For example, is: ' a valid key? Should the following line work?¹ say-hello ꘌ "Hello, World!" Hint: the equality sign is not an equality sign, but the character 0xa60c (Vai syllable lengthener). Although few people would use this symbol instead of the equality, the more frequent case is a copy-paste from Microsoft Word (watch closely the quotation marks): say-hello = “Hello, World!” etc. This is why, unless you are completely sure that you can define a format and describe it precisely and verbosely, use a format which already exists. JSON or XML are commonly used formats you can use in nearly every programming language. You may even abstract the underlying format by using a database. Redis, for instance, is a popular solution for key-value store. ¹ Chrome users using Windows would probably see a question mark in a square. With other browsers or with Chrome on Linux, the character appears like an equality sign and can easily be misleading: the only visual difference is that there is a tiny difference in the space between the horizontal bars.
0.888889
How do you escape quotes? What is the maximum length of a key?
Transform a Binary Search Tree into a Greater Sum Tree
Given a Binary Search Tree (where all nodes on the left child branch are less than the node), and all nodes to the right are greater/equal to the node), transform it into a Greater Sum Tree where each node contains sum of it together with all nodes greater than that node. Example diagram is here: Looking for code review, optimizations and best practices. public class GreaterSumTree implements Iterable { private TreeNode root; public GreaterSumTree(List<Integer> list) { create(list); } private void create (List<Integer> items) { root = new TreeNode(items.get(0)); final Queue<TreeNode> queue = new LinkedList<TreeNode>(); queue.add(root); final int half = items.size() / 2; for (int i = 0; i < half; i++) { if (items.get(i) != null) { final TreeNode current = queue.poll(); final int left = 2 * i + 1; final int right = 2 * i + 2; if (items.get(left) != null) { current.left = new TreeNode(items.get(left)); queue.add(current.left); } if (right < items.size() && items.get(right) != null) { current.right = new TreeNode(items.get(right)); queue.add(current.right); } } } } public static class TreeNode { private TreeNode left; private int item; private TreeNode right; TreeNode(int item) { this.item = item; } } public static class IntObject { private int sum; } /** * Computes the greater sum, provided the tree is BST. * If tree is not BST, then results are unpredictable. */ public void greaterSumTree() { if (root == null) { throw new IllegalArgumentException("root is null"); } computeSum (root, new IntObject()); } private void computeSum(TreeNode node, IntObject intObj) { if (node != null) { computeSum(node.right, intObj); int temp = node.item; node.item = intObj.sum; intObj.sum = intObj.sum + temp; computeSum(node.left, intObj); } } /** * Returns the preorder representation for the given tree. * * @return the iterator for preorder traversal */ @Override public Iterator iterator () { return new PreOrderItr(); } private class PreOrderItr implements Iterator { private final Stack<TreeNode> stack; public PreOrderItr() { stack = new Stack<TreeNode>(); stack.add(root); } @Override public boolean hasNext() { return !stack.isEmpty(); } @Override public Integer next() { if (!hasNext()) throw new NoSuchElementException("No more nodes remain to iterate"); final TreeNode node = stack.pop(); if (node.right != null) stack.push(node.right); if (node.left != null) stack.push(node.left); return node.item; } @Override public void remove() { throw new UnsupportedOperationException("Invalid operation for pre-order iterator."); } } } Here is a test case: public class GreaterSumTreeTest { @Test public void test() { Integer[] a = {1, 2, 7, 11, 15, 29, 35}; GreaterSumTree greaterSumTree = new GreaterSumTree(Arrays.asList(a)); greaterSumTree.greaterSumTree(); int[] expected = {71, 87, 89, 72, 35, 42, 0}; int[] actual = new int[a.length]; int counter = 0; Iterator itr = greaterSumTree.iterator(); while (itr.hasNext()) { actual[counter++] = (Integer) itr.next(); } assertTrue(Arrays.equals(expected, actual)); } }
A minor bug: You get an IndexOutOfBoundsException for an empty list in GreaterSumTree.create(List<Integer> items). You don't have a comment stating you need to input a list containing at least something. Consider returning IllegalArgumentException and adding a comment. /** * Computes the greater sum, provided the tree is BST. * If tree is not BST, then results are unpredictable. */ public void greaterSumTree() { if (root == null) { throw new IllegalArgumentException("root is null"); } computeSum (root, new IntObject()); } You should use IllegalStateException here. IllegalArgumentException is for when the arguments are bad. What's bad here is the internal state of your object. Alternatively, remove the check here and put it in the create function. That way you don't get bad internal states.
0.666667
IndexOutOfBoundsException for an empty list
Why won't osm2po setup table correctly?
OK, I have no idea what's going on. I'm using a Mac and successfully installed pgRouting. I used osm2po on some data, which created a sql file. I imported the sql file into a pgRouting database and all is well, except the fact I only took into account routes for cars. After Carsten helped me with configuring osm2po.config, I ran osm2po again that ran as expected. From the terminal, I run the command: psql -U [username] -d [dbname] -q -f "/Users/John/Desktop/osm2po-4.6.9/wmCar/wmCar/wmCar_2po_4pgr.sql I was expecting it to be successful like last time, as to my knowledge the conditions are the same. However I get the error: psql:/Users/John/Desktop/osm2po-4.6.9/wmCar/wmCar_2po_4pgr.sql:101739: ERROR: INSERT has more expressions than target columns LINE 2: ..., -2.0046492, 52.5307149, -2.0026647, 52.5310823, >'010200002... With pgAdmin I look at the empty table that was created, and compared to the first sql file I imported, the new table was missing a column. That being geom_way. I find this odd as I haven't changed anything. I threw osm2po folder to the trash, and unzipped a new osm2po folder. To test whether it was going to work, I ran osm2po on the original pbf file with the original osm2po.config settings and tried to import that into the same pgRouting database. The error appeared again. For some reason, the last column, geom_way, isn't being added to the table. Would anyone know why it's started doing this?
Just a guess. Did you use an uppercase letter in osm2po prefix name? It looks like yes - try to rename prefix/table name from "wmCar_2po_4pgr" to "wmcar_2po_4pgr". It helped me in similar situation - error while loading osm2po routing sql-script into PostgreSQL
0.888889
How to rename prefix/table name from "wmCar_2po_4pgr"
How many connections reads queue
Is there a way to get to know how many external tasks (console applications) is reading queue? I am using Service Broker external activator. What i want is something similar to information i get from sys.dm_broker_activated_tasks, just for external queue readers.
Sort of. You can see though sys.dm_exec_requests executing a RECEIVE statement (including a WAITFOR RECEIVE). By simply peeking into the the currently executing text sys.dm_exec_sql_text(sql_handle) between the statement_start_offset and statement_end_offset you can see if the statement is RECEIVE or not (with some parsing...). Figuring out if an active transaction has issued a RECEIVE and is now processing returned messages is more complicated. Is somehow of an unusual request, why do you need to know?
0.777778
Is executing a RECEIVE?
To access button from another class which is in another page
My goal is to access the button and make the visibility to false from another class in vb.net Dim obj = New MyClass() obj.btnName.Visible = False But it is throwing error as "Object reference not set to an Instance"
hmm how about? Dim obj as New MyClass() obj.btnName.Visible = False
1
Dim obj as New MyClass()
Is the tree of the field a man?
Dvarim 20:19 reads: כִּי תָצוּר אֶל עִיר יָמִים רַבִּים לְהִלָּחֵם עָלֶיהָ לְתָפְשָׂהּ לֹא תַשְׁחִית אֶת עֵצָהּ לִנְדֹּחַ עָלָיו גַּרְזֶן כִּי מִמֶּנּוּ תֹאכֵל וְאֹתוֹ לֹא תִכְרֹת כִּי הָאָדָם עֵץ הַשָּׂדֶה לָבֹא מִפָּנֶיךָ בַּמָּצוֹר When you besiege a city for many days to wage war against it to capture it, you shall not destroy its trees by wielding an ax against them, for you may eat from them, but you shall not cut them down. Is the tree of the field a man, to go into the siege before you? Rashi explains that the word 'Ki' denotes a (rhetorical) question not a statement: Is the tree of the field a man, to go into the siege before you]?: The word כִּי here means“perhaps:” Is the tree of the field perhaps a man who is to go into the siege by you, that it should be punished by the suffering of hunger and thirst like the people of the city? Why should you destroy it? So the Torah is saying: Is a tree like a man? No! If so, why do we find that many commentaries try to find connections between man and trees?
Rashi's understanding is only one, as Michoel said, of the "70 faces of Torah". The syntax of this pasuq is inherently ambiguous, and it is not clear whether the correct reading of the verse is as a rhetorical question or a statement. Ibn Ezra explains that the Torah is in fact equating people and trees: ולפי דעתי: שאין לנו צורך לכל זה וזה פירושו כי ממנו תאכל ואותו לא תכרות, כי האדם עץ השדה. והטעם: כי חיי בן אדם הוא עץ השדה In my opinion, we don't need these or those [erroneous explanations of other commentators]. Rather, the [correct] explanation is, "For you should eat from it, and not destroy it, because [as] a person is the tree of the field." Meaning, the lives of people are [as] trees of the field. Regardless of which explanation holds more ground grammatically, the point remains: throughout TaNaKh, trees are powerful metaphors for righteous people, happiness, stability, and the Torah itself. As Shalom wrote, poetic/midrashic license allows us to read this (admittedly ambiguously phrased) pasuq in a way to derive meaning. See, for examples, some of the sources that Jeff Spitzer brings in his article here, including the Tzena uRena and the MaHaRaL of Prague.
0.555556
The syntax of this pasuq is inherently ambiguous .
How much is too much damage?
How much damage is too much? Based on photos I've seen as reference on this forum I'm afraid the damage is more extreme than superficial. Supposedly it happened from one fall. The bottom side has a hole that's been repaired and the face/soundboard has two cracks below the bridge on either side. It's a TW15H Tanglewood Ill Here's the story: I'm trying to buy my husband a guitar for Christmas. He played in college but has only picked up a guitar a handful of times since we've met. He's 34 now and we have a soon-to-be 2yo son who is captivated by the guitar (and another son due in 2mos). My husband has been hinting on wanting to start playing again so I thought it would be the perfect Christmas gift. I don't have much to spend and really don't want an all laminate plastic piece of junk. I don't know much about guitars but I recognize when I hear sound quality I love - rich, full bodied, well balanced sound that resonates with a person. Not that tinny twang I hear from some guitars without that depth of sound. I was at a local music shop this morning that pointed me to a damaged TW15H Tanglewood Ill He told me it's solid wood construction with ebony and bone. Sounds beautiful. I believe it was a dreadnought. (Sorry if I sound naive...picture a hugely pregnant lady shopping in a guitar shop with a toddler. I assure you we look as naive as I might sound). The problem is that the TW15H Tanglewood Ill is damaged. It's been dropped. The face is cracked in 2 places and there was a hole at the bottom. If I can post photos here I will. The owner has repaired the damage. Says it was his own guitar and he loved it but a friend dropped it soon after it's purchase and despite being repaired he gets upset whenever he sees it and no longer wants it around to remind him. The damage is quite visible but it sounds lovely. My question is how much damage is too much? Will it hold a tuning etc? He told me it's a 3000k guitar and is asking $375 for it. I only saved $200 to buy a guitar which I realize is laughable for a decent one. I'm thinking of putting the rest on a credit card if I can find out it's worth it. Can anyone help advise me here? The shop says he'll back the guitar for a year. The other option he suggested was a Sammick - Greg Bennett (which I've never heard of) for $250 I'm trying to decide if I should buy the damaged TW15H Tanglewood Ill or look for a new beginner guitar. Please help
I question the price that the owner stated, that is at least a red flag. The price at TangleWood is listed in the link at about 800 pounds (roughly $1250). It could still be a nice guitar, but if you find one lie then there is a greater chance of more. http://www.tanglewoodguitars.co.uk/products/acoustic/sundance/heritage/TW15H.html
1
TangleWood is listed in the link at about 800 pounds (roughly $1250)
Does changing the gap between plates change the capacitor voltage?
Consider an ideal capacitor which has a length of \$\ell_1\$ between its plates. The capacitor terminals are open; they are not connected to any finite valued impedance. Its capacity is \$C_1\$ and it has an initial voltage of \$V_1\$. What happens to the capacitor voltage if we make the gap between the plates \$\ell_2=2\ell_1\$ without changing the amount of charge on the plates? My thoughts on this: Increasing the gap will decrease the capacitance. $$ C_2 = \dfrac{C_1}{2} $$ Since the amount of charge is unchanged, the new capacitor voltage will be $$ V_2 = \dfrac{Q}{C_2} = \dfrac{Q}{\dfrac{C_1}{2}} = 2\dfrac{Q}{C_1} = 2V_1. $$ Is this true? Can we change the capacitor voltage just by moving its plates? For example, suppose that I'm wearing plastic shoes and I have some amount of charge on my body. This will naturally cause a static voltage, since my body and the ground act as capacitor plates. Now, if I climb a perfect insulator building (e.g.; a dry tree), will the static voltage on my body increase?
Yes, the voltage increases. It seems most of us learned of this in school. My Physics professor had a setup with movable plates, and a very sensitive (actually, very high impedance) voltmeter. As the plates were pulled apart, the voltage went up. This comes from the elemental formula Q=CV. Pulling the plates apart lowers the capacitance. The charge didn't go anywhere, so the voltage must rise. This may seem counterintuitive, but the charge on the plates want to attract each other, and you are doing work by pulling them apart. You can reproduce the experiment described above if you have a voltmeter with an FET input (or an oscilloscope, if you're that fortunate). Ground the negative lead and hold the other lead in your hand. If your shoes are not conductive, and you don't have any ESD straps connected, you should be able to deflect the meter simply by raising and lowering your foot. By the way, rubbing the carpet creates the charge and picking up your feet and moving away is what raises those static charges to such high voltage levels. On a practical note, this is how an electret condenser microphone works. As the diaphragm vibrates, the capacitance between it and a fixed plate changes, and the voltage changes with it.
0.666667
Using an electret condenser microphone to deflect static charges
c stack smashing detected on file managing
I'm having problem with my program. The variables are written in italian, I'm sorry! I have to handle the penalties phase of a football game. If in the first five penalties the teams end tie, they will go for penalties to the end. if (retiPrimaSquadra != retiSecondaSquadra){ buffer = fopen("buffer.txt", "w"); fprintf(buffer, "%d-%d", retiPrimaSquadra, retiSecondaSquadra); fclose(buffer); return 0; } else { printf("Risultato secondo tempo supplementare: %d - %d\n\n", retiPrimaSquadra, retiSecondaSquadra); printf("RIGORI\n"); int rigoreA=0, rigoreB=0; char vRigoreA[5]; char vRigoreB[5]; int rigore=0; int i=0; vRigoreA[i]='x'; //printf("%c", vRigoreA[i]); for(i=0; i<5; i++){ //tiro prima squadra rigore = (rand() % 101); if(rigore <= 75){ rigoreA++; retiPrimaSquadra++; vRigoreA[i]='x'; } else{ vRigoreA[i]='o'; } //tiro seconda squadra rigore = (rand() % 101); if(rigore <= 75){ rigoreB++; retiSecondaSquadra++; vRigoreB[i]='x'; } else{ vRigoreB[i]='o'; } //stampa xo printf("%c %c\n", vRigoreA[i], vRigoreB[i]); } //risultato 5 rigori printf("%d - %d\n", rigoreA, rigoreB); char enter = '\0'; while(enter != '\n'){ enter = getchar(); } //OLTRANZA while(rigoreA==rigoreB){ //tiro prima squadra rigore = (rand() % 101); if(rigore <= 75){ rigoreA++; retiPrimaSquadra++; vRigoreA[i]='x'; } else { vRigoreA[i]='o'; } //tiro seconda squadra rigore = (rand() % 101); if(rigore <= 75){ rigoreB++; retiSecondaSquadra++; vRigoreB[i]='x'; } else{ vRigoreB[i]='o'; } //stampa xo printf("%c %c\n", vRigoreA[i], vRigoreB[i]); } printf("check\n"); } buffer = fopen("buffer.txt", "w"); fprintf(buffer, "%d-%d", retiPrimaSquadra, retiSecondaSquadra); fclose(buffer); } The program runs with no errors if it doesn't enter in the last "while". Otherwise, after finishing the while cycle, when it goes to right the results in the buffer.txt file, it gives me a stack smashing detected problem. I really don't know how to handle it, cause it seems so stupid that if it doesn't enter the while it goes fine!
You are using i to access your vRigoreA array in the while (vRigoreA[i]='x';). However, i is set to 5 after your for-loop, so you are accessing stack memory not belonging to the array. At the end of the function, the debugger detects that out-of-bounds writes happened.
0.888889
vRigoreA[i]='x'
What role does this past-participle take?
Someone standing outside the Great Hall might well have thought some sort of explosion had taken place, so loud was the noise that erupted from the Gryffindor table. Harry, Ron, and Hermione stood up to yell and cheer as Neville, white with shock, disappeared under a pile of people hugging him. He had never won so much as a point for Gryffindor before. Harry, still cheering, nudged Ron in the ribs and pointed at Malfoy,who couldn’t have looked more stunned and horrified if he’d just had the Body-Bind Curse put on him. (Harry Potter and the Sorcerer's Stone) I don’t find the same syntactic example as the highlighted case in OALD. Is it a certain type of have-structure that I don’t find yet. Or does the phrase, put on him, modify the previous noun phrase, the Body-Bind Curse?
This is an instance of HAVE employed in a resultative sense—it’s the sense at OALD 22: 22 (used with a past participle) have something done to suffer the effects of what somebody else does to you She had her bag stolen. The use is actually broader than OALD suggests; it as also employed to express positive results: Now that we have that settled we can move on to the next item. This use goes all the way back to Old English, and was in fact the ancestor of the Perfect constructions which emerged in Middle English. In Old English the underlying syntax at that time was HAVE + [Direct Object] + [PaPpl], with the PaPpl modifying the Direct Object. (We know this because nouns and adjectives had case endings in OE, and in this construction the PaPpl 'agrees' with the Direct Object). In Modern English, however, it is probably best understood as a reduced subordinate clause: He had [ [that] a curse [was] put on him. ] I advance this parsing because in ModE there is also a use with a bare infinitive instead of a past participle; this is employed when the verb in question may be used both transitively and intransitively and the participle would be ambiguous: She had her house burn down. ... which may be similarly parsed as She had [that] her house burned down. Using active burn instead of passive burned here prevents this being parsed as transitive burned down used with causative HAVE, as in OALD's 23: 23 (used with a past participle) have something done to cause something to be done for you by somebody else You've had your hair cut! We're having our car repaired. This use also supports use with an explicit subject, OALD's #24: 24 to tell or arrange for somebody to do something for you • have somebody do something He had the bouncers throw them out of the club.
0.888889
Use of a resultative sense at OALD 22: 22 (used with a past participle)
When enumerating motivations, is it correct to write firstly, secondly, ..., or first, second, ...?
Suppose I am enumerating reasons not to fly. Is it then correct to write/say: Firstly, I prefer the train because I can see the landscape. Secondly, I have control over my luggage, and thirdly, it is better for the environment. Or is it rather: First, I prefer the train because I can see the landscape. Second, I have control over my luggage, and third, it is better for the environment. I thought the first should be correct, but I find the second one in written texts. Which one is correct?
Both styles are used. In most genres, no-one will object to either. However, traditionally, first, secondly, thirdly etc. is used. Only pedants will insist on this usage, but it is something to be aware of, as there are many pedants. See Fowler's Modern English Usage (3rd edition). The Oxford English Dictionary on firstly: Used only in enumerating heads, topics, etc. in discourse; and many writers prefer first, even though closely followed by secondly, thirdly, etc. Burchfield in Fowler's Modern English Usage on first:
1
Both styles are used in most genres .
how to retrieve data from database correctly in java
I wrote this code in order to display the name of employee who has the maximum salary but when the output wasn't correct it appeared null not "mmm kkk" !! although I filled the table and this is the contents : HERE this is my code, can any one help me ?? :( public static void displayMaxSalary() throws ClassNotFoundException, SQLException { int size=0; int count=0; String maxSalary=null; Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/task4DB?" + "user=root&password=123"); PreparedStatement st = con.prepareStatement("select * from task4Table "); ResultSet r1=st.executeQuery(); while (r1.next()) { size++; } int salaries[]=new int[size]; String Names[]=new String[size]; while (r1.next()) { salaries[count]= r1.getInt("salary"); Names[count]= r1.getString("fName")+""+r1.getString("lName"); count++; } for(int i=1;i< salaries.length;i++) { if(salaries[i]>salaries[i-1]) { maxSalary= Names[i]; } } System.out.println("The name of employee who has the higher salary is :"); System.out.println( maxSalary); } //end-displayMaxSalary.
Try this SQL statement: select fName, max(salary) from task4table A problem with your code: In this loop you iterate to the end of the result set: while (r1.next()) { size++; } And then, when you want to iterate again while (r1.next()) { salaries[count]= r1.getInt("salary"); Names[count]= r1.getString("fName")+""+r1.getString("lName"); count++; } r1.next() returns false so this iteration does not happen. You either do it in one loop, or you execute query again. But, as I said, to it with proper sql statement using max.
0.777778
SQL statement fName, max(salary) from task4table
check if a string has four consecutive letters in ascending or descending order
Good day stack overflow. I'm a noob in using regex and here is my problem - I need to check a password if it contains 4 consecutive characters. so far what I have just covered is regarding the digits. Here is my regex: ascending digits - ^.?(?:0123|1234|2345|3456|4567|5678|6789).$ descending digits - ^.?(?:9876|8765|7654|6543|5432|4321|3210).$ This works only for the digits. I know this is already an overkill in regex so I dont want to do it with the letters. It will be waaay too overkill if I do that. abcdblah //true because of abcd helobcde //true because of bcde dcbablah //true beacause of dcba heloedcb //true because of edcb Any help would be highly appreciated. Thanks stackoverflow.
This is my solution. It uses only a single loop. Keep in mind that you'll need more logic if you want to constrain it to pure ASCII. static boolean isWeak(String pass) { Character prev = null; Boolean asc = null; int streak = 0; for (char c : pass.toCharArray()) { if (prev != null) { switch (c - prev) { case -1: if (Boolean.FALSE.equals(asc)) streak++; else { asc = false; streak = 2; } break; case 1: if (Boolean.TRUE.equals(asc)) streak++; else { asc = true; streak = 2; } break; default: asc = null; streak = 0; } if (streak == 4) return true; } prev = c; } return false; }
0.888889
boolean isWeak(String pass) Character prev = null
Would this work? Using a computer SMPS as a DC-DC converter
I have this crazy idea of using a computer SMPS with active PFC boost to take high voltage DC battery banks (144V+) and drop it down to 3.3V, 5V and 12V. Here's my thinking: the power supply internally rectifies the AC to DC, and the PFC boost should then boost the 144V to an acceptable 350V-400V for the power supply. The 144V input is okay for it because it falls in the 100VAC range, and most are rated down to 85VAC if not lower. I'm not looking for a guaranteed solution - it's a one-off problem I'm trying to solve, but I think it could be a cheap and viable solution.
Is cost a factor? If not, then how about using the batteries in series-parallel to get 24VDC and using a PSU that is made for 24VDC? I had this setup some time ago when I had 5 machines running in a 19" rack. Worked quite well as a very efficient UPS. (Although the 24VDC PSUs are more expensive than standard ones) I just ran a very simple step-down/rectify/regulate circuit to trickle-charge the batteries.
0.777778
Is cost a factor?
PHP - how to output a MySQL average store rating in a loop
I have a table with ratings for every store in a directory. I want to display the average rating from each store on a business directory list page. I have the directory business listing page finished without the average rating. I believe I have figured out how to create an average rating, but I don't know how to get the rating to output in the loop for each store. Here is how I calculate the rating: $result = mysql_query("SELECT AVG(rating) FROM reviews GROUP BY store_id WHERE store_id = '$storeid'"); $rating_for_page = mysql_fetch_row($result); $rating = $rating_for_page[0];
You should iterate through the results if I am understanding the issue correctly. Also, in your MySQL command you need to set an AS for the AVG(rating). And I have set mysql_fetch_assoc (instead of mysql_fetch_row) for the results to be returned in an associative array: foreach ($storeids as $storeid) { $result = mysql_query("SELECT AVG(rating) AS rating FROM reviews GROUP BY store_id WHERE store_id = '$storeid'"); while ($row = mysql_fetch_assoc($result)) { echo $row['rating']; } } EDIT Looking at your query and seeing the $storeid being set, unclear where that value is coming from but I wrapped the solution I have provided in a foreach loop which assumes you have a list—and hopefully an array—that contains all of the $storeids in to loop through.
1
Is iterate through the results in a foreach loop?
Why does my 24VDC fan draw much less current than labeled?
I have three Delta PFB0824UHE, which were provided to me by a customer for a project. They are labeled 0.93A. When actually hooked up to 24V, the fan draws .45A, regardless of head pressure. This current varies linearly with input voltage, going as low as .2A and as high as .5A across the fan's spec'd input voltage range. I have three units, which all behave the same. The datasheets I find for this part indicate a current draw of 0.77A. I’m confused as to how much current I should actually expect this fan to draw. Do fan manufacturers typically allow that much overhead in their specs? Are they subject to manufacturing variations to that degree? Do I perhaps have some special variant of the fan, and not know it? Are they perhaps mislabeled? Should I expect the fan's current draw to increase over time, or with temperature or some other variable?
The electrical motors have (as a rule) high efficiency. That is why the current consumption highly depends on the motor mechanical load. For example, if you try to stop the rotor, the current should increase at least twice. When the fan works it is differently loaded, depending on the airflow. On the next picture, you can see, that the efficiency is maximal when the airflow is limited by the pressure difference - i.e. when the fan have to make to work in order to move the air: So, if you test the fan in idle mode it will consume less power.
1
The electrical motors have (as a rule) high efficiency
Problem with Google Now in Tab 2
I have a Galaxy Tab 2 7.0 which I have updated to the official jellybean provided by Samsung, it is supposed to have Google Now but I cant see the cards on opening the the app. Can anyone help me out by pointing out the way in which I can see the cards.
It's entirely possible that there simply are no cards to display. If you don't have a wireless connection on, for instance, it can't fetch data to populate cards for viewing. Available cards also depend on several other factors such as whether the GPS is on, whether you allow Google to track you/your data, and what country you live in (most Now cards are US-centric; living in Canada, the only ones that ever come up for me are weather and "time to travel" Navigation cards)
0.777778
There are no cards to display if you don't have a wireless connection
Performance Counters for SQL Server Related to iSCSI Disk Access
I am planning to my SQL server databases (plus TLogs and TempDB) to a new LUN on our iSCSI SAN. The current LUN's used by these of these files are on their own two disk RAID 1 disk group and I'm going to a larger but shared 14 disk RAID 10 disk group. I want to measure the performance of the current configuration and the new configuration as I move each database over and ensure that I am not starting to hit any disk performance issues (or see if I am actually increasing the performance). There are a bunch of posts on the internet on SQL performance counters such as this one, but I am really interested in just the few that are related to network/disk usage and any latency or limits that associated with disk reads/writes. What are some of the important SQL or Windows performance counters that I should look at to create a current baseline/comparison for iSCSI disk access for SQL?
You need to be looking at seconds per read and seconds per write. Those numbers will tell you how long the storage is taking to respond.
1
How long storage is taking to respond?
Generating RSA-SHA1 signatures with JavaScript
I'd like to generate RSA-SHA1 signatures with the RSA-Sign JavaScript Library. Specifically, I'd like to use this for signing OAuth requests. However, the signature generated by the JavaScript library looks different to the one I can generate e.g. with $ echo -n "x" | openssl dgst -sha1 -sign priv.key -binary | openssl base64 | xargs echo -n eV0ZrD7ZrTsuzHHYSwLfUJhXuM96D6ZyIzD5FFphzHbKRaO4TMeTR7bJjkuPib+l EccM7t6YNDvRgOHyXJDVZZQTg5G4D4jnGVmOgeuti1etCCpLsb1Rl3sfJF/rIlgA AmejvBbrEG+n8L+GeD6Vd3cneW7k2Rksnh+/BWnnR3c= In contrast: This is what the library generates (base64 encoded): Nzk1ZDE5YWMzZWQ5YWQzYjJlY2M3MWQ4NGIwMmRmNTA5ODU3YjhjZjdhMGZhNjcy MjMzMGY5MTQ1YTYxY2M3Ng0KY2E0NWEzYjg0Y2M3OTM0N2I2Yzk4ZTRiOGY4OWJm YTUxMWM3MGNlZWRlOTgzNDNiZDE4MGUxZjI1YzkwZDU2NQ0KOTQxMzgzOTFiODBm ODhlNzE5NTk4ZTgxZWJhZDhiNTdhZDA4MmE0YmIxYmQ1MTk3N2IxZjI0NWZlYjIy NTgwMA0KMDI2N2EzYmMxNmViMTA2ZmE3ZjBiZjg2NzgzZTk1Nzc3NzI3Nzk2ZWU0 ZDkxOTJjOWUxZmJmMDU2OWU3NDc3Nw== (assuming the same input & key, of course) Is it possible that this is because of the SHA1 implementation being used? In that case, I could try to use another one. I'm no expert of cryptography, but the OAuth RFC 5849 is saying that RSASSA-PKCS1-V1_5-SIGN needs to be used, which seems to be the case for the library. Thank you very much.
I tried both the openssl command and the JS library you mentioned above, and the results are consistent. The signatures that I get from both ways are the same. One thing I noticed from your post is that, the base64 encoded result generated from the library is way too long and looks wrong. Is it possible that you are not base64-encoding the binary signature? Could you try this code for getting the base64 encoded string of the signature? function doSign() { var rsa = new RSAKey(); rsa.readPrivateKeyFromPEMString(document.form1.prvkey1.value); //replace with your private key var hSig = rsa.signString("x", "sha1"); var base64_encoded_signature = hex2b64(hSig); } If you compare the value of "base64_encoded_signature" with what you get from the openssl command, they should be the same.
0.666667
Is it possible that you are not base64-encoding the binary signature?
What are the uses for a roasting pan? Do I really need a roasting pan?
We registered for a roasting pan and it has been sitting around taking up a lot of space. Do I really need this or is this a "one-tasker" as Alton Brown would say? I understand that the roasting rack allows the juices to drip down. I've had lots of success roasting chickens just in a baking pan with 2" high sides.
A roasting pan is one of the definitive methods to make oven-roasted bbq, such as kansas city ribs. Most recipes involve a period of foil covered roasting on a rack (so the meat does not sit in its own oil) and covered with foil. It is almost a form of steaming, but different. I do not know any other method to achieve truly splendid results.
1
A roasting pan is one of the definitive methods to make oven-roasted bbq
Multiple-prime RSA; how many primes can I use, for a 2048-bit modulus?
In standard RSA, the modulus $n=p_1 p_2$ is a product of two primes $p_1,p_2$ of the same size. Suppose we construct the modulus as a product of multiple primes $p_1,\dots,p_k$, i.e., $n=p_1 p_2 \cdots p_k$, where all the primes are of about the same size. I'm wondering how much this reduces the security of RSA, for typical modulus sizes. Let me be more concrete. I want security comparable to that obtained with standard RSA with a 2048-bit modulus. Can I use $k=3$ (three primes) without significant loss of security? $k=4$? What's the largest number of primes $k$ that I can use, without significant loss of security? Assume that each prime is $2048/k$ bits long, so all the prime factors are of equal length. Related: see also Who first published the interest of more than two prime factors in RSA?, which asks about the inventor of this technique. I'm asking something slightly different; in this question, I'm not asking about its inventor; I'm asking about concrete security levels.
For a 2048-bit modulus, based on current knowledge of attacks: you can use up to $k=3$ primes without any loss in security. Using $k=4$ primes apparently causes some loss in security (it's not clear to me exactly how much loss it causes, though). I've found two sources that support this conclusion: The blog post Multi-prime RSA trade offs analyzes the security of a 2048-bit $k$-prime modulus against the NFS and ECM factoring algorithms. For $k=2$ and $k=3$, the security level is 107 bits (NFS is the best attack). For $k=4$, the article claims that the security level is 106 bits (ECM is slightly faster than NFS for four primes), so we've lost about one bit of security, though this estimate seems like it might over-simplify. Table 3 of the paper Unbelievable Security: Matching AES security using public key systems also addresses this issue. It suggests that, for a 2048-bit modulus, $k=3$ primes offers no measurable loss of security. Starting in 2030, $k=4$ primes will offer no loss in security (it changes over time because NFS factoring speeds up faster than ECM factoring). Here is Table 3:
0.333333
Multi-prime RSA trade offs analyzes the security of a 2048-bit modulus .
Next & Previous (Pagination in this case) Not Appearing
I am using a custom page template for my portfolio. The code is calling the correct number of posts per page but for some reason the pagination links won't show up :-S My query <?php $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 2)); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php $custom = get_post_custom($post->ID); $screenshot_url = $custom["screenshot_url"][0]; $website_url = $custom["website_url"][0]; ?> The entire markup <?php /* Template Name: Portfolio */ ?> <?php get_header(); ?> <div id="full_container"> <div id="portfolio_content"> <div id="portfolio_wrap"> <div id="content"> <?php $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 2)); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php $custom = get_post_custom($post->ID); $screenshot_url = $custom["screenshot_url"][0]; $website_url = $custom["website_url"][0]; ?> <a href="<?php the_permalink() ?>"> <span class="img"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thmb-portfolio' ); } ?> <span class="under"> <!-- Excerpt title --> <span class="title"><?php the_title(); ?></span> <!-- Excerpt description --> <span class="desc"> <?php my_excerpt('short'); ?> </span> </span> </span> </a> <?php endwhile; ?> <!-- Next/Previous Posts --> <?php if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); } ?> </div> </div> </div> </div> </div> <?php get_footer(); ?>
<?php /* Template Name: Portfolio */ ?> <?php get_header(); ?> <div id="full_container"> <div id="portfolio_content"> <div id="portfolio_wrap"> <div id="content"> <?php $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 2)); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php $custom = get_post_custom($post->ID); $screenshot_url = $custom["screenshot_url"][0]; $website_url = $custom["website_url"][0]; ?> <a href="<?php the_permalink() ?>"> <span class="img"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thmb-portfolio' ); } ?> <span class="under"> <!-- Excerpt title --> <span class="title"><?php the_title(); ?></span> <!-- Excerpt description --> <span class="desc"> <?php my_excerpt('short'); ?> </span> </span> </span> </a> <?php previous_posts_link('Previous'); ?> / <?php next_posts_link('Next') ?> <?php endwhile; ?> <?php if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); } ?> </div> </div> </div> </div> </div> <?php get_footer(); ?>
0.888889
Template Name: Portfolio
Password hashes should run md5 thousands of time: really?
I skimmed through How Companies Can Beef Up Password Security and I thought that several assertions were completely wrong, in particular: Cryptographic hash (like md5) with salt are bad. It isn't uncommon to break/crack unix shadow files. To make a password hash I should run it over md5 or whatever hundreds or thousands of times. The article suggests that salted hashes are too easy to break and you'd want to select a password hash because its computationally longer to check passwords so you can not do as many per second. I think doing 3 is bad for security and 1 is in reality the best option. What do you guys think?
Why do you think 3 is bad for security? Really what you should be doing is using something like bcrypt to hash your passwords to avoid all this mess. Bcrypt combines those properties. It hashes the password using a salt many times over to create a slow and secure hash function that produces cryptographically secure hashes.
1
Why do you think 3 is bad for security?
Can a portion of human skin cells be modified in some way to generate light?
I have come across some species of living organisms who are able to emit light at whim. Can that ability be incorporated into a portion of human skin (a specialized tissue)?
Sort of problematic is the "at a whim" part. Just a brief search to wikipedia on electric organs, here, we see that the electrocytes are controlled by a nucleus of pacemaker neurons. This is all unique to electric fish, and you'd have to express that whole system in a human being to elicit the same effect. You'd also have to consider how your organism is engineered to withstand the actual electric shock emitted by the electric organ. We can already tag molecules with luciferase to emit light as a mode of bio-luminescence. To get an appreciable reaction, or rather an appreciably bright light, I can imagine we'd need a ridiculous amount of luciferin in vivo, though. We also get stuck at the part about it being on a whim. The control mechanisms/structures for the light-emitting reaction simply aren't present.
1
"at a whim" part of electric organs
Why is the 't' in Hash Table(Hashtable) in Java not capitalized
Everything in Java seems to follow capitalization rules except for Hashtable. Hashtable<String, String> ht = new Hashtable<String, String>(); as opposed to ArrayList<String> a = new ArrayList<String>(); or HashMap<String,Integer> a = new HashMap<String,Integer>(); Why is this ? Is Hash Table read as just one word (Hashtable) ?
Although this question has no technical value, I have to admit, I've asked myself this a couple of times :) My version is that unlike List (ArrayList), Set (HashSet) , Map (Tree/HashMap) table is not a data structure. Of course (its possibly known) that the Hashtable class was created before the collection framework (in java 1.0). So maybe at that point they didn't really thought about the same naming conventions. In general we better use collection framework from java 2+ :)
1
Hadhtable class was created before collection framework .
Does "so far, so good" carry a negative connotation?
As a follow up to this etymology question, does "so far, so good" carry a negative connotation? For example, after having her sonogram, my wife asked the technician if everything was okay. The technician replied, "so far, so good." My wife later remarked that she didn't like that the technician used the phrase because it sounded like things will be going wrong later. I always thought this phrase was positive and that it was a replacement for the word "good."
I'd say it was neutral rather than negative. It means something like Everything's OK so far. Let's hope it stays that way.
0.888889
Let's hope everything's OK so far
Controller dispatch error in Zend framework 2
I am returning Json response from zend controller. This is my code Controller Code public function get() { $result = //calling other function and getting response in array print("value in controller before calling toJsonModel"); print_r($result); $temp = $this->toJsonModel($result); var_dump($temp); return $temp; } toJsonModel function public function toJsonModel($data = array()) { $data['requestId'] = $this->getHeader('RequestId'); print("Value just before returning to controller"); print_r($data); return new JsonModel($data); } Response First and second print displays correct values. But after getting values from toJsonModel when I try to displays wrong values and adds some other values like "captureTo", "terminate" and "children" as protected. I don't know why it's giving me wrong message. Can any one guide me to right path and tell me what the problem is ? Thanks in advance. EDIT I am adding new screenshot to display full message. ERROR : {"name":"Email Not Found","message":"No account found with this email address.","code":404,"requestId":"12","reason":"error-controller-cannot-dispatch","display_exceptions":true,"controller":"RSMobile\Controller\ForgotPassword","controller_class":null}
This is because you are returning an object of JsonModel from method toJsonModel. return new JsonModel($data); So, every object has some properties that you can use to manipulate data. See the docs of Zend\View\Model\JsonModel here So actually the values are not wrong but there is a way to access properties of an object. Update Attaching dispatch event public function onBootstrap($e) { // some stuff $eventManager = $e->getApplication()->getEventManager(); $eventManager->attach("dispatch", function($e) { echo "Dispatch!"; }); // some stuff }
0.777778
Return JsonModel from method toJsonModel
Local user accounts have disappeared after installing Active Directory and running dcpromo
I'm kinda newbie in this Windows 2008 Server R2 configuration stuff, so I would appreciate any help regards the issue I'm facing. After a Windows 2008 Server R2 clean install I created a couple of local user accounts and joined them to the administrators group, I tested them and I was able to log on with each one. Then I installed Active Diectory role (DNS role implied) and runned DCPromo. The domain was created and promoted succesfully and I was able to log on into the domain from a client machine. The issue began when I realized that I was no longer able to log on locally into the server (meaning LOCALMACHINE\localusername). I looked into domain user accounts and noticed that the local user accounts I created previously were now part of the domain. I consider a bad thing not being able to log on locally anymore, so in a shot to fix it I stopped the Active Directory service... my bad! Now I'm sort of locked up, I can't log either locally or as part of the domain. Can someone please shed some light in this? What did I miss in the process? I tried googling but could find any straight forward solution or explanation. What concept I'm not catching?How can I promote a server to PDC and still be able to log on locally? Thanks in advanced.
When you install Active Directory, it removes any local accounts - this is well documented and intended functionality. As an aside, there are no primary and backup domain controllers any more - each DC is equal. Reboot the machine - Active Directory should start back up again on reboot. If it doesn't, reboot again and keep tapping F8 and boot into Directory Services Restore Mode. You should then be able to log in and interrogate the Event Viewer for any clues why Active Directory isn't starting.
0.888889
Active Directory removes local accounts - no primary and backup domain controllers
Filter a property by the value of another property
I have two drop down lists. Niether of them have a relation ship with each other. But I need to filter one drop down list based on the chosen value of another drop down list. I can filter it in code. When I debug I can see the filtered results on the property. However when I run the app, it does not work. Here is my code so far: private BindingList<Commodity> _AllocationCommodities; [Browsable(false)] public BindingList<Commodity> AllocationCommodities { get { if (_AllocationCommodities == null) { _AllocationCommodities = new BindingList<Commodity>(); ChangeCommodities(); } return _AllocationCommodities; } } private SourceEntity _SourceEntity; [ImmediatePostData] [Association("SourceEntity-LimitAllocations")] [RuleRequiredField("RuleRequiredField_LimitAllocation_SourceEntity", DefaultContexts.Save)] public SourceEntity SourceEntity { get { return _SourceEntity; } set { //New Code if (SetPropertyValue<SourceEntity>("SourceEntity", value)) { if (IsSaving || IsLoading) return; ChangeCommodities(); } } } private Commodity _Commodity;// This is the drop down to be filtered [ImmediatePostData] [DataSourceProperty("AllocationCommodities")] //// This Attribute Should filter Commodities [RuleRequiredField("RuleRequiredField_LimitAllocation_Commodity", DefaultContexts.Save)] public Commodity Commodity { get { return _Commodity; } set { SetPropertyValue("Commodity", ref _Commodity, value); if (Commodity.Oid != Guid.Empty) AllocationVolumeUnits.Reload(); } } private void ChangeCommodities() { if (!this.IsLoading && _SourceEntity != null) { _AllocationCommodities.RaiseListChangedEvents = false; _AllocationCommodities.Clear(); OperandValue[] _params; System.Collections.Generic.List<CMSBOD.SourceCommodity> _sc = new System.Collections.Generic.List<SourceCommodity>(); BindingList<Commodity> _Commodities = new BindingList<Commodity>(); foreach (SourceCommodityEntity _tempSCE in _SourceEntity.SourceCommodityEntities) { if (_tempSCE.SourceCommodity != null) _sc.Add(_tempSCE.SourceCommodity); } foreach (SourceCommodity _tempSC in _sc) { if (_tempSC.Commodity != null && !_Commodities.Contains<Commodity>(_tempSC.Commodity) && _tempSC.Commodity.IsActive) _Commodities.Add(_tempSC.Commodity); } _AllocationCommodities.RaiseListChangedEvents = true; _AllocationCommodities = _Commodities;///This is where I can see the filtered list when debugging. } }
You can find a DataSourceCriteria useful in this scenario, instead of DataSourceProperty. Assuming you have collection properties that associates Commodity back to SourceCommodityEntity, you can use this criteria: [DataSourceCriteria("IsActive And SourceCommodities[SourceCommodityEntities[SourceEntity = '@SourceEntity'] ]")] Even if its designed to be a 1x1 assocation, you can find that associations can be useful for filtering purposes.
0.777778
A DataSourceCriteria can be useful in this scenario, instead of DataSourceProperty
Overriding Attributes values in Shortcode Plugins
I have made some shortcode plugins according to my need. But this time I am getting a strange problem. My attributes in the shortcode are not getting the values written in the shortcode while executing them, instead I am just getting the default set values only. Please Help me. add_shortcode('wi_form' , 'wi_form_func'); function wi_form_func($input) { extract(shortcode_atts( array( 'productName' => 'Java', 'productPrice' => 1000 ), $input)); return $productName . esc_attr($productPrice); }
Try not to use capital letters in the shortcode attributes, use for example [wi_form product_name="php" product_price="888" ] where: add_shortcode( 'wi_form' , 'wi_form_func' ); function wi_form_func($input) { extract(shortcode_atts( array( 'product_name' => 'Java', 'product_price' => 1000 ), $input)); return $product_name . esc_attr( $product_price ); } or this: add_shortcode( 'wi_form' , 'wi_form_func' ); function wi_form_func($input) { $input = shortcode_atts( array( 'product_name' => 'Java', 'product_price' => 1000 ), $input ); return $input['product_name'] . esc_attr( $input['product_price'] ); } if you don't want to use extract: Update: The shortcode attributes go through strtolower() in the shortcode_parse_atts() function that retrieves them from the shortcode tag (see here).
0.777778
Shortcode attributes go through strtolower() in shortcode tag
Can the term "jack/jerk off" be used for female masturbation?
I apologize for this potentially obscene question. Can the terms jack off or jerk off be used for female masturbation? If not (which is my intuition), what would be the not too poetic vulgar slang equivalent? By too poetic I refer to expressions such as spank the monkey, choke the chicken, etc. I checked online dictionaries, and most of them don't expand on the usage, and some of the definitions in the Urban Dictionary imply that jack off primarily refers to male masturbation, but do not provide the female counterpart.
I vote for touching oneself. (Best political party ever?) I assume there’s some particular reason you want to avoid the word masturbate—too clinical, perhaps. If you’re looking for a euphemism that isn’t ostentatiously vulgar, I think touching oneself fits the bill, without sounding terribly childish. If you’re working on erotic fiction, masturbation does sound oddly forward; touching, rubbing, fingering, and other literal actions are all common, cromulent alternatives. And for the love of all that is good in literature, never, ever call a vulva a sex. It’s not cute.
1
If you’re looking for a euphemism that isn’t ostentatiously vulgar, I think touching
Right way to translate view Titles?
As far as I see the view titles are not translatable. As a quick fix I just created a new views-view.tpl.php file and changed the line 32 from: <?php print $title; ?> to <?php print t($title); ?> What do you think? Is this a right method?
I find existing answers rather confusing. Views (as we know) is extremely cool module. It supports localization plugins. Go to page admin/structure/views/settings/advanced to see for yourself: Preferred way to translate Views is to use Internationalization Views module which depends on i18n_string (i18n package) module. How to use? Just enable Internationalization Views and go to translate page for your view. You also may be interested in i18n_string settings here: admin/config/regional/i18n/strings. Core localization plugin just do t() for Views titles, headers, footers etc. It's not so flexible and secure, but as a developer you can choose this method in some cases. How to use? Nothing special here. Your strings will appear in Drupal translate interface after the first request. You can disable localisation at all or create your own plugin if you need.
0.666667
How to translate Views?
Is there a list of Mitzvot and their corresponding body parts?
The Talmud (Makkot 23B)and the Zohar (1:170B - unverified English translation here) say that the 248 positive commandments correspond to the 248 limbs of the human body. (The Mishna (Ohalot 1:8) lists the 248 Halachic limbs). The Talmud also says that the 365 Negative commandments correspond to the days of the year. The Zohar adds that the 365 negative commandments also correspond to the 365 sinews in the human body (See Yonatan Ben Uziel Bereshit 1:27), and connects them to the days of the year. R' Chaim Vital, in Shaar HaKavanot (Shaar 1, Part 1) says that "Each of the 248 spiritual limbs gets its nourishment from a particular mitzvah that corresponds to that limb. When a person fails to perform that particular mitzvah, the corresponding limb will lack its proper nourishment..." (translation from here) Is there any source which tells us which limb (and/or sinew) each Mitzvah corresponds to? As an example, the Zohar referenced above (1:170B), connects Gid Hanasheh (sciatic nerve), one of the 365 sinews, to the prohibition of eating on Tisha B'av.
Biblical mitzvos are in bold. Items that are minhagim or otherwise are not mitzvos are listed for completeness but are not bold. -- Each is followed by the corresponding (set of) body part(s) 30 days of blowing shofar (in Elul) -- 30 in the feet 10 offerings brought on Rosh Hashana -- 10 in the ankles 2 approaches to the aron(?) -- 2 in the shins 5 people called up to the Torah -- 5 in the knees 1 day of Rosh Hashana -- 1 in the thighs 3 types of shofar sound -- 3 in the hips(?) 11 sounds blown with the musaf -- 11 ribs 9 b'rachos in the amida of Rosh Hashana -- 9 in the arms 30 verses recited in that amida -- 30 in the palms 18 b'rachos in the daily amida -- 18 vertebrae 9 shofar sounds with the daily offering -- 9 in the head 8 shofar sounds with two bowings -- 8 in the neck 5 books of Torah -- 5 cavities 6 books of Mishna -- 6 in the heart Disclaimers: This might be a partial list, a complete confound, or not what you're looking for. Some numbers may need to be doubled for dual limbs. The above most likely does not add up to 248. It comes from מחזור רבא - נוסח ספרד - ראש השנה, published by שי למורא, on page 198 in my edition. It is part of an inserted piyut in the k'dusha of musaf. A very similar list appears in a number of other machzorim (example) and some translation assistance was provided by this machzor. Some of the items on this list are mitzvos, even if it is intended for a purpose other than explication of the statement of Rav Simla'i in Makos that you linked. If they don't count toward the general total then some body parts must double count.
1
Biblical mitzvos are in bold but not bold.
Is potential energy and "work done" the same thing?
Is potential energy and "work done" the same thing? If they are not one and the same thing then why is potential energy always associated with "work done"? Could you explain me with some examples?
Suppose you drive your car to the store and back. Your car started and finished in the same place (on your drive) so its potential energy hasn't changed but during the trip the car engine did a lot of work. This is an example where the work done is not equal to the change in potential energy. Generally speaking in physics we are interested in conservative forces, and one of the definitions of a conservative force is that the work done is equal to the change in potential energy. This normally means energy neither leaves or enters the system we are considering. The reason the example I gave of the car journey is non-conservative is that friction and drag causes energy to leave the system (as heat). In principle if your car had no friction or drag then it would use no energy going to the store unless the store was at a different height. If the store was at a different height then any energy used going to the store would be recovered on the way back.
1
Suppose you drive your car to the store and back
How do I make certain areas editable?
I'm new to wordpress and I'm currently converting an HTML/CSS site I made to wordpress to make it easier for my client to edit it from the admin panel. I have provided 3 screenshots and I'll refer to them here. The first screenshot shows how my website looks so far. It's using a template I made called homepage.php (see screenshot 3 for code). The template includes header.php which contains the logo, navigation menu etc. It has the image banner and finally includes footer.php. I want the "Our Values" part to be editable so that my client can change the text any time they need to. Currently, they can edit the top part which says "PROtential Coaching" and that's because it's included on the page within the admin panel and not in the template. I want the bottom part including"Our Values" to be editable from that panel too, is there a way to do this or does this content have to be static and within the template? "Our Values" and "Our People" are in a dynamic secondary navigation menu which my client can add items to if they want to, however they can't change the content for the menu item. Images: http://imgur.com/yq9y8SQ,5IqOPzr,SHkzrFz Please help me out guys, I've been looking all over the place for days to get this done.
These links should help you: http://codex.wordpress.org/The_Loop http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items with this two techniks you can give your client the ability to change the content and the navigation. For these you have to edit your theme and insert the snippets on the placese you want to output your contents.... For the footer you can use a custom page maybe footer $loop = new WP_Query( 'pagename=footer' ); while ( $loop->have_posts() ) : $loop->the_post(); the_content(); endwhile;
1
How to change content and navigation?
Draggable / floating Web Part Properties dialog
I have a pretty tight design that has a fixed width. However, when editing a Web Part, the dialog gets cut off or sometimes doesn't get display at all because of the frame's overflow. I would like to implement a floating Web Part properties dialog. Any suggestions on how to approach this and apply it across my site collection?
If this is part of a page layout, you can have a separate stylesheet for edit mode that relaxes your fixed width or removes your branding altogether to make it easier to modify web part properties. You would use an EditModePanel. I've done things like this in page layouts: <asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server"> <PublishingWebControls:EditModePanel runat="server" id="ContentDisplay" PageDisplayMode="Display"> <link rel="stylesheet" href="mydisplaymode.css" /> </PublishingWebControls:EditModePanel> <PublishingWebControls:EditModePanel runat="server" id="ContentDisplay" PageDisplayMode="Edit"> <link rel="stylesheet" href="myeditmode.css" /> </PublishingWebControls:EditModePanel>
0.888889
EditModePanel
Folder compare tool?
I'm looking for a Windows GUI tool to compare the contents of two folders and show which files are different....
SourceGear DiffMerge compares files and folders, and is free to use.
1
SourceGear DiffMerge compares files and folders
Is it reasonable to use Javascript MVC Frameworks for closed source paid web applications?
I am wondering if it is reasonable to write closed source, paid web apps in Javascript (JS MVC Frameworks like AngularJS, Backbone, Knockout, ...)? I'm concerned because in this type of frameworks you use typically a REST backend for CRUD operations and the majority of business and application logic happens in Javascript which can be looked up by anyone using my app. He can see how i do things. When I use for example PHP or Java (Wicket) most of the logic is happening on the server and so a lot less of my source code is exposed. This seems to me a lot safer if I want to have an edge over my competitors, so potentially I earn more money. So is it reasonable to use JavaScript MVC Frameworks for paid applications? Does it depend on something and if yes on what?
If you are only using REST as your entire backend to communicate with the database, that maybe your problem. Using EJB and JPA, the business logic is abstracted away from the user, and handled by the server and its database. If your application logic is happening in your java code, well then I would suggest that it is not clean code. A servers job is to respond to the questions asked by the client. If the business application logic happens in javascript, then the client is essentially answering their own questions. Essentially, your questions makes no sense.
1
Using REST as your entire backend to communicate with the database
Is it possible to jailbreak an iPad 2 (A1395) after updating to iOS 6.0.1?
I have a jailbroken iPad 2 (A1395) running Version 5.0.1 (9A405). If I update to 6.0.1, can I jailbreak untethered? Will I have to re-install all my Cydia apps & settings, or do they get backed up and restored? Confused by too many Google results!
Dont do it!!!!!!!!!!!!! If you upgrade you will kill any chance (at present of jailbreaking). I did mine last year without thinking and have regretted it ever since. stay with ios 5.1. Trust me there is no benefit at all in upgrading only losses
0.777778
if you upgrade you will kill any chance .
Is there a stable Linux distro using btrfs?
I'm a big fan of ZFS on FreeBSD (I've been using it on my home server since before it got stable; bleeding edge, baby!) and I'd like to try out btrfs to see how that's evolving. Since it's still largely in development, none of the usual mainstream distros have btrfs as an option. I haven't used Linux in a bunch of years, so I don't really know what my best options are for giving btrfs a try. Requirements: easy to install btrfs supported without requiring me to rebuild the kernel Thanks!
Debian supports it. I've had it installed on a server of mine and running for about six months now. No issues, really.
1
Debian supports it
Where is the Atiyah-Singer index theorem used in physics?
I'm trying to get motivated in learning the Atiyah-Singer index theorem. In most places I read about it, e.g. wikipedia, it is mentioned that the theorem is important in theoretical physics. So my question is, what are some examples of these applications?
The equations of motion, or the equations of instantons, or solitons, or Einstein's equations, or just about any equations in physics, are differential equations. In many cases, we are interested in the space of solutions of a differential equation. If we write the total (possibly nonlinear) differential equation of interest as $L(u) = 0,$ we can linearize near a solution $u_0,$ i.e. write $u = u_0 + v$ and expand $L(u_0 + v) = 0 + L'|_{u_0}(v) + ... =: D(v)$ to construct a linear equation $D(v)=0$ in the displacement $v.$ A linear differential equation is like a matrix equation. Recall that an $n\times m$ matrix $M$ is a map from $R^n$ to $R^m$, and $dim(ker(M)) - dim(ker(M^*)) = n-m,$ independent of the particular matrix (or linear transformation, more generally). This number is called the "index." In infinite dimensions, these numbers are not generally finite, but often (especially for elliptic differential equations) they are, and depend only on certain "global" information about the spaces on which they act. The index theorem tells you what the index of a linear differential operator ($D,$ above) is. You can use it to calculate the dimension of the space of solutions to the equation $L(u)=0.$ (When the solution space is a manifold [another story], the dimension is the dimension of the tangent space, which the equation $D(v)=0$ describes.) It does not tell you what the actual space of solutions is. That's a hard, nonlinear question.
1
In infinite dimensions, these numbers are not generally finite, but often depend only on certain "global" information about the space of solutions
Representation of negative integers
Does ISO-Prolog have any prescriptions / recommendations regarding the representation of negative integers and operations on them? 2's complement, maybe? Asking as a programmer/user: Are there any assumptions I can safely make when performing bit-level operations on negative integers?
Strictly speaking these are two different questions: Actual physical representation: this isn't visible at the Prolog level, and therefore the standard quite rightly has nothing to say about it. Note that many Prolog systems have two or more internal representations (e.g. two's complement fixed size and sign+magnitude bignums) but present a single integer type to the programmer. Results of bitwise operations: while the standard defines these operations, it leaves much of their behaviour implementation defined. This is a consequence of (a) not having a way to specify the width of a bit pattern, and (b) not committing to a specific mapping between negative numbers and bit patterns. This not only means that all bitwise operations on negative numbers are officially not portable, but also has the curious effect that the result of bitwise negation is totally implementation-defined (even for positive arguments): Y is \1 could legally give -2, 268435454, 2147483646, 9223372036854775806, etc. All you know is that negating twice returns the original number. In practice, fortunately, there seems to be a consensus towards "The bitwise arithmetic operations behave as if operating on an unlimited length two's complement representation".
0.833333
arithmetic operations on negative numbers are officially not portable .
What is the white sauce of Domino's pasta made of?
What is that made of? Can it be replicated at home?
It's Alfredo sauce and according to Domino's nutrition guide it's made of: Water Cream (Cream, Milk) Parmesan Cheese (Part-Skim Milk, Cheese Cultures, Salt, Enzymes) Asiago Cheese (Pasteurized Milk, Cheese Culture, Salt, Enzymes) Margarine (Palm Oil, Water, Salt, Vegetable Monoglycerides, Whey Solids,Sodium Benzoate [Preservative], Natural And Artificial Flavor, Citric Acid, Beta Carotene [Color], Vitamin A Palmitate Added) Seasoning (Maltodextrin, Nonfat Milk, Modified Corn Starch, Salt, Enriched Bleached Wheat Flour [Bleached Wheat Flour, Malted Barley Flour, Niacin, Reduced Iron, Thiamine Mononitrate, Riboflavin, Folic Acid], Disodium Inosinate, Disodium Guanylate, Xanthan Gum, Spices, Mono And Diglycerides) Butter (Butter, Salt) Parmesan Cheese Concentrate (Parmesan Cheese [Pasteurized Milk, Cultures, Salt, Enzymes], Water, Salt, Natural Flavors, Yeast Extract, Sodium Phosphates, Sodium Citrate) Modified Corn Starch Garlic (Garlic, Water) Chicken Base (Chicken Meat, Chicken Juices, Salt, Potato Flour, Flavorings, Sugar, Disodium Inosinate, Disodium Guanylate) Parsley Salt You can definitely make something similar at home. You should also be able to buy something like it in a jar at your local grocery store.
1
Water Cream (Cream, Milk) Parmesan Cheese (Part-Skim Milk, Cheese Cultures, Salt, Enzymes
Why would an incorrect password attempt take a lot longer to process than a correct one?
The most prominent place I've noticed this is when SSH-ing at work, but I feel like I've observed this behaviour elsewhere too. When I try to log into Linux servers from my Windows desktop at work, I've noticed that if I mis-type my password, it takes a good 5 seconds or so before I get "Access Denied" back. Then when I type my password correctly, the login (along with welcome messages etc) is virtually instant. Is there any logical reason for this, or would it be down to some odd configuration that's specific to the machines here at work?
Technically, this deliberate delay is to prevent attacks like the "Linearization attack" (there are other attacks and reasons as well). To illustrate the attack, consider a program (without this deliberate delay), which checks an entered serial to see whether it matches the correct serial, which in this case happens to be "xyba". For efficiency, the programmer decided to check one character at a time and to exit as soon as an incorrect character is found, before beginning the lengths are also checked. The correct serial length will take longer to process than an incorrect serial length. Even better (for attacker), a serial number that has the first character correct will take longer than any that has an incorrect first character. The successive steps in waiting time is because each time there's one more loop, comparison to go through on correct input. So, attacker can select a four-character string and that the string beginning with x takes the most time. (by guess work) Attacker can then fix character as x and vary the second character, in which case they will find that y takes the longest. Attacker can then fix the first two characters as xy and vary the third character, in which case they will find that b takes the longest. Attacker can then fix the first three character as xyb and vary the fourth character,in which case they will find that a takes the longest. Hence, the attackers can recover the serial one character at a time. Linearization.java. Linearization.docx, sample output The serial number is four characters long ans each character has 128 possible values. Then there are 1284 = 228 = 268,435,456 possible serials. If attacker must randomly guess complete serial numbers, she would guess the serial number in about 227 = 134,217,728 tries, which is an enormous amount of work. On the other hand, by using the linearization attack above, an average of only 128/2 = 64 guesses are required for each letter, for a total expected work of about 4 * 64 = 28 = 256 guesses, which is a trivial amount of work. Much of the written martial is adapted from this (taken from Mark Stamp's "Information Security: Principles and Practice"). Also the calculations above do not take into account the amount of guesswork needed to to figure out the correct serial length.
1
The correct serial length of a serial is longer than an incorrect first character .
Is it safe to eat freshwater fish raw?
According to this question freshwater fish should not be used in Ceviche--why not?
To reduce the mercury issue with freshwater fish trim away the belly meat because that is where the majority of mercury settles. Also, most areas will have pollution warning for specific fisheries.
0.888889
To reduce the mercury issue with freshwater fish trim away the belly meat
Brakeman: model attribute used in file name warnings
I'm setting file name like 'abc_1.pdf' where '1' is the value of a model's attribute. But brakeman scanner take this as security issue. I need to keep track of files by referencing file name with model attribute. Can you please tell me, what is the right way to fix this security issue? Thanks.
You could sanitize model attribute when generating file name "abc_#{sanitize(@mymodel.some_attribute)}.pdf" I think we could find even better solution if you post exact code example.
0.777778
sanitize model attribute when generating file name
How can I learn how to lay out an "evidence scene"?
I feel like I'm particularly bad at any kind of scene where I want to drop clues. I'm hesitant to use the term "crime scene" because it's not always being investigated by "police", and some of these times there isn't any kind of typical evidence. I'm not even 100% sure that my problem is just the scene, but rather creating enough evidence to begin with. Other aspects I struggle with is witnesses - both witnesses with knowledge, and how to reveal it. Having useless witnesses for flavor, etc. I keep feeling that in general I give too little in these scenes, and everything I give is important. Since I suspect this is a rather broad problem, I'd like to know if there are any Role Playing resources (sections of books, site, etc) that are specifically geared at teaching this portion of RPG storytelling? I'm currently playing in the "new" World of Darkness 2.0, but I want answers on this not tied to the game system's rules.
I watched a whole lot of Law & Order with an eye toward trying to understand how they structure their mysteries. I noticed a few things that I think ought to help run a mystery game. (Life has gotten in the way of testing my theories in the game I was to run, so do report back if any of this helps!) First, a mystery is not a confusing story--it's a simple story about a perpetrator, a victim, and a crime scene, that the characters learn out of sequence. Supposing we're talking about a murder, there is a victim, and there is physical evidence. The detectives will have physical evidence to check out, and they'll want to learn about the social network that the victim was a part of. The clues and interviewees lead to more places to look for more evidence. Bringing me to the second point: the detectives spend as much time or more ruling possibilities out than learning about them. The common problem GMs face is not wanting to give out too much information; I suspect that the thing to do is give out a good amount of information that looks suspicious, so that the characters turn up new evidence while ruling out suspects. The elements of a mystery game, then: nameless NPCs who are forthcoming with information, though they don't have any idea how it fits into an investigation; named NPCs who act suspiciously and lie to the PCs, but because they are concealing a secret that doesn't directly relate to the crime; a perpetrator who seems like they can be ruled out, but whose guilt will be revealed when facts that come up while the PCs are ruling things out show the motive, means, and opportunity of this perpetrator. Justice is served, etc. etc. Like I said, these are theories that haven't been borne out by play. But I stand by this idea that a crime is a simple linear incident, and an investigation is a nonlinear process of alternately expanding the network of physical and social links, and ruling things out, until only the perpetrator remains.
1
a mystery is not a confusing story--it's a simple story about a perpetrator, a victim, and
How can I get my main class returned?
This main class is initialized by the Bukkit framework and cannot be initialized again. public class Demo extends JavaPlugin { public void onEnable() { } } How do I access its unique instance from other classes? public class CoolDown extends BukkitRunnable { public CoolDown(Demo mainClass, int time) { } public void run() { } }
If you want to use the OOP way: In your CoolDown class, have a field with the type of Demo (or your JavaPlugin-extending class). You may also create any other fields you will pass in the constructor here. private Demo plugin; private int time; Then instantiate the fields using the CoolDown's constructor public CoolDown(Demo plugin, int time) { this.plugin = plugin; this.time = time; } Now you can use the plugin field for your needs. Example: public void run() { plugin.fooBar(); } If you want to use the Static Programming way (not recommended, you are in a OOP language being Java!): In your Demo class, have a public, static field of type Demo, without any value (this is after the class decleration, by the way). public static Demo instance; In your plugin's enable method (I suggest to put this at the very first line of the method invokation): instance = this; Then you can use, in your CoolDown's run() method invokation: Demo.instance.fooBar(); Once again, I do not suggest using static programming in Java. It's a lazy and bad practice in general. Here is a full example, in your case, in OOP programming: public class Demo extends JavaPlugin { public void onEnable() { Bukkit.getScheduler.scheduleMyEpicCooldown(new CoolDown(this, time), time); } } public class CoolDown extends BukkitRunnable { private Demo plugin; private int time; public CoolDown(Demo plugin, int time) { this.plugin = plugin; this.time = time; } public void run() { plugin.fooBar(); } }
0.666667
How to use the OOP way in Java
How to hide a DIV element when I click outside
I have a div and want to hide it when I click outside. My code is: <div id="mydiv">The div must be above button</div> $('#mydiv').click(function(e) { e.stopPropagation(); }); $(document).click(function() { $('#mydiv').fadeOut(300); }); But it is not working for me ... UPDATE Full code is presented below. When I click on a button it shows a div above, so I need to hide this div when I click outside. DEMO <div id="but" style="text-align: right;"><button type="button">Show Div!</button></div> <div id="mydiv" style="display:none;">The div must be above button</div> $("#but button").click(function(){ var pos = $(this).offset(), div = $("#mydiv"); // Make it visible off-page so // we can measure it div.css({ "display": "block", "border": "1px solid black", "position": "absolute", "left": -10000, "top": 0 }); // Move it where we want it to be div.css({ "left": pos.left - 40, "top": pos.top - div.height() - 10 }); }); $('#myDiv').click(function(e) { e.stopPropagation(); }); $(document).click(function() { $('#mydiv').fadeOut(300); });
Better than binding click event to document, you can use this kind of snippet: SEE DEMO $('#mydiv').click(function(e) { e.stopPropagation(); }) .css({outline:0}) .focusout(function(){ $(this).fadeOut(300); }).focus();
0.666667
click event to document
Custom Logout in Sharepoint 2010
I have sp application where there are 15 subsite.I need to redirect each subsite to the respective logout page when i click logout.How do i achieve this & properly logout each respective subsite?
No need to LOGOUT each SubSite but simple call this page in the _layouts virtual folder (available from wherever in SharePoint) use (the / in front would make your link relative to your site collection) /_layouts/signOut.aspx
0.888889
LOGOUT a SubSite in SharePoint
Does adding a comma before "or" change the meaning of a phrase?
For example, the definition given from the OALD for pronoun is the following one: a word that is used instead of a noun or noun phrase, for example he, it, hers, me, them, etc. If I would rewrite it as the following, would the mean change? a word that is used instead of a noun, or noun phrase, for example he, it, hers, me, them, etc. If the meaning doesn't change, are there other differences between those phrases? Is this just an example of using the Oxford comma, or is there something different/more? I am asking because I rephrase a similar phrase, and I was said it was more correct without the comma.
This is not an Oxford comma because it is not the serial comma customarily used before a coördinating conjunction at the end of a series. It is instead an example of paired commas used as a weak or less obtrusive form of parentheses. These are all equivalent: A pronoun is a word that is used instead of a noun, or noun phrase, for example he, it, hers, me, them, etc. A pronoun is a word that is used instead of a noun (or noun phrase), for example he, it, hers, me, them, etc. A pronoun is a word that is used instead of a noun — or noun phrase — for example he, it, hers, me, them, etc. Such “parenthifying” punctuation is something that could be omitted without great loss. I don’t think you can use the comma there, because “or noun phrase” cannot be freely omitted without changing the overall meaning. Also, the indefinite article seems intended to distribute across noun and noun phrase in that sentence, and if you break it up with a comma, you lose that. My own preference would be to write that this way: A pronoun is a word used in place of a noun or noun phrase; for example, he, it, hers, me, mine, and them are all pronouns. Incidentally, this is the pro- that means “for”, so a pronoun is a word used for a noun (or noun phrase).
1
A pronoun is a word that is used instead of a noun (or noun phrase)
How to undo card archive on Trello?
I accidentally hit c with a card selected and archived the card. I tried to undo the archive but couldn't find the option. I tried moving the card back to the list but that didn't seem to work.
You can also visit your profile and see the audit trail of what you've done to each card, which includes a link to the archived card. Then you can "move" the card back to the board.
1
"move" the card back to the board
Offline tiled map web app
I'm not sure whether to post this here or on Stackoverflow, as it's sort of a crossover. Let me give it a try. In the proposed HTML5 standard, there's the option of storing web application data in a local cache using a cache manifest. I am looking to use this technique for an offline tiled web map application and did a quick prototype here based on a standard install of Geoserver. I just ripped the OpenLayers client page that is generated from one of the default layers and changed the <html> tag to <html xmlns="http://www.w3.org/1999/xhtml" manifest="cache.manifest"> And created the file cache.manifest which simply reads CACHE MANIFEST http://lima.schaaltreinen.nl:8080/ Which should, in my limited understanding of the matter, locally cache everything that loads from that URL: all tiles and the OpenLayers JS. In fact, upon first call in Firefox, it does ask me to allow local storage, but when I hit refresh - either online or offline - the page croaks stating that the OpenLayers object is not defined. Looks like it hasn't loaded the OpenLayers JS. Anyone successfully did a functioning offline OpenLayers-based tiled web map app? Or hints on how to investigate this further?
You might be interested in the projects Maps on a Stick and MapBox iPad. (disclaimer: designed the former, involved in the latter. however, both are BSD-licensed, and the underlying tile format, termed ".mbtiles", is SQL-based.) Maps on a Stick is an offline OpenLayers map. The main reasoning for going with a portable database/server instead of client side storage is that using browsers as large data storage isn't quite worked out and populating and indexing the cache can be costly.
0.777778
Maps on a Stick and MapBox iPad
"Files" can't be resized
I am not able to change the size of my nautilus window. It is now small. What should I do to restore it to normal size?
Click in the window to make it active, then hold ALT and hit space - a small menu will appear at the top left corner of the window. You will see: Minimize Maximize / Unmaximize Move Resize Always on top Close "Unmaximize" is present if you have the window "maximized". "Move" makes the arrow keys usable for moving the window (press ESC to exit this mode), same for "Resize".
0.888889
Minimize Maximize / Unmaximize Move Resize Always on top
Hard Disk Speed for Virt Laptop
If I want to run a few dev VMs on a laptop, how fast do my drives realistically need to be? I do not expect lightning fast performance, but the last time I tried this on a Lenovo Thinkpad T400, suspending to disk takes forever, and the host OS (Windows 7 x64 Professional) grinds to a halt with VMWare Workstation 6.5. I understand this is going to happen, and this is not the right platform in general, but how much better would I have it with a 7200 RPM drive? Are there faster drives available? I really want to have the flexibility of VMs on the go, and it takes 3+ or 4+ minutes the last time I tried. The current one is really crappy. I am shopping for a new computer anyway, and I was hoping someone could tell me this is a worthwhile consideration for now and the future or just a pipedream.
You don't mention the memory on your system, the speed of the processor, what load you normally run, what you're doing in the VM's...Some of it might be in the links, but for the sake of the question it wouldn't have been all that hard to just post what your system has so people answering don't have to chase links. Nor do you really say what's acceptable for speed (or perceived speed). That's the biggest issue that specs can't give...what do you consider acceptable? Best answer I can offer is that 7200 RPM drives would help a little. SSD drives should really speed it up. Bump memory up as much as your system will accept and you'll see another nice boost.
0.777778
What do you consider acceptable for speed?
CTE Running in Infinite Loop
My CTE runs in an infinite loop for a specific customer and I am not able to find out why. Here is the query: ;WITH ClassTree AS (SELECT ID, NAME, Parent_ID FROM TableName WHERE ID = 1 UNION ALL SELECT T.ID, T.NAME, T.Parent_ID FROM TableName T WITH (NOLOCK) JOIN ClassTree ON Parent_ID = ClassTree.ID ) SELECT * FROM ClassTree
The very first thing I would do is change this: JOIN ClassTree ON Parent_ID = ClassTree.ID to this: JOIN ClassTree ON t.Parent_ID = ClassTree.ID It might be trying to join ClassTree to itself since you didn't specify the table alias in the join.
1
JOIN ClassTree ON Parent_ID = ClassTRee.ID
Grouping Multiple Raster Layers
My question is how to create multiple raster layers group, for example when using several aerial photos. I wish to group the layers into one so that I can edit/select as a batch rather than having to click on individual layers. I use ArcGIS 10.2. Thank you in advance!
If you aren't looking to mosaic your rasters, it sounds like you just want to group them. Have a look at creating a Group Layer on the ESRI help page. If that doesn't help, perhaps have a look at the Overview of the Raster Toolset on the ESRI help page.
0.777778
Create a Group Layer on the ESRI help page
Dynamic Programming: find the minimal route with ten nodes from a set of 100 nodes
You are given 100 stations and distance between each adjacent stations. Now you have to select 10 stations(means 10 hops) among those 100 stations in such a way that maximum of distance between any 2 hops will be minimised. By default 1 and 100 stations are selected , so you need to choose only 8 more stations.
Since you haven't told us: I'll assume time isn't an issue I'll assume memory isn't an issue. I'll assume the answer isn't programming language specific I'll assume you are aiming to get from one station (1) to a destination station (100) //Iterate through all possible paths to destination //If you take more than 8 steps, stop and go back //Note the total length of each path //Select the shortest path You're question is impossible difficult to answer, as such, my answer is rather impossible to understand. You will need to learn how to ask questions to get decent answers. While you're at it, learn to accept answers
0.666667
How to ask questions to get decent answers?
linq to xml query with all attributes
I have a xml document like this <Products> <Product Name="Mobile Device" Code="10000000000000000006"> <Providers> <Provider Name="VODA" Code="VODA"> <Menus> <Menu Name="Home" Url="TopModelsNew.aspx" DisplayOrder="1" NewWindow="0"/> <Menu Name="Top Queries" Url="TopIssues.aspx" DisplayOrder="2" NewWindow="0"/> <Menu Name="Error Codes" Url="PCErrors.aspx" DisplayOrder="3" NewWindow="0"/> </Menus> </Provider> </Providers> </Product> I want to find all the menu where Product Code="10000000000000000006" and Provider Code="VODA" in a list. The result should be like Name Url DisaplayOrder Home TopModels 0 I was trying linq to xml as follows XDocument xdoc = XDocument.Load(Server.MapPath("~/App_Data/LeftMenu.xml")); var products = from product in xdoc.Descendants("Product") where new{ ..... }; I am not able to find how to get the list.
var menus = doc.Root .Elements("Product") .Where(p => (string)p.Attribute("Code") == "10000000000000000006") .SelectMany(p => p.Element("Providers").Elements("Provider")) .Where(p => (string)p.Attribute("Code") == "VODA") .SelectMany(p => p.Element("Menus").Elements("Menu")) .ToList(); It returns all 3 menu elements for your sample data. You can use projection to get anonymous object instead of XElement: var menus = doc.Root .Elements("Product") .Where(p => (string)p.Attribute("Code") == "10000000000000000006") .SelectMany(p => p.Element("Providers").Elements("Provider")) .Where(p => (string)p.Attribute("Code") == "VODA") .SelectMany(p => p.Element("Menus").Elements("Menu")) .Select(m => new { Name = (string)m.Attribute("Name"), Url = (string)m.Attribute("Url"), DisplayOrder = (int)m.Attribute("DisplayOrder") })
0.888889
XElement returns all 3 menu elements for sample data
Can we represent this sequence as a function of n?
I have this sequence : 4,12,24,48,240,720,.... I order to find nth term of this sequence , can we represent this sequence as a function of n.
I wrote out the factorizations of the first 24 numbers: ================================================================ # A133411 (b-file synthesized from sequence entry) 2 3 5 7 11 13 17 19 23 29 31 - - - - - - - - - - - 1 1 2 2 1 3 4 2 4 12 2 1 5 24 3 1 6 48 4 1 7 240 4 1 1 8 720 4 2 1 9 5040 4 2 1 1 10 10080 5 2 1 1 11 20160 6 2 1 1 12 221760 6 2 1 1 1 13 665280 6 3 1 1 1 14 8648640 6 3 1 1 1 1 15 17297280 7 3 1 1 1 1 16 294053760 7 3 1 1 1 1 1 17 5587021440 7 3 1 1 1 1 1 1 18 27935107200 7 3 2 1 1 1 1 1 19 642507465600 7 3 2 1 1 1 1 1 1 20 1927522396800 7 4 2 1 1 1 1 1 1 21 13492656777600 7 4 2 2 1 1 1 1 1 22 26985313555200 8 4 2 2 1 1 1 1 1 23 782574093100800 8 4 2 2 1 1 1 1 1 1 24 24259796886124800 8 4 2 2 1 1 1 1 1 1 1 - - - - - - - - - - - 2 3 5 7 11 13 17 19 23 29 31 ================================================================ There is no closed form expression for this. However, a more realistic goal is to have the ability to find the next larger element, $a_{n+1},$ in the list up to element $n,$ then the next one after that, and so on. This has been done. For general terminology, you want On Highly Composite Numbers by Jean-Louis Nicolas, pages 215-244 in a book called Ramanujan Revisited, edited by George Andrews et al, appearing in 1988. You may email me for a pdf. Then, the specific method is by his student Guy Robin, Methodes d'optimisation pour un probleme de theorie des nombres, R.A.I.R.O. Informatique theoretique 17, no. 3, 1983, pages 239-247. The reason it is possible to do such a thing is that highly composite numbers bear some resemblance to superior highly composite numbers. S.H.C. numbers have the basic feature, nonincreasing exponents, but in addition the ratios of the exponents for distinct primes $p \neq q$ must approximate the outcome of Ramanujan's recipe. Between consecutive S.H.C. numbers, one may find all the h.c. numbers as a sort of operations research problem. This is all, well, difficult. So it all depends on why this is important to you, and how important. The short version, meanwhile, is that you calculate the s.h.c larger than you current $a_n,$ calculate the h.c. numbers up that high, and take the smallest one that is a multiple of $a_n.$ If you need to go up an extra s.h.c number, so be it. Note that finding the first s.h.c number which is a multiple of your fixed number $a_n$ is entirely straightforward, as for any given $p^e,$ one may find the first (largest) $\delta > 0$ such that the s.h.c. number $N_\delta$ is divisible by $p^e.$ Do this for all primes that divide your fixed $a_n$ and there you have it.
1
Calculating s.h.c numbers as a sort of operations research problem
Equitably distributed curve on a sphere
Let $\gamma=\gamma(L)$ be a simple (non-self-intersecting) closed curve of length $L$ on the unit-radius sphere $S$. So if $L=2\pi$, $\gamma$ could be a great circle. I am seeking the most equitably distributed $\gamma(L)$, distributed in the sense that the length of $\gamma$ within any disk is minimized. This is something like placing repelling electrons on a sphere, but here the curve self-repels. So there should be no "clots" of $\gamma$ anywhere on $S$. I am especially interested in large $L$. A possible $\gamma$ is shown below, surely not optimal for its length:             Here is an attempt to capture more formally "equitably distributed." I find this an awkward definition, and perhaps there is a more natural definition. Around a point $c \in S$, measure the $r$-density of $\gamma$ as the total length within an $r$-disk: $$d_\gamma(c,r) = | \gamma \cap D(c,r)|$$ where $D(c,r)$ is the disk of geodesic radius $r$ centered on $c$. Then define $d_\gamma(r)$ as the maximum of $d_\gamma(c,r)$ over all $c \in S$. Finally, we can say that, for two curves $\gamma_1$ and $\gamma_2$ of the same length $L$, that $\gamma_1 \le \gamma_2$ if $d_{\gamma_1}(r) \le d_{\gamma_2}(r)$ for all $r \in (0,\pi)$, i.e., $\gamma_1$ is less concentrated than $\gamma_2$ for all $r$ up to a hemisphere. This definition provides a partial order on curves of a given length $L$. One version of my question is: Q. What do the minimal elements of this poset look like, especially as $L$ gets large? These minimal curves are in some sense nowhere densely clotted. Update. Acknowledging Gerhard Paseman's remark, I thought I would include this attractive image of a space-filling curve on a sphere:     (Image from this website). But notice it is certainly not equidistributed in any sense, crowding near the northpole.
I suppose one heuristic would be to find a shortest tour through uniformly distributed points on a sphere. The following image applies Mathematica's FindShortestTour command to $10000$ points generated by your own sphere command from Computational Geometry in C. We could also use more regularly distributed points to obtain a path that (I suspect) has better local properties. This image uses 5000 points generated by the algorithm described here. I don't know that I quite follow your $\gamma(L)$ function, but it might be something like an inverse of the function obtained by plotting the length $L$ as a function of the number of points input to this procedure.
0.777778
Mathematica's FindShortestTour command to $10000$ points
A Generic error occured in GDI+ in Image.Save() method
I'm trying to use this class but I'm getting a Generic error occured in GDI+ in Image.Save() method. From what I read it's some stream I need to close but I don't know which one. I'm calling using this: Image image = Image.FromFile(@"C:\a.jpg"); using (var resized = ImageUtilities.ResizeImage(image, 50, 100)) { //save the resized image as a jpeg with a quality of 90 ImageUtilities.SaveJpeg(@"C:\myimage.jpeg", resized, 90); } Why is that error and how do I solve this?
Unless your program is running as administrator you can not save directly to the root of C: make a folder and save it inside there instead.
0.888889
Unless your program is running as administrator
Is SourceSafe really safe?
Having spent all morning trying to check something in - I now realise I've lost a couple of days worth of work. Its happened before - and is apparently common occurrence with SourceSafe. Can SourceSafe be used successfully, without problems, and if so, how?
My view on VSS ? I declined a few job offers (very well paid) because they requested "VSS proficiency". And I am sure there is a couple of other people here who did the same.
0.888889
VSS proficiency ?
let you know a couple of facts OR bring couple of facts to your notice
Which of the following is more appropriate / polite? I would like to bring a couple of facts (or things?) to your notice. OR I would like to let you know a couple of facts. Please advise.
Whenever you are writing to someone it's really important to use words that sound polite. So it would be better sounding to the reader if you use "I would like to bring a couple of facts to your kind notice/attention".
1
Use words that sound polite to the reader
How do I find the area between two polar curves?
More specifically above r=6 and below r=4+4cos(θ) graph of the two curves PolarPlot[{6, 4 + 4 Cos[t]}, {t, 0, 2 Pi}]
We can use any one of the line integrals that by Green's Theorem yield the area: dA = RandomChoice[{x Dt[y], -y Dt[x], (x Dt[y] - y Dt[x])/2}] param = {x -> r Cos[θ], y -> r Sin[θ]}; boundary1 = {r -> 6}; boundary2 = {r -> 4 + 4 Cos[θ]}; θ0 = θ /. Solve[{Equal @@ (r /. {boundary1, boundary2}), -Pi < θ < Pi}, {θ}]; Integrate[dA /. param /. boundary2 /. Dt[θ] -> 1, Flatten[{θ, θ0}]] - Integrate[dA /. param /. boundary1 /. Dt[θ] -> 1, Flatten[{θ, θ0}]] // Simplify (* 1/2 (-y Dt[x] + x Dt[y]) 18 Sqrt[3] - 4 π *) Now this is an interesting bug result (the double integral in polar coordinates): Integrate[r, {r, θ} ∈ ImplicitRegion[6 <= r <= 4 + 4 Cos[θ], {r, θ}]] As Michael Siefert astutely pointed out, the problem is that the range of θ is assumed to be all reals. Restricting θ to one period of length 2 Pi gives the right answer: Integrate[r, {r, θ} ∈ ImplicitRegion[6 <= r <= 4 + 4 Cos[θ] && 0 <= θ <= 2 Pi, {r, θ}]] (* 2 (9 Sqrt[3] - 2 π) *)
1
Restricting to one period of length 2 Pi gives the right answer
How remove works for ArrayList while iterating using for-each loop?
I have a very basic question. I have created simple ArrayList and I am removing the item while iterating using for-each loop. It gives me java.util.ConcurrentModificationException because I can't remove an item while iterating but when I un-comment the if condition it works fine. Please can anybody explain me how for-each works in this way. ArrayList<String> list1 = new ArrayList<String>(); list1.add("Hello"); list1.add("World"); list1.add("Good Evening"); for (String s : list1) { //if (s.equals("World")) { list1.remove(1); //} } If I change it to list1.remove(2); or list1.remove(0); then also its working fine. Note: This is sample code and I know it will work fine using Iterator. My sole purpose of this question is to know how method remove() works perfectly if condition is un-commented no matter what index you are removing from the list.
You can also use an index-based removal. The drawback of this solution is that the list1.size() gets evaluated during every loop iteration. The positive thing is that removing an item from a List by its index is faster. for (int i = 0; i < list1.size(); /* i incremented in loop body */) { if ("World".equals(list1.get(i))) { list1.remove(i); } else { i++; } }
0.666667
removing an item from a List by its index is faster
Upload/Download File using REST or Web Services
Is it possible to Upload/Download a file using REST or any other Web Service and send HTML code? This has to be possible using: PHP, Java or ASP.
I think this will be helpful. At least when it comes to Java. Actualy, have a look at whole tutorial Here is an example how to do it by using Spring: Add commons-io and commons-fileupload dependencies to your pom.xml. Configure multipart resolver in your servlet context xml file: <beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <beans:property name="maxUploadSize" value="10000000" /> </beans:bean> This will be your JSP for upload of files (i.e. fileUpload.jsp): <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title></title> </head> <body> <form:form method="post" commandName="upload" action="uploadNewFile" enctype="multipart/form-data"> <table class="table table-bordered"> <tbody> <tr> <td><label>File</label></td> <td><input class="form-control" name="file" type="file" id="file" /></td> </tr> <tr> <td colspan="2"><input class="btn btn-primary" type="submit" value="Upload" /></td> </tr> </tbody> </table> </form:form> </body> </html> And this is controller: import java.io.IOException; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; @Controller public class UploadController { // Show page for upload @RequestMapping(value = "/fileUpload", method = RequestMethod.GET) public ModelAndView showUploadFilePage() { return new ModelAndView("fileUpload", "upload", null); } // Get multipart file and save it @RequestMapping(value = "/uploadNewFile", method = RequestMethod.POST) public String save(@RequestParam("file") MultipartFile file) { // Save it to i.e. database // dao.save(file); return "fileUpload"; } // Downloads file. I.e. JPG image @RequestMapping(value = "/download/{id}", produces = MediaType.IMAGE_JPEG_VALUE) public @ResponseBody HttpEntity<byte[]> getFile( @PathVariable("id") Integer id) throws IOException { byte[] file= dao.get(id).getImage(); HttpHeaders header = new HttpHeaders(); header.set("Content-Disposition", "attachment; filename=Image"); header.setContentLength(file.length); return new HttpEntity<byte[]>(file, header); } }
1
How to configure multipart resolver in a servlet context
What is the best way to modify entry data when submitting and updating entries
I am looking to modify a counter which is a field in a channel when i submit or update an entry. I am looking to count the number of matrix rows and then add that into the input field to act as the counter. What is the best way for me to do this? What hook should i use? And what files should i create? Thanks
First - you can get this count in your template by using {my_matrix_field:total_rows} - but I'll assume you need the number stored as a value in a field for other purposes (use in orderby perhaps). In which case - yes, you'd write an extension, and use the entry_submission_ready hook. Then in your method, pass $data by reference, so you can modify it. Check to make sure you're in the channel you're looking for, then dump the $data array so you can see how the data is structured. From there you can figure out how to count your Matrix rows, and then set the value of $data['field_id_XX'] (which would be your "counter" field). function entry_submission_ready($meta, &$data, $autosave) { if($meta['channel_id'] == XX) { // This is just to let you examine the data - you'd remove it after print_r($data); exit(); } }
0.888889
How to count Matrix rows in your template?
Will a site URL with repeating keywords get penalized by search engines?
I have an URL structure like the following: sitename.com/cellphone/nokia/galaxy-5678-nokia-cellphone-from-abc/ For more example: sitename.com/cellphone/motorolla/new-motorolla-gta800-cellphone-from-zxy/ The directory structure is like the cellphone is the main directory of the module and the words like Motorolla and Nokia are subdirectories which are categories and then comes the title of the cellphone. Here the word cellphone and Nokia in the first link and cellphone and Motorolla in the second link are repeated. Is it any kind of keyword stuffing? will it be penalized by Google?
It's important to note that there is no official number that is classed as keyword stuffing and every page/site is different. But in your example it's not a matter if its keyword stuffing or not. You should be making your URLs for your visitors and not the search engines. Your unnecessary repeating the words, words such as 'new' are stop words and you no need to repeat the manufacturer or cellphone since its mentioned before. sitename.com/cellphone/motorolla/new-motorolla-gta800-cellphone/ is exactly the same as: sitename.com/cellphone/motorolla/gta800/ Focus on Keywords and what the page is about. If its a review then you use: sitename.com/cellphone/motorolla/gta800-review/ If its about 10 reasons why the gta800 sucks then you use something like: sitename.com/cellphone/motorolla/10-reasons-why-not-to-buy-a-gta800/ Cater for your audience not the search engines. There is no need to repeat it more than once: it doesn't make it any more important. Google has many ways of establishing what the page is about, URL is just one indicator of many. As long as you have the main 'KEYWORD' or Keywords you want to rank then the rest don't matter. Use the title, H1 and meta description for more in depth information. Short URLs are preferred, not only because they have higher click rates but also they are better to link.
1
Keyword stuffing is not a matter if the gta800 sucks.
Quantity based discount for single product in Expresso Store
I'm using latest build of Expresso Store, 2.3.1. I need to apply quantity based discounts to products, but the discount needs to apply to a single product. For example: I have 10% off discount for all products in store when you order 10 or more of a single product, but the discount only applies to the particular product. So I order 11 of Product 1, 10 of Product 2 and 5 of Product 3. Products 1 and 2 will get the discount, product 3 will be full price. As far as I can see this is not possible in Store. If so are there any ways I can handle this in the template? As our discount will likely be pretty simple, with the same discount being applied store wide. Failing that, what are our options for extending Store to achieve this? Update: Just to clarify, we are looking to apply this discount at a category or store wide level, rather than updating the pricing of an individual product, as there are thousands of products this would not be viable, in particular as we will likely just have one percentage discount that is the same for all products.
We've just had the bulk discount configured to work with store 2.4 by another extension developer. You're right, it doesn't accept percentage discounts however you could easily use Datagrab to import the matrix fields all at once across any product range you wanted. I'm sure we could put you in touch with the developer that made the add on compatible with store 2 if you wanted...
1
bulk discount for store 2.4
What's the correct pronunciation of "epitome": "Epi-tome" or "Epi-tuh-mi"?
A friend said that epitome is pronounced as epi-tuh-mi and not epi-tome (with the tome like home). Who is right? Also, is the pronunciation purely dependent on the region where you learnt English?
Epitome comes from Greek but it was introduced in English via the Medieval French épitomé. It's now very rarely used in French, really found only in scholarly works. Note the acute accent at the end. This is why you pronounce it with an 'i'. For instance: Beauté => Beauty.
1
Epitome comes from Greek but introduced in English via the Medieval French épitomé
Is this a bug? Angular removes object params when corresponding input is not valid
Please see this: http://plnkr.co/edit/soubKCayeLAqgDOel8AL?p=preview <!DOCTYPE html> <html ng-app="testApp"> <head> <script data-require="[email protected]" data-semver="1.4.1" src="https://code.angularjs.org/1.4.1/angular.js"></script> <script src="script.js"></script> </head> <body ng-controller="testCtlr"> <pre>{{contacts | json}}</pre> <div ng-repeat="contact in contacts"> <div ng-repeat="email in contact.emails"> <input type="email" name="email" ng-model="email.email"> <input type="text" name="text" ng-model="email.text"> </div> </div> </body> </html> var app = angular.module('testApp', []); app.controller('testCtlr', ["$scope", function ($scope) { $scope.contacts = [ { id:'', name:'', emails:[ { email: 'e1', text: 'fghfgh' }, { email: 'e2', text: 'hjkhjk' } ], } ]; }]); you see if you change the text in the email text box it is removed from the obj unless it is a valid email...
Its not bug, its desired behaviourof angular, when value is not valid , it is not binded to ngModelController , https://docs.angularjs.org/api/ng/type/ngModel.NgModelController But there is possibility to attach custom email validator ($parsers) https://docs.angularjs.org/api/ng/type/ngModel.NgModelController#$parsers You can push parser to array of parser so it will be executed as last, and return modelValue so you will "override" angular validator and bind invalidValue to ngModel.
1
angular validator binds invalidValue to ngModelController
Solve for time, given distance and acceleration
Two gangsters are flying down I-70 West at a constant 108 hm/hr. If they make it to Indiana, they will be safe. When they are 1 km away from the Indiana border, while still traveling at a constant 108 km/hr, they pass a concealed police car hidden in a speed trap. At the instant that the criminals pass the patrol car, the cop pulls onto the highway and accelerates at a constant rate of 2 m/s^2. Does the cop catch up with them before they cross the state line? Here's what I have progressed so far ΔV = (ΔX)/(T) when V is velocity, X is distance, and T is time. 108 = (1 - 0)/T 108T = 1 T = 1/108 T = 0.00925 hours T = 0.00925 * 60 * 60 T = 33.33 seconds (this is the time it takes the gangsters to get to the borders of Indiana) What I am stuck at is the time it takes the cop to travel the same distance. I have used the distance formula to find time as follows: Xf = Xi + 1/2 * A * T^2 where A is acceleration Since the cop is starting from rest, the initial velocity is 0 (zero), so 1 = 0 + 1/2 * (2) * T^2 1 = T^2 T = 1 seconds So it takes the cop 1 seconds to travel the whole mile to Indiana? What am I doing wrong?
Converting the gangsters' speed to ms$^{-1}$, $108$ km/h $=108/3.6$ ms$^{-1} = 30$ ms$^{-1}$. The distance the cop travelled in time $t$ s is $\frac12at^2 = t^2$ metres, and the distance the gangsters travelled in time $t$ s is $30t$ metres. The time when they met the second time is $$\begin{align*}t^2 =& 30t\\t=&30\text{ seconds}\end{align*}$$ Then the distance they have travelled in $30$ seconds is $900$ metres, and this is before they arrive Indiana.
1
Converting gangsters' speed to ms$-1$, $108$ km/h
How can I check USB drive contents safely?
I would like to check the contents of a USB stick drive from a not-quite trusted source (my sister): is there a safe way to do this in OSX 10.9.5 or 10.10.1?
That's a good idea and a lot of malware depends on being able to write to where it is running from but it is not foolproof and if the O/S can read the drive then stuff can get off the drive. For the really paranoid I would be tempted to download and burn a LiveCD (Ubuntu or the like) that will boot your Mac. Boot it from the LiveCD and then examine the contents. You can then remove any potentially harmful Macintosh executables, Javascript or Flash exploits or infected files of other kinds. Though it will require a bit of technical savvy to do all of that.
1
Using a LiveCD to boot a Mac
Why are there so many different types of screws (phillps/flat/hex/star/etc)?
Newbie question. Why is it that there's a bazillion different types of screws? Why can't we just always use one standard screw type? Are there advantages/disadvantages to the different types? Are there times when one type is preferred over another? Help me understand why there isn't one screw to rule them all.
Shamelessly ripped off from here, looks like the primary reason why we still have "bad" screws (flat head and Phillips) is that the "better" types of screws are simply more difficult/expensive to manufacture: The reason for the different styles is cost and torque. The slotted head screws are cheap and easy to make. But they're completely useless for powered screwdrivers and you can't put much torque on the screw without it either slipping out or stripping the head (and maring the surface of whatever you're screwing). [Mad] Phillips screws are self-centering, making powered screwdrivers possible. They're somewhat more expensive to produce than slotted-head. They tend to 'cam-out' easily under torque, making it hard to apply much torque. I've heard they were designed that way to prevent overtightning. However, it's not good for exposed fasteners to look stripped. Robertson-head and allen-head fasteners can handle more torque than phillips-head fasteners, but are more expensive. Because the bottom of the hole is flat (unlike the pointed end of the phillips), there's more contact area and so it's less likely to cam-out. The robertson-head is cheaper than the allen-head, but the allen-head has six points of contact rather than 4, making it less prone to rounding out the hole. The Torx-head fasteners solve the problem of rounding/stripping by having the flat bottom of the robertson/allen that reduces cam-out, but it has much better contact with the driving bit to prevent stripping the head. The points of the 'star' on the driving bit engage the recesses on the screw at nearly right angles, so it has a very positive contact. Torx is becoming more and more popular because of that, particularly in assembly-line work. Because they're less likely than a phillips to be damaged when tightening, the allen (internal hex) heads are often used for exposed ('decorative') fasteners on 'some assembly required' furniture. It's also very cheap to make the allen keys, so they usually include one with the fasteners.
1
"bad" screws are more difficult to make than slotted head fasteners .
URLs with final slash trigger hotlink protection on my server
in all my Apache servers I use hotlink protection because I hate the idea someone could stick my images/flash in their sites using my server bandwidth. In order to make hotlink protection work, in my Apache .htaccess I simply use this: #Hotlink protection (only for www.domain.it cause http://domain.it is being redirected) RewriteCond %{HTTP_REFERER} !^http://www.domain.it/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.domain.it$ [NC] RewriteRule .*\.(wav|swf|jpg|jpeg|gif|png|bmp|js)$ - [F,NC] This works well, but I recently dicovered that when I ask for http://www.domain.com/somepage.htm/ (with final slash) the hotlink protection seems to be triggered and server stops page to download .(wav|swf|jpg|jpeg|gif|png|bmp|js) files Do you know how could I fix this in .htaccess??? Before today I even thought that the server should return an error if I enter as URL http://www.domain.com/somepage.htm/ (with final slash). But I saw it's normal because if you look for http://www.php.net/docs.php it returns the same page of http://www.php.net/docs.php/ (final slash). Why is that, could you explain me a bit?! Thanks
Are you sure it's the hotlink protection? If your website is laid out something like this: /somepage.htm /images/a.jpg Then if somepage.htm has relative paths to the image like <img src="images/a.jpg"> and you go to http://example.com/somepage.htm/, then your web browser will think it's in the "somepage.htm" directory and try to load the image http://example.com/somepage.htm/images/a.jpg. Apache will probably send you another copy of somepage.htm if you go there, which will cause your browser to show a broken image. I'm not sure if Apache has a setting to turn this off. It doesn't make much sense on plain HTML files but the reason Apache (and other servers) allow this is for sites that use "pretty URLs" (like serverfault's URLs!) where the URL extends past the actual file. There isn't a file on serverfault called "urls-with-final-slash-trigger-hotlink-protection-on-my-server", that's just there for people (and Google) to read. You can load this question just fine with http://serverfault.com/questions/197935 While I don't know how serverfault was made (there are many ways to do this) it's almost certain that there's no file named "197935" either. It's possible that there's a script named "questions" though, and the server could run that script, and the script would see the entire URL, look up the number in the database, and make this page.
1
Hotlink protection on serverfault?
How to remove a directory and its contents using NSFileManager
New to Objective C. I have created a few directories which contain pdf files for an iPhone app. How can I delete a directory and its contents using NSFileManager? Do I need to loop through and remove the contents first? Any code samples would be much appreciated. Thanks in advance.
To start off, it would be wise to look through Apple's NSFileManager documentation for the iPhone: NSFileManager Class Reference. Second, look at NSFileManager's -removeItemAtPath:error: method and its documentation. That's what you're looking for.
1
Apple's NSFileManager documentation for the iPhone
Anybody knows if there is a counterpart for CTR+w , that deletes immediate words after cursor
I mean when the cursor is on the left side of the words ,I would like to remove the words on the immediate right side of it . CTR+k remove everything on the right side, i only want one word to be removed.
In my bash shells, I hit ESC and 'd'.
0.888889
In my bash shell, I hit ESC and 'd'
More dissonant chords/intervals in the bass clef when frequency proprtions are the same?
Take for example C augmented. It sounds more consonant in the treble clef above middle C and more dissonant in the bass clef. However the proportions of the frequencies are exactly the same. This doesn't make any sense that it is more dissonant in the bass while the proportions are the same. Frequency proportions being the same should suggest the same amount of dissonance in every octave. So why are dissonant intervals and chords more dissonant in the bass clef and more consonant in the treble clef?
In general, smaller intervals do not sound as pleasing in a bass register as they do in a treble register. This is a general effect that occurs regardless of whether you play a consonance or a dissonance, although it is more noticeable with dissonances. What happens is that the overtones of the bass notes end up having more noticeable clashes between them, and those clashes are more audible because they are lower in pitch. When you are in a higher register, the clashing overtones occur at a much higher, and therefore less noticeable range. One way to get around this is to use a more open voicing. For example, instead of playing C-E-G#, try playing C-G#-E. Unfortunately, that's a tenth, and not playable for many left hands. This is why you often see widely-spaced arpeggios in the left hand of keyboard music. Playing closely-voiced chords in the bass often creates a very thick, heavy sound, sometimes described as "muddy".
0.777778
In general, smaller intervals do not sound as pleasing as in a treble register
Demonstrating the effect of aliasing
How does the signal look when we don't use the Nyquist rate to remove aliasing from a signal during sampling? Let's suppose the signal is sinusoidal, with a frequency of 500 Hz and an amplitude of 2. signal = 2*cos(2*pi*500*t) If I sample it, (replacing t=nTs , Ts = sampling period and n represent number of samples) and plotting the sampled signals with a different sampling period using the subplot command in MATLAB, how could I identify the aliasing in a sampled signal? Here is the example code that plotted two signals, one at the Nyquist rate while the other less than the Nyquist rate: A = 2; Fmax = 10; Fs = 2*Fmax; n = 0:1/Fs:1; Cont = A*sin(2*pi*(Fmax/Fs)*n); Cont1 = A*sin(2*pi*(Fmax/18)*n); subplot(2,1,1) stem(n,Cont) hold on stem(n,Cont1) and here is the waveform: I wasn't able to identify the aliasing. How did it affect the signal when Nyquist rate didn't use?
You can't identify aliasing with a simple sinusoid at a specific frequency and that in a way is the whole point about trying to avoid it. You can't know if the sinusoid you are "looking at" is $Q$ Hz or $2Fs-Q$Hz. A single aliased sinusoidal component looks just like a non-aliased sinusoid. If you want to experience aliasing, you have to attempt it with either a more complex waveform or a sinusoid that is changing in time. One way to "experience aliasing" is to undersample a chirp in the following way: Fs = 8000;t=0:(1./Fs):(5-1./Fs);p=2.*pi.*t; %Sampling Frequency, Time Vector, Phase Vector y1 = chirp(t,0,5,Fs/2.0); %Create a chirp that goes from DC to Fs/2.0 spectrogram(y1); %Have a look at it through spectrogram, please pay attention at the axis labels. This is basically going to be a "line" increasing with time. soundsc(y1,Fs); %Listen to it...It clearly "goes up" in frequency y2 = chirp(t,0,5,Fs); %Now create a chirp that goes from DC to Fs spectrogram(y2); %Have a look at it through spectrogram soundsc(y2,Fs); %Listen to it...Do you "get" the folding of the spectrum? In general, you can think of Sampling as Modulation because this is what is effectively happening at the sample and hold element of an ADC converter. This will enable you to understand more easily concepts like undersampling for example (and applications where it is perfectly OK to sample at lower than the Nyquist rates). But also, you can load a WAV file in MATLAB (with 'wavread') containing some more complex signal and prior to listening to it with 'soundsc', simply multiply it with a "square" wave* (you might want to lookup function 'square') at some frequency lower than the WAV file's $F_s$. This will effectively introduce the key (unwanted) characteristic of aliasing which is this folding of the spectrum. The result is not very pleasant so you might want to keep your speakers volume down. I hope this helps. *EDIT: Obviously, "square" returns a square with an amplitude in the interval [-1,1] so prior to multiplying it with your signal it would be better to rescale it as: aSquareWave = (square(100.*p)+1.0)/2.0 % Where p is the phase vector and here we are producing a square wave at 100Hz (given an Fs of 8kHz as above). aSquareWave's amplitude is now in the interval [0,1]
1
aliasing with a sinusoid at a specific frequency
What is it called when a music has two concurrent tempos
I've recently watched a BBC documentary about the history of music and recall an episode where they talk about music that has two distinct tempos (and possibly time signatures) at the same time for different sets of instruments. Still, I can't remember how this is called and who are the famous composers that composed that way (Stravinsky?).
The answer here is deceptively simple: Polytempo. There are other names, such as multi-tempo, polytemporal, and others, but they all describe the same phenomena. Here is a link for further reading on Wikipedia. For a list of composers that have used this technique, as well as the pieces in which this technique was used, check out this page and look under "Compositions". I want to clarify for everyone that Polyrhythm and Polymetric are both incorrect here. Polyrhythms are multiple, independent rhythmic lines (typically ostinatos) that can form a hemiola or hemiola-like effect in music. Polymeters are ways of organizing the beat. Tempo is the speed of the beat, not how it is organized, or the rhythms that it defines. Here is a wonderful Q/A from this very website that addresses the difference: Polymeter vs Polyrhythm
1
Polyrhythm vs Polyrhythm
Why do direct limits preserve exactness?
I've heard that taking direct limits is an exact functor in the category of modules, and I'm trying to figure out why, as I couldn't find a proof. Suppose you have homomorphisms $\varphi_i: K_i\to N_i$ and $\psi_i: N_i\to M_i$ for $(K_i,h^i_j)$, $(N_i,g^i_j)$, and $(M_i,f^i_j)$ directed systems of modules such that $0\to K_i\to N_i\to M_i\to 0$ is exact for every $i$. Why is $0\to\varinjlim K_i\to\varinjlim N_i\to\varinjlim M_i\to 0$ also exact? So I let $\varphi:\varinjlim K_i\to\varinjlim N_i$ and $\psi:\varinjlim N_i\to\varinjlim M_i$ be the natural homomorphisms. Take $x\in\ker\psi$. Then $x=g^i(x_i)$ for some $x_i\in N_i$. Then $0=\psi(g^i(x_i))=f^i(g^i(x_i))$. I know there exists some $j\geq i$ such that $f^i_j(g^i(x_i))=0$ in $M_j$. But $f^i_j\circ\psi_i=\psi_j\circ g^i_j$, so $g^i_j(x_i)\in\ker\psi_j=\text{im}(\varphi_j)$. Then $g^i_j(x_i)=\varphi_j(y_j)$ for some $y_j\in K_j$, so $$ x=g^i(x_i)=g^j(g^i_j(x_i))=g^j(\varphi_j(y_j))=\varphi(h^j(y_j)) $$ and so $\ker\psi\subseteq\text{im}\varphi$. Conversely, suppose $x\in\text{im}\varphi$. Then $x=\varphi(y)$ for some $y=h^i(y_i)$ and $y_i\in K_i$. So $x=\varphi(h^i(y_i))=g^i(\varphi_i(y_i))$. Thus $$ \psi(x)=\psi(g^i(\varphi_i(y_i)))=f^i(\psi_i(\varphi_i(y_i)))=0 $$ since $\psi_i\circ\varphi=0$. Then $\ker\psi=\text{im}\varphi$. (Please let me know if I've written nonsense, too many maps can cause me to get lost!) What is bugging me is, is $\varphi$ injective and $\psi$ surjective to see that the short exact sequence is in fact exact? Is there some obvious fact I'm missing? If possible, is there an explanation in the same vein as the above (i.e. using the maps and manipulating the elements without relying on more general facts from category theory? I'm not too knowledgeable about the latter.) Thanks.
It suffices to show that if $K_i\to M_i\to N_i$ is exact at $M_i$ for each $i$ (and the appropriate squares commute), then $\varinjlim K_i\to \varinjlim M_i\to \varinjlim N_i$ is exact at $\varinjlim M_i$. (To get that $\varinjlim$ sends short exact sequences to short exact sequences from this, simply apply the argument to $0\to K_i\to M_i$, exact at $K_i$; to $K_i\to M_i\to N_i$; and then to $M_i\to N_i\to 0$). Call the first map $f_i$ (with induced map of limits $f$), the second $g_i$ (with induced map $g$); use $\kappa$, $\mu$, and $\nu$ for the structure maps. Given $[(k,i)]$, we have $g(f([(k,i)])) = g([f_i(k),i]) = [g_i(f_i(k)),i] = [0,i]$, so the composition is trivial. That is, $\mathrm{Im}(f)\subseteq \mathrm{Ker}(g)$. Now assume that $g([(m,i)]) = [(0,j)]$. Then there exists $t\geq i$ such that $\nu_{it}(g_i(m)) = 0$; hence $g_t(\mu_{it}(m)) = 0$, so by exactness of the original diagram we know that there exists $k\in K_t$ such that $f_t(k) = \mu_{it}(m)$. Therefore, $$f([k,t]) = [(f(k),t)] = [(\mu_{it}(m),t)] = [(m,i)],$$ so $[(m,i)]$ lies in the image of $f$. Thus, $\mathrm{Im}(f)\supseteq \mathrm{Ker}(g)$, proving equality. Now, this proves that $\varinjlim$ is exact; as to "why" it is exact (is there some deep why it is exact)? I don't know if I can answer.
0.888889
Why is $varinjlim$ exact at $M_i$ for each $i$
Why doesn't Owen Lars recognize C-3PO during ANH?
As shown in this answer, Owen and Beru Lars should be very familiar with C-3PO (he stayed with Shmi Skywalker till her death, and was present at her funeral). Yet, Lars (not sure if Beru saw him during ANH) never recognizes C-3PO in the first part of A New Hope, despite presumably having lived with him during the time of Shmi Skywalker's marriage to Cliegg Lars. Is there a canon explanation for Owen's lack of recognition? (related: How come Obi-Wan doesn't remember R2D2 and C3P0 in New Hope? )
3PO droids were pretty common. It's quite possible that he just never imagined that of all the 3PO droids in the universe, C-3PO would end up being sold to him by Jawas 22 years later. Not being recognized by C-3PO probably didn't help. Adding to this is the fact that C-3PO never identifies himself as such to Owen. OWEN: I have no need for a protocol droid. THREEPIO: (quickly) Sir -- not in an environment such as this -- that's why I've also been programmed for over thirty secondary functions that... OWEN: What I really need is a droid that understands the binary language of moisture vaporators. THREEPIO: Vaporators! Sir -- My first job was programming binary load lifter...very similar to your vaporators. You could say... OWEN: Do you speak Bocce? THREEPIO: Of course I can, sir. It's like a second language for me...I'm as fluent in Bocce... OWEN: All right shut up! (turning to Jawa) I'll take this one. THREEPIO: Shutting up, sir. OWEN: Luke, take these two over to the garage, will you? I want you to have both of them cleaned up before dinner. It is not until Luke has taken both of the droids to the garage to clean them up that either of the droids are identified by name to any of them. (note that this version omits the line where Owen asks C-3PO if he is a protocol droid, but that is present in this version of the draft).
0.888889
C-3PO never identifies himself as such to Owen .
.xlsx and xls(Latest Versions) to pdf using python
With the help of this .doc to pdf using python Link I am trying for excel (.xlsx and xls formats) Following is modified Code for Excel: import os from win32com import client folder = "C:\\Oprance\\Excel\\XlsxWriter-0.5.1" file_type = 'xlsx' out_folder = folder + "\\PDF_excel" os.chdir(folder) if not os.path.exists(out_folder): print 'Creating output folder...' os.makedirs(out_folder) print out_folder, 'created.' else: print out_folder, 'already exists.\n' for files in os.listdir("."): if files.endswith(".xlsx"): print files print '\n\n' word = client.DispatchEx("Excel.Application") for files in os.listdir("."): if files.endswith(".xlsx") or files.endswith('xls'): out_name = files.replace(file_type, r"pdf") in_file = os.path.abspath(folder + "\\" + files) out_file = os.path.abspath(out_folder + "\\" + out_name) doc = word.Workbooks.Open(in_file) print 'Exporting', out_file doc.SaveAs(out_file, FileFormat=56) doc.Close() It is showing following error : >>> execfile('excel_to_pdf.py') Creating output folder... C:\Excel\XlsxWriter-0.5.1\PDF_excel created. apms_trial.xlsx ~$apms_trial.xlsx Exporting C:\Excel\XlsxWriter-0.5.1\PDF_excel\apms_trial.pdf Traceback (most recent call last): File "<stdin>", line 1, in <module> File "excel_to_pdf.py", line 30, in <module> doc = word.Workbooks.Open(in_file) File "<COMObject <unknown>>", line 8, in Open pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Excel ', u"Excel cannot open the file '~$apms_trial.xlsx' because the file format or f ile extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.", u'xlmain11.chm', 0, -21468 27284), None) >>> There is problem in doc.SaveAs(out_file, FileFormat=56) What should be FileFormat file format? Please Help
You can print an excel sheet to pdf on linux using python. Do need to run openoffice as a headless server and use unoconv, takes a bit of configuring but is doable You run OO as a (service) daemon and use it for the conversions for xls, xlsx and doc, docx. http://dag.wiee.rs/home-made/unoconv/
1
Excel sheet to pdf on linux using unoconv
How to encode factors as dummy variables when using stepPlr?
When using the step.plr() function in the stepPlr package, if my predictors are factors, do I need to encode my predictors as dummy variables manually before passing it to the function? I do know that I can specify "level", but how the "level" parameter works is confusing to me. My understanding is that I need to tell step.plr() explicitly which factors should be encoded as dummy variables and thus leaving one factor out intentionally. Let's consider a simple example. Suppose I have 1 categorical predicator with 4 levels and binary response. Normally, if I use glm() to fit a logistic regression model, glm() would automatically convert the categorical predicator into 3 dummy variables. Now in stepPlr(), do I specify the "level" parameter for that predictor with 4 levels or 3 levels? The "Help" section is vague, and says: If the j-th column of x is discrete, level[[ j ]] is the set of levels for the categorical factor. Does it mean I should tell step.plr() about all 4 levels, or I should make an intelligent decision myself and tell step.plr() to use only 3 levels? ==============UPDATE (16 Oct 2012)============= The following example will demonstrate what is the problem with step.plr()'s automatic dummy variable encoding. It is a slight modification of the code in the function's help section. set.seed(100) n <- 100 p <- 3 z <- matrix(sample(seq(3),n*p,replace=TRUE),nrow=n) x <- data.frame(x1=factor(z[ ,1]),x2=factor(z[ ,2]), x3=factor(sample(seq(3), n, replace=TRUE, prob=c(0.2, 0.5, 0.3))), x4=factor(sample(seq(3), n, replace=TRUE, prob=c(0.1, 0.3, 0.6)))) y <- sample(c(0,1),n,replace=TRUE) fit <- step.plr(x,y, cp="aic") summary(fit) And here's an excerpt of the result: Call: plr(x = ix0, y = y, weights = weights, offset.subset = offset.subset, offset.coefficients = offset.coefficients, lambda = lambda, cp = cp) Coefficients: Estimate Std.Error z value Pr(>|z|) Intercept 0.91386 5.04780 0.181 0.856 x4.1 1.33787 4.61089 0.290 0.772 x4.2 -1.70462 4.91240 -0.347 0.729 x4.3 0.36675 3.18857 0.115 0.908 x3.1:x4.1 7.04901 14.35112 0.491 0.623 x3.1:x4.2 -5.50973 15.53674 -0.355 0.723 x3.1:x4.3 -0.50012 7.95651 -0.063 0.950 You can see that all levels, that is, (1,2,3), are used to fit the model. But normally you only need two dummy variables to encode a predictor with 3 levels. On the other hand, if you use glm(): glm(y~.^2, data=x, family=binomial) you will get the correct dummy variable encoding.
See the first example given in help for step.plr n <- 100 p <- 3 z <- matrix(sample(seq(3),n*p,replace=TRUE),nrow=n) x <- data.frame(x1=factor(z[ ,1]),x2=factor(z[ ,2]),x3=factor(z[ ,3])) y <- sample(c(0,1),n,replace=TRUE) fit <- step.plr(x,y) # 'level' is automatically generated. Check 'fit$level'. Does that answer your question?
0.888889
Step.plr n <-
What is the best introductory Bayesian statistics textbook?
Which is the best introductory textbook for Bayesian statistics? One book per answer, please.
Take a look at "The Bayesian Choice". It has the full package: foundations, applications and computation. Clearly written.
0.777778
"The Bayesian Choice" has the full package: foundations, applications and computation