summary
stringlengths
15
147
text
stringlengths
1
19.3k
answer
stringlengths
32
22.6k
labels
float64
0.33
1
answer_summary
stringlengths
5
164
How do I deal with a compromised server?
I suspect that one or more of my servers is compromised by a hacker, virus, or other mechanism: What are my first steps? When I arrive on site should I disconnect the server, preserve "evidence", are there other initial considerations? How do I go about getting services back online? How do I prevent the same thing from happening immediately again? Are there best practices or methodologies for learning from this incident? If I wanted to put a Incident Response Plan together, where would I start? Should this be part of my Disaster Recovery or Business Continuity Planning? This is meant to be a canonical post for this topic. Originally from serverfault.
You could try chmod on them if you have su access. They may be disabled for your users permissions. If you chmod 777 it will give permission for all users then you could try rm them. If this does not work i would suggest refreshing the systems if it is not too much messing about as they may be hiding deeper in the filesystem. You could also try a chkrootkit to see if there is any underlying files still left but i would rather be safe than sorry. Hope this helps
0.888889
You could try chmod on them if you have su access .
Array Binding simple example doesn't work
I'm very new to xaml and I'm trying to understand the Binding issue. I have a problem with the Array Binding. I created this very simple example: I have a stack panel with three images. Each image has a RotationTransform. Each Angle is obtained by an array element (the array is a DependencyProperty called Rotations). This is the xaml simple file: <StackPanel Orientation="Vertical"> <Image Source="/Assets/knife.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5"> <Image.RenderTransform> <RotateTransform Angle="{Binding ElementName=pageRoot, Path=Rotations[0], Mode=OneWay}"/> </Image.RenderTransform> </Image> <Image Source="/Assets/fork.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5"> <Image.RenderTransform> <RotateTransform Angle="{Binding ElementName=pageRoot, Path=Rotations[1], Mode=OneWay}"/> </Image.RenderTransform> </Image> <Image Source="/Assets/spoon.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5"> <Image.RenderTransform> <RotateTransform Angle="{Binding ElementName=pageRoot, Path=Rotations[2], Mode=OneWay}"/> </Image.RenderTransform> </Image> <Button x:Name="actionButton" Content="Try Binding!" Click="Op_Click"/> </StackPanel> And this is my c# class: public sealed partial class MainPage : Page { public static readonly DependencyProperty RotationsProperty = DependencyProperty.Register("Rotations", typeof(double[]), typeof(MainPage), new PropertyMetadata(new double[3])); public double[] Rotations { get { return (double[])GetValue(RotationsProperty); } set { SetValue(RotationsProperty, value); } } private void Op_Click(object sender, RoutedEventArgs e) { Rotations[0] = 180; Rotations[1] = 130; Rotations[2] = 350; } public MainPage() { this.InitializeComponent(); Rotations[0] = 20; Rotations[1] = 90; Rotations[2] = 180; } } The binding works only the first time (at startup time). When I click on the button (changing the Rotations array) the binding doesn't work and it is completely ignored from my images. This is a very simple example, so it's clear that I miss something concerning the Binding issue.
Ok, I found a solution using ObservableCollection: the xaml file remains the same, but the c# class changes this way: public sealed partial class MainPage : Page { public static readonly DependencyProperty RotationsProperty = DependencyProperty.Register("Rotations", typeof(ObservableCollection<double>), typeof(MainPage), new PropertyMetadata(new ObservableCollection<double>())); public ObservableCollection<double> Rotations { get { return (ObservableCollection<double>)GetValue(RotationsProperty); } set { SetValue(RotationsProperty, value); } } private void Op_Click(object sender, RoutedEventArgs e) { Rotations[0] = 180; Rotations[1] = 180; Rotations[2] = 320; } public MainPage() { this.InitializeComponent(); Rotations.Add(90); Rotations.Add(90); Rotations.Add(90); } }
0.888889
Public sealed partial class MainPage : Page
What role is a "Heavy" supposed to fill?
Based on the name and my understanding of the TF2 class, a Heavy is a front-lines tanky soldier guy. But that doesn't really seem to be his role in XCOM. Assault soldiers are better at being in the front lines with their mobility and defensive abilities. What, then, is the heavy supposed to be doing on the battlefield? What are the general strategies that are useful for heavy soldiers?
Hello just reading through all the above and realized that my play style is quite different from most people that have answered this question. Heavies are by far what I call as close as possible to the X-COM the original in the fight against the giant single eye @ Cydonia: You had an inventory grid and I would just cram the soldier with heavy plasma on 1 hand with extra clips, psi amp on the other hand, blaster launcher in back pack, 1st blaster ammo in the back pack, 2nd & 3rd bomb ammo in the belt, an electro flair, and the rest with as many alien grenades and proximity grenades, and the flying suit. So to mimic the original X-COM I built my heavy with the following skills: shredder rocket and 1 more rocket giving it a total of 3 blaster bombs. I gave the heavy grenadier for 2 alien grenades, if only there were prox grenades. Bullet swarm to mimic auto shot, and rapid reaction - kinda like saving time units for snap shot and just sit in the corners waiting for aliens at the base. I debated between psi suit vs. archangel suit vs. titan vs. ghost for psi ready soldiers and after some playing around, in the end I went for ghost suit. Ghost suit is just too good as you run as far as u can without triggering the enemy to move, and on the next turn I'd have so many opening moves to choose from: bullet swarm or mind control for single enemies when they are close by, grenade if their clustered but too close to friendlies, or blaster if i can hit a lot without hurting friendlies. This was so good I decided to have 4 heavies like this. All 3 heavies go cloak, run in and surprise fireworks. Now the good thing about running into the enemies with ghosted heavies is that you can mind control them and before the control wears off group them up and grenade/blaster bomb em to death or even use their own grenades on em while clustered. So my heavies are the front of the line. I usually go with 4, followed by 2 medics for health patch up. In the end game, it was mandatory to have one of my heavy's go with psi suit as a volunteer, but now I know it's not needed to have the highest will power soldier to finish the game. Although that heavy was kinda fun with 3 blaster bombs and rift. I'd take ghost armor any time. 4 ghosting blaster heavies is a total of 12 blaster bombs per mission, so blasting fun (just remember by late game you have everything you want and you don't need to worry about the loot).
1
heavies are what I call as close as possible to the original X-COM .
Applying OO patterns and principles to plugin development
I'm busy writing my first plugin, using PHP 5.3.5. I come from a C# environment, and I must say I'm more than happy with the level of support for good, solid OOP techniques in PHP. However, I'm a little uncertain how to structure a plugin using classes. I have a plugin class that takes care of hook registration in its constructor, and some worker classes like a mail queue and mailer, but I have one or two non-class scripts, mostly for forms, that I don't quite know how to neatly fit into classes. What resources are their I can consult for guidance on this aspect of my OO plugin? The plugin is for mass mailing, i.e. mailing to all subscribers, on schedule etc. It registers a custom post type for mail templates, with add new and edit capabilities, and it adds its own menu to the bottom of the admin menu, currently with two submenu pages: 'settings' and 'send mail'. It also adds an 'opt out' option to the user profile page, but that's quite tidy and easy to include the main plugin class.
I have one or two non-class scripts, mostly for forms, that I don't quite know how to neatly fit into classes. Split your project into multiple classes. Keep your worker classes as instantiable objects (typical OOP patterns) and put your non-class scripts into a class of their own as static scripts. I often use static PHP classes to namespace my code this way. Example: class My_Object { public $variable = 1; public function __construct() { // Constructor } public function do_something() { // Misc. method for the object $this->variable++; } } static class Helper { public static function Run_Script() { // Function that does something and doesn't belong in a class } } The difference between these two classes is that you instantiate one (My_Object) and use it as an object. The other is basically a namespace wrapper for a function that doesn't belong in an object but that also doesn't belong in the global namespace. Let's say you started with just a regular Run_Script() method in your plugin ... then later down the road, another developer adds a Run_Script() method to another plugin. You now have a name conflict. Keeping your standalone functions inside a static class helps prevent this. Just call Helper::Run_Script() to access it. What resources are there I can consult for guidance on this aspect of my OO plugin? Basically, look at what others have done. There are quite a few quality plugins out there that follow this kind of a pattern. So take a look at how others have tackled the problem and learn from their example. GitHub is a great place to look at code. Most of my plugins are up there, so you can browse through code files to view the structure without needing to download them and install them. Some good developers on GitHub that you should follow for more examples: Michael Fields Austin Passy Cristi Burca Me (Shameless self-plug)
1
How to namespace non-class scripts into multiple classes?
How do I set IntelliJ to place xml tags on separate lines when formatting xml files?
I'm using IntelliJ IDEA 12. I've used the context menu to import some pom.xml maven dependencies. However, when I view the POM file, the dependencies are not formatted nicely--they are in a single line. When I reformat the pom file (Ctrl-Alt-L) the formatting is still not fixed. I tried looking at Project Settings > code style > XML, but I couldn't see an obvious setting that would fix this. I fiddled with "keep line breaks" and "wrap text" settings, but to no avail. I have noticed that other XML files have the same issue--if I join them, formatting won't break them apart. How can I get IntelliJ to intelligently break xml across multiple lines, with proper indentation?
Uncheck the option "keep white spaces" in the settings. In IDEA 12, File > Settings > Code Style (left menu panel) > XML (left menu panel) > Other (tab) > Keep White Spaces (checkbox)
0.888889
Uncheck the option "keep white spaces" in settings
Just found out my internet was routing through a proxy, how screwed am I?
I checked my internet setting today and it seem that everything has being going through some proxy server for the last few weeks. How screwed am I? Could they get my internet login password? All my files on Dropbox? I buy things online too, is my credit card compromised? EDIT: The IP of the proxy is 85.214.85.193, but on my other computer which was also proxied the IP was something different (I forgot to write it down).
This all depends on the proxy itself. A proxy intercepts, and redirects. Everything going towards the Internet was intercepted, but it doesn't mean that all was readable. When you log into certain sites (banks, to buy something) most use SSL which means that, unless the proxy was intercepting with a trusted certificate, most data would be encrypted. If in the event the proxy intercepted SSL, and was capable of forging a certificate, or making you believe a certificate was trusted, then you're data is readable. You would have gotten a certificate error via your browser: "Warning this site uses an untrusted certificate..." Can you elaborate more on the proxy server. E.g. the IP (if possible). Some ISPs use proxies (rare) to cache and provide content quicker. ADDED The IP space belongs to Strato in Germany http://bgp.he.net/net/85.214.0.0/15#_whois and is listed in a lot of "free proxy" like sites. The bigger question for you is, how did your machine manage to get proxied in the first place. This is likely caused by some form of malware that made its way onto your machine if you did not configure that proxy. As noted, SSL could have been stripped so that is something to take into consideration. Personally, I would try and determine how my machine got compromised, I would clean it up, preferably re-install from a clean source, then go and change all my passwords AFTER the fact I cleaned up. (Makes no sense to type much via way of credentials when you don't know what's on your machine)
0.888889
How did your machine get proxied in the first place?
Real norms on vector spaces over finite fields
I am interested in functions of the form $\psi: F^n \to \mathbb{R}^+$, where $F$ is a finite field, that have norm-like properties, e.g., $\psi(x+y) \le \psi(x) + \psi(y)$. Does anybody know if there is any literature on this area?
The triangle inequality might allow some interesting functions, but positive homogeneity doesn't. A finite field has a prime characteristic, $p$. Positive homogeneity says $\psi(rx)=|r|\psi(x)$ for $r\in\mathbb{Q}$. To satisfy this property, $\psi(0)=\psi(px)=p\psi(x)$, which first says $\psi(0)=0$ and then $\psi(x)=0$ for all $x\in F$.
1
A finite field has a prime characteristic, $p$, but positive homogeneity doesn't
Is there a word for "rule by criminals"?
Is there a word for "rule by criminals"? Not kleptocracy, which is rule by thieves, but more broadly by criminals.
You may be interested in kakistocracy, definition from Wiktionary: Government under the control of a nation's worst or least-qualified citizens.
1
kakistocracy: Government under the control of a nation's worst or least-qualified citizens
Extracting useful information from free text
We filter and analyse seats for events. Apparently writing a domain query language for the floor people isn't an option. I'm using C# 4.0 & .NET 4.0, and have relatively free reign to use whatever open-source tools are available. </background-info> If a request comes in for "FLOOR B", the sales people want it to show up if they've entered "FLOOR A-FLOOR F" in a filter. The only problem I have is that there's absolutely no structure to the parsed parameters. I get the string already concatenated (it actually uses a tilde instead of dash). Examples I've seen so far with matches after each: 101WC-199WC (needs to match 150WC) AAA-ZZZ (needs to match AAA, BBB, ABC but not BB) LOGE15-LOGE20 (needs to match LOGE15 but not LOGE150) At first I wanted to try just stripping off the numeric part of the lower and upper, and then incrementing through that. The problem I have is that only some entries have numbers, sometimes the numbers AND letters increment, sometimes its all letters that increment. Since I can't impose any kind of grammar to use (I really wanted [..] expansion syntax), I'm stuck using these entries. Are there any suggestions for how to approach this parsing problem?
The only pattern I can see is that you have either letters followed by digits, or digits followed by letters, or letters only. From this point, the first step would be to separate the string into the beginning and the end, then to separate each part into a group of one or two entities: "AB12-ZZ789" β†’ ["AB12", "ZZ789"] β†’ [["AB", "12"], ["ZZ", "789"]] The numeric entities can be then converted to numbers: [["AB", "12"], ["ZZ", "789"]] β†’ [["AB", 12], ["ZZ", 789]] Then, letters can be converted to their respective numeric representation. For example, if "A" is mapped to 0, "B" - to 1, etc., "AB" is 0 Γ— 26 + 1, while "ZZ" is 25 Γ— 26 + 25. [["AB", 12], ["ZZ", 789]] β†’ [[26, 12], [675, 789]] Once you do this conversion, it's pretty simple to know if the value is in a range. For example, "HC52" β†’ ["HC", "52"] β†’ ["HC", 52] β†’ [(7 Γ— 26 + 2), 52] β†’ [184, 52] 26 ≀ 184 ≀ 675 and 12 ≀ 52 ≀ 789, so the value is in the range. "HC999" β†’ ["HC", "999"] β†’ ["HC", 999] β†’ [(7 Γ— 26 + 2), 999] β†’ [184, 999] 26 ≀ 184 ≀ 675, but (12 ≀ 999 ≀ 789) is false, so the value is outside of the range.
1
Numeric entities can be converted to numbers
struts2+spring3: passing a variable from action to jsp (javascript code)
First of all, thank you very much to all these that are trying to solve our problems in this forum;) I am developing a web application with struts2+spring3. And I have a question about how to pass a variable (an array of arrays) from the action class to the jsp page. I know that the only you need to do is to declare a private variable in my action and a get method for that variable and then its possible to access these variable from the jsp, I have done it and it works. public class Workspace extends ActionSupport { private String[][] objects=null; public String[][] getObjects() { return objects; } public String execute() throws Exception{ The problem is that I want to access to this variable from the javascript code before loading the whole web page. I have tried by different ways but it is never working. $(function() { var objectsMap=new Array(); $(document).ready(function() { objectsMap = $objects; }); neither works (the alert says: "Value: undefined"): <s:set name="auxObj" value="%{objects}"/> <script> alert("Value: "+$("#auxObj").val()); </script> Anyone have idea about how could I do that? Thank you very very much!
Thank you people, It works finally, I type the code here for in case is useful for other one: var $linesMap=new Array(); $(document).ready(function() { var $arr; <s:iterator value="objects" var="item" status="stat"> $arr=new Array(); <s:iterator value="item" var="item2" status="stat2"> $arr.push(['${item2[0]}','${item2[1]}']); </s:iterator> $linesMap.push($arr); </s:iterator> }); Then I can use $linesMap in the javascript code :) Thank you very much, Aleix
0.888889
var $linesMap=new Array()
Calculating coordinates with postscript
I want to calculate coordinates for some lines using pstricks. How can I do this? Example: I want something like (0.5*cos(45) + 8, 0.5*sin(45) + 8) and use coordinate pairs like this one to draw lines in between.
It isn't clear if you want to do the calculation in TeX or PostScript, in PostScript that would be 0.5 45 cos mul 8 add 0.5 45 sin mul 8 add as you can check by typing to gs (or any other PostScript interpreter): GS>0.5 45 cos mul 8 add 0.5 45 sin mul 8 add pstack 8.35355377 8.35355377 GS<2>
1
Calculation in TeX or PostScript
Hostname resolution in a machine with multiple running eth ports
Consider a machine having 4 eth ports running on it. Then to which eth port's ipaddress will the hostname resolve to? Kindly guide me to some documentation to support your answers so that I could use them as proof in my project. Thanks
You don't mention which brand of Linux you're using. RedHat (and Centos, and perhaps even Fedora) uses the /etc/sysconfig/network file to determine the host's name. Then, using the host's name, it determines the IP address of the host using the normal naming system (as given in /etc/resolv.conf), which in practice means that you should have an IP-to-name mapping in /etc/hosts. The IP addresses are associated to the NICs in /etc/sysconfig/network-scripts/ethX, where X is an integer (0, 1, 2, and 3 in your case). See http://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-sysconfig-network.html and Ch03:_Linux_Networking">http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:Ch03:_Linux_Networking ...and http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-networkscripts.html
1
Using the host's name, it determines the IP address of the host using the normal naming system
How to i update an iPhone 4 with iOS 4.3.5 offline
i was able to update my iPhone 4S and iPad via the option on the settings menu however i iPhone 4 which i use as my music player doesn't have that option, my computer with itunes doesn't connect to the internet so i can't download it via itunes i am wondering if there is an offline installer i can download that itune can detect to use, that way i can download it on a separate computer then transfer it to my main computer
There exists direct download links for the restore images that you can download from one computer and use for the restore on your own computer, however you will still need an internet connection for the final part of the installation (iTunes needs to verify with Apple servers). Once you have the .ipsw file on your computer, hold down ⌘ Command (or control if on a PC) while clicking 'Update' in iTunes, and select the .ipsw file for your iPhone.
1
iTunes needs to verify with Apple servers .
How to turn off Twitter's Suggestions for you / Who(m) to follow?
I am looking for a method/option to remove the new Twitter's suggestions feature. Assuming it works in a similar fashion to Facebook ... if I keep hiding users ... will it eventually go away ?
If you're using Firefox, a custom CSS for twitter.com to hide <div id="recommended_users"> should work. Updated: Or just use this script: http://userscripts.org/scripts/review/83086
1
CSS to hide <div id="recommended_users"
Redirecting users to referrer page after logging in using custom login form
I am using a custom wordpress login form using the following code. I have this form in the sidebar of my site: <?php if ( ! is_user_logged_in() ) { // Display WordPress login form: $args = array( 'redirect' => admin_url(), 'form_id' => 'loginform-custom', 'label_username' => __( 'Username' ), 'label_password' => __( 'Password ), 'label_remember' => __( 'Remember Me' ), 'label_log_in' => __( 'Log In' ), 'remember' => true ); wp_login_form( $args ); } else { // If logged in: echo 'you are already logged in'; wp_loginout( home_url() ); // Display "Log Out" link. echo " | "; wp_register('', ''); // Display "Site Admin" link. } ?> And in the functions.php page, I am using the following code to redirect users to the homepage after they log in: function my_login_redirect( $redirect_to, $request, $user ){ //is there a user to check? if( isset( $user->roles ) && is_array( $user->roles ) ) { //check for admins if( in_array( "administrator", $user->roles ) ) { // redirect them to the default place return $redirect_to; } else { return home_url(); } } else { return $redirect_to; } } add_filter("login_redirect", "my_login_redirect", 10, 3); My question is:, Is there a way to redirect users to the 'referrer page (page from where they logged in)' after they login by making changes to the above code or perhaps using a better code? Thanks in advance.
The key part is right here-- 'redirect' => admin_url(), in your first block of code. Whatever you set that to is where you will redirect. I don't see a reason for the second block if you are redirecting everyone. There is no function that I can find for "this page" so you probably want $_SERVER['REQUEST_URI'] $args = array( 'redirect' => esc_url($_SERVER['REQUEST_URI']), 'form_id' => 'loginform-custom', 'label_username' => __( 'Username' ), 'label_password' => __( 'Password' ), 'label_remember' => __( 'Remember Me' ), 'label_log_in' => __( 'Log In' ), 'remember' => true ); wp_login_form( $args ); Be careful with $_SERVER vars: http://markjaquith.wordpress.com/2009/09/21/php-server-vars-not-safe-in-forms-or-links/
0.5
'redirect' => admin_url() in first block of code
Is 1 pixel of a height map representative of 1 vertex on the mesh?
I'm trying to get my head around heightmap terrain generation. If I have a plane say 64 x 64 verts will I need to create a 64px by 64px greyscale heightmap in order to displace the geometry of the plane correctly?
You may be confusing some details. A height map is simply a 2D array of data. Each point represents 3 pieces of information: an x and y location and a number to represent the height at that point. For a simpler example, lets look at a 1D array of data that creates some 2D terrain. Each data point here will contain an x location and a number to represent the height at that point: Pretty simple right? It's just a regular old graph. As you can see, the numbers on the x axis go up by tens. We could easily change that to go up by 100's or by .01's. Same goes for the data displayed on the y axis. We can scale those values however we like. Basically, it's just numbers until you decide how you're going to visually represent it. So, saying a height map of 64px by 64px is already one step beyond where we need to go. Since a grayscale image is just another way to display the same data as a 3D height map. The data to represent each is coming from the same place. Further, you don't even need a 1 to 1 relationship between data and display. You could have far more vertices than you have data points, or far fewer. They don't even need to be equally spaced. For the most basic example: Yes, generate an array of [64][64] data points to make a grayscale image or a 3D heightmap. Each [x][y] of your array will correspond to the x, y of your vertices and the value stored in each [x][y] will represent the z value of your vertex.
0.888889
A height map is simply a 2D array of data
Why is RSS distributed chi square times n-p?
I would like to understand why, under the OLS model, the RSS (residual sum of squares) is distributed chi square times n-p (p being the number of parameters in the model, n the number of observations). I apologize for asking such a basic question, but I seem to not be able to find the answer online (or in my, more application oriented, textbooks).
I consider the following linear model: ${y} = X \beta + \epsilon$. The vector of residuals is estimated by $$\hat{\epsilon} = y - X \hat{\beta} = (I - X (X'X)^{-1} X') y = Q y = Q (X \beta + \epsilon) = Q \epsilon$$ where $Q = I - X (X'X)^{-1} X'$. Observe that $\textrm{tr}(Q) = n - p$ (the trace is invariant under cyclic permutation) and that $Q'=Q=Q^2$. The eigenvalues of $Q$ are therefore $0$ and $1$ (some details below). Hence, there exists a unitary matrix $V$ such that (matrices are diagonalizable by unitary matrices if and only if they are normal.) $$V'QV = \Delta = \textrm{diag}(\underbrace{1, \ldots, 1}_{n-p \textrm{ times}}, \underbrace{0, \ldots, 0}_{p \textrm{ times}})$$ Now, let $K = V' \hat{\epsilon}$. Since $\hat{\epsilon} \sim N(0, \sigma^2 Q)$, we have $K \sim N(0, \sigma^2 \Delta)$ and therefore $K_{n-p+1}=\ldots=K_n=0$. Thus $$\frac{\|K\|^2}{\sigma^2} = \frac{\|K^{\star}\|^2}{\sigma^2} \sim \chi^2_{n-p}$$ with $K^{\star} = (K_1, \ldots, K_{n-p})'$. Further, as $V$ is a unitary matrix, we also have $$\|\hat{\epsilon}\|^2 = \|K\|^2=\|K^{\star}\|^2$$ Thus $$\frac{\textrm{RSS}}{\sigma^2} \sim \chi^2_{n-p}$$ Finally, observe that this result implies that $$E\left(\frac{\textrm{RSS}}{n-p}\right) = \sigma^2$$ Since $Q^2 - Q =0$, the minimal polynomial of $Q$ divides the polynomial $z^2 - z$. So, the eigenvalues of $Q$ are among $0$ and $1$. Since $\textrm{tr}(Q) = n-p$ is also the sum of the eigenvalues multiplied by their multiplicity, we necessarily have that $1$ is an eigenvalue with multiplicity $n-p$ and zero is an eigenvalue with multiplicity $p$.
1
The vector of residuals is estimated by $$hatepsilon = y - X hat
No value for $TERM and no -T specified
I recently upgraded (with apt-get dist-upgrade) my Kubuntu and Lubuntu Linux boxes, and now every time I log into one of these machines, I get this message: tput: No value for $TERM and no -T specified Here is a screenshot of the exact message: This happened on both my Lubuntu machine and Kubuntu machine, and it wasn't a problem until after I upgraded; so I suspect that it was not user error. How can I fix this? UPDATE I have tracked this down to my .bashrc file, which is getting called by my .profile file. Though, the fact that my .bashrc file now runs when I do a GUI login whereas it didn't before I upgraded is a bit weird. And no, I haven't modified my .bashrc file or my .profile recently. Also, bash isn't my default shell. The problem is that I am calling tput in my .bashrc file to set up variables for use in adding color to the prompt. But at the (inappropriate) time when my .bashrc file now gets run, $TERM is not set. fgRed=$(tput setaf 1) ; fgGreen=$(tput setaf 2) ; fgBlue=$(tput setaf 4) fgMagenta=$(tput setaf 5) ; fgYellow=$(tput setaf 3) ; fgCyan=$(tput setaf 6) fgWhite=$(tput setaf 7) ; fgBlack=$(tput setaf 0) bgRed=$(tput setab 1) ; bgGreen=$(tput setab 2) ; bgBlue=$(tput setab 4) bgMagenta=$(tput setab 5) ; bgYellow=$(tput setab 3) ; bgCyan=$(tput setab 6) bgWhite=$(tput setab 7) ; bgBlack=$(tput setab 0) Updated question: How should I fix this? Should I set $TERM myself? Or should I just not set these variables if $TERM is not set? UPDATE 2 One solution I tried was to check whether $TERM was set. But this didn't seem to work; I still got the same error message. Here's the code: if [ ! "$TERM" = "" ]; then #Do stuff here fi So apparently $TERM was set, but tput still concluded it wasn't.
What ultimately worked for me was to check whether the shell was an interactive shell. I based the solution on this other post at unix.stackexchange: How to check if a shell is login/interactive/batch. So the code for the solution was: if [[ $- == *i* ]]; then fgRed=$(tput setaf 1) ; fgGreen=$(tput setaf 2) ; fgBlue=$(tput setaf 4) fgMagenta=$(tput setaf 5) ; fgYellow=$(tput setaf 3) ; fgCyan=$(tput setaf 6) fgWhite=$(tput setaf 7) ; fgBlack=$(tput setaf 0) bgRed=$(tput setab 1) ; bgGreen=$(tput setab 2) ; bgBlue=$(tput setab 4) bgMagenta=$(tput setab 5) ; bgYellow=$(tput setab 3) ; bgCyan=$(tput setab 6) bgWhite=$(tput setab 7) ; bgBlack=$(tput setab 0) fi
1
How to check whether a shell is an interactive shell
Counting vowels with consonants
I have made a program to count the number of vowels and consonants in an inputted string: Scanner in = new Scanner(System.in); System.out.print("Enter a string "); String phrase = in.nextLine(); int i, length, vowels = 0; int consonants = 0; boolean y = false; String j; length = phrase.length(); for (i = 0; i < length; i++) { j = "" + phrase.charAt(i); boolean isAVowel = "aeiou".contains(j.toLowerCase()); boolean y = "y".contains(j.toLowerCase()); if(isAVowel){ vowels++; }else if(isAVowel && y){ vowels++; consonants++; //}else if(y && !(isAVowel)){ // vowels++; }else{ consonants++; } System.out.println("The number of vowels in \"" +phrase+"\" is "+ vowels+".\n\nThe number of consonants is "+consonants+".\n\n"); When "y" is by itself it says its a consonant, it should be a vowel. Where do I state this?
The following recursive function returns the number of vowels in an input string public static int vc(String s){ if(s.length() - 1 < 0) return 0; return ((("aeiou".indexOf((s.charAt(s.length()-1)+"").toLowerCase()) >= 0 ? 1 : 0)) + vc((s = s.substring(0,s.length()-1)))); }
0.666667
recursive function returns number of vowels in input string public static
How do I figure out my Google OpenID URL?
I'm trying to log in to the CakePHP website using Open ID: http://ask.cakephp.org/users/login The most correct looking URL I've found is: https://www.google.com/accounts/o8/id ..but I can't properly determine what I'm supposed to enter for my open ID, as it rejects everything that I try putting in. Is the cake site just broken, or do I have the wrong URL?
On most sites you can use your Google profile link when logging in to OpenID. E.g. http://www.google.com/profiles/your.name.here Before Google profile OpenID support you had to use https://www.google.com/accounts/o8/id You can read more about it at Jeff Atwood blog post: Google Offers Named OpenIDs. However, it appears, that at ask.cakephp.org Google profile URLs are not working. As noted by Greg, if you are logged in to your google account, google.com will work as OpenID url there.
1
Google profile URLs are not working on most sites
Modify function to display max windows height minus 20%
I'm trying to modify JavaScript (jQuery, Google Maps v.3) to get the size of #mao_canvas only 80% of the screen height, but I can't undestand what to modify in tihs function. Can anyone help me with this? The basic idea is to get 80% height of #map_canvas. $(function(){ $("#map_canvas").css("height",$(window).height() + 'px'); initialize(); });
is this what you mean? $(function(){ $("#map_canvas").css("height",($(window).height()*80/100) + 'px'); initialize(); });
1
is this what you mean?
What does this sentence about toxemia and Clostridium tetani mean?
I know that Cl tetani is not invasive and strictly localised. I think toxemia means spread in the blood. I am thinking this sentence The volume of infected tissue is small, and the disease is almost entirely a toxemia. Cl tetani has spores. This suggests me that these spores spread through blood. They then open and become pathogenic in some tissues where they remain strictly locally (so small area/volume of infected tissue; I think area is better word, since the disease is not invasive) and pathogenic. How do you understand the quoted sentence about pathogenesis of Cl tetani?
Clostridium tetani produces a protein toxin, tetanospasmin which causes the major symptom of tetanus, namely involuntary muscle spasms. C. tetani is an aerobic species, does not infect the blood, and apparently only produces toxin in anaerobic conditions. If a pathogenic bacterium propagates through the bloodstream this condition is referred to as bacteraemia. In the case of C. tetani it is the toxin which enters the bloodstream, not the bacteria, hence toxaemia. The bacteria, being anaerobic, are inhibited from spreading through aerobic tissues.
0.888889
Clostridium tetani produces a protein toxin which causes involuntary muscle spasms .
Teletext Subtitles on Romanian Television
There is a teletext feature on the televisions in the hotel rooms. In England there was a way to get subtitles to appear by going to the teletext interface and entering 888. As far as I know this is no longer available. In Romania, is there a special code you can enter into the teletext interface to enable subtitles? I've tried 888 but it doesn't do anything.
Bad news. While 888 will get you the teletext subtitles in Greece, Belgium and other countries, and Austria is 777, for example, Romania is one of the few EU members to have NONE for Teletext subtitling. Source: State of subtitling access in EU report - European Federation of Hard of Hearing People (page 20).
0.777778
Romania is one of the few EU members to have NONE for Teletext subtitling
Layman's guide to getting started with Forex (foreign exchange trading)?
How should I get started with Forex (foreign exchange trading)? How should I prepare myself for it? Please give your answer thinking of me as a layman.
Currency Trading For Dummies, no offense. The "For Dummies" series is well known for its expertise in every field one can imagine. That said, what prompts you to want to get into this? The average person is very likely to lose money as the long time experts walk away winners. Do you have an urge to trade commodity futures? I sure don't. While I offer the book as a guide, the real answer is "you shouldn't."
0.888889
Currency Trading For Dummies, no offense
iMessage Weird Behavior
I have multiple mobile devices (2x iPhone, 2x iPad) in my home, all which share the same iTunes account between them. When iMessage is used to exchange messages between two of the devices (e.g. the two iPhones), the messages appear to be sent from and received by the same identity. The only way I have found to correct this by turning off iMessage on one of the devices and only using SMS. Is there a way to associate iMessage with a different iTunes account than other apps on the same device?
iMessages on an iPhone will always receive on the phone number of that phone, and (by default) the email address associated with the iTunes ID you logged into. On an iPad or iPod, there is obviously no phone number and so they will only listen on the email address of the Apple ID. However you are able to add additional email addresses to receive messages against. You are welcome to create any number of additional iCloud accounts for each device and add them into Settings > Messages > Receive At. Then you just need to remember to use the correct email address to start a new conversation with. You can have contact entries for "My iPad/[email protected]" and "The Wife's iPod/[email protected]" etc if you wish to effectively address a device directly rather than the user of the device.
1
iMessages on an iPhone will always receive on the phone number of that phone, and the email address associated with the Apple ID.
Psychology behind $0.99 for paid apps, but $1.00 for donation apps?
I've noticed a trend (at least on the Google Play store) of application prices ending in x.99, while 'donation' apps usually end on the dollar. I see the reasoning behind the psychology that makes a user purchase a $0.99 item over one that costs $1.00, but why the trend to keep the prices on the dollar for donation items?
The psychology behind the $0.99 was explored in depth in Priceless: The Hidden Psychology of Value, which if you ask for my humble opinion, is a life-changing book. Partly the reason for such price tags is that it translates for many as a 'sale' price. Against it, is that it is typically associated with 'hard sale'. The donation payment system is in its core anti-capitalist, thus anti-commerce, and so prices are accordingly just simple (distinguishing themselves from any sale or hard sale like prices).
1
Priceless: The Hidden Psychology of Value
Ubuntu 11.04 "The destination is read-only" - thumbdrive - GNOME error?
I have Ubuntu 12.04. My problem is, I can't get write access to any USB device, like thumbdrive, SD card or digital camera using GNOME 3.4.1. Both FAT32 and NTFS filesystems won't work. From terminal I can create files without any problems... But when I do this same from GNOME file explorer: "The destination is read-only": Link to full-size image syslog: Jul 1 21:52:48 alan-OEM kernel: [19186.444270] usb 1-5.1: reset high-speed USB device number 12 using ehci_hcd Jul 1 21:52:48 alan-OEM kernel: [19186.539012] scsi10 : usb-storage 1-5.1:1.0 Jul 1 21:52:49 alan-OEM kernel: [19187.543752] scsi 10:0:0:0: Direct-Access Generic STORAGE DEVICE 9407 PQ: 0 ANSI: 0 Jul 1 21:52:49 alan-OEM kernel: [19187.546942] sd 10:0:0:0: Attached scsi generic sg4 type 0 Jul 1 21:52:50 alan-OEM kernel: [19187.769766] sd 10:0:0:0: [sdd] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB) Jul 1 21:52:50 alan-OEM kernel: [19187.770881] sd 10:0:0:0: [sdd] Write Protect is off Jul 1 21:52:50 alan-OEM kernel: [19187.770885] sd 10:0:0:0: [sdd] Mode Sense: 03 00 00 00 Jul 1 21:52:50 alan-OEM kernel: [19187.771900] sd 10:0:0:0: [sdd] No Caching mode page present Jul 1 21:52:50 alan-OEM kernel: [19187.771905] sd 10:0:0:0: [sdd] Assuming drive cache: write through Jul 1 21:52:50 alan-OEM kernel: [19187.776387] sd 10:0:0:0: [sdd] No Caching mode page present Jul 1 21:52:50 alan-OEM kernel: [19187.776392] sd 10:0:0:0: [sdd] Assuming drive cache: write through Jul 1 21:52:50 alan-OEM kernel: [19187.779555] sdd: sdd1 Jul 1 21:52:50 alan-OEM kernel: [19187.784891] sd 10:0:0:0: [sdd] No Caching mode page present Jul 1 21:52:50 alan-OEM kernel: [19187.784896] sd 10:0:0:0: [sdd] Assuming drive cache: write through Jul 1 21:52:50 alan-OEM kernel: [19187.784900] sd 10:0:0:0: [sdd] Attached SCSI removable disk /etc/mtab: /dev/sdd1 /media/CC2A-FA36 vfat rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks 0 0 root@alan-OEM:/etc# And /media: root@alan-OEM:/media# ls -l total 12 drwx------ 26 alan alan 8192 sty 1 1970 CC2A-FA36 ("alan" is my account.) It looks like like I have read-write-execute. So from terminal: alan@alan-OEM:/media/CC2A-FA36$ mkdir zzz alan@alan-OEM:/media/CC2A-FA36$ mkdir zzzz drwx------ 2 alan alan 4096 lip 1 22:49 zzz drwx------ 2 alan alan 4096 lip 1 22:49 zzzz Work great... but from GNOME I can't.... It's making me crazy...
I had the same issue in 12.04 LTS because of an outdated version of Nautilus. I solved using an update and dist-upgrade: sudo apt-get update sudo apt-get dist-upgrade nautilus -q Hope it helps.
0.833333
Dist-upgrade nautilus
What can I do about this gap between a wooden board and the sink?
The board already started to rot from below, so I need to replace it. How can I seal this small gap without having a permanent seal? The problem is that the boad is attached to the wall and I still want to be able to move the sink table away from the wall to get access to the tubes and things that fell behind the sink.
I have to say, this is a very uncommon situation. I have never seen a radiator behind a sink or heard of a movable sink table. I guess you have your reasons, but would it be easier to put doors on the front of the "sink table" so you can access the plumbing etc without moving it? With that said, the first thing I'd recommend would be replacing the wood board with a rot proof composite or PVC board. I'd add a 2 or 3 inch vertical splash board around the opening by the heater so water and objects won't fall down behind the sink. With the sink in place, maybe you could use a thin bead of acrylic door/window caulk to seal it to the wall and board. If you find that you must move the sink on occasion, the acrylic caulk is easy to remove and simple to reapply. Another alternative you might try is a strip of self adhesive rubber pillow style weather stripping to seal the gap between the sink and wall.
0.888889
Is it easier to put doors on the front of a sink table without moving it?
problem unscheduling reports
I have a user that is unable to see the "unschedule report" button in the edit report screen. However I am, as Sys Admin, able to see the button and use. I have checked their profile setting and they have the "Schedule Reports" option. Should this not enable them to unschedule the reports as well?
The Permission required to unschedule reports is β€œModify All Data” reference : https://help.salesforce.com/HTViewHelpDoc?id=reports_schedule_delete.htm&language=en_US and there's a related idea to enabled unschedule option for non administrators without the need to Modify All Data permission Idea : https://success.salesforce.com/ideaView?id=08730000000BpiV
0.888889
Permission to unschedule reports
Can I remove the labels from ICs?
In another question I asked about ways one might obfuscate the design of a system, to prevent unauthorized cloning. One suggestion was that IC manufacturers are often willing to put custom labels on their chips. The idea is interesting, but my quantities are low enough that this would not be cost-effective. How might one remove or otherwise render unreadable the labels on ICs?
It is not difficult to search component libraries looking for part of the same style and size with matching power and ground pins. A simple product with little added value is exactly the kind of thing a cloner can make money at. The only way I know of to make a design hard to copy is to add value to it that isn't easily reproducible or is patentable and/or to iterate the product faster than the cloners can keep up.
0.888889
a simple product with little added value is exactly the kind of thing a cloner can make money at
How to remember 10 last read articles with timestamp in session for a user in Codeigniter?
I would like to make a PHP if condition code that will check if the last 10 articles or 10 minutes from the article reading by the user have already elapsed. E.g. A user open a page with id = 235 (this id value is in the url localhost/article/235 ) and this id value will be saved in session with a current timestamp and maybe his IP address Then he read another article and the same will happen. I need to remember the clicked stuff for another ten clicks and then reset that only for the first row. E.g. after the 10th click the id and timestamp will not became 11th row but will replace the 1st row in the list. The php condition in CodeIgniter will then check these values and will update the article hit counter value in the articles table and column counter like this: $this->db->where('id', $id); $this->db->set('counter', 'counter+1', FALSE); $this->db->update('articles'); But before calling this code I need to make this check from the session? How to do that? I think storing e.g. 10 entries in the session with timestamps per user will be enough. Just don't save the same page in the session twice. And the condition will check the current timestamp with the saved one and if it is more than e.g. 10 minutes or the user have read/clicked another 10 articles it will allow the update counter php code. I don't need to have this bulletproof. Just to disable the increment using browser's refresh button. So, if he wants to increment the counter he will need to wait ten minutes or read another 10 articles ;)
Based on Raphael_ code and your question you can try this: <?php $aClicks = $this->session ->userdata('article_clicks'); $nextId = $this->session->userdata('nextId'); // Initialize the array, if it's not already initialized if ($aClicks == false) { $aClicks = array(); $nextId = 0; } // Now, we clean our array for the articles that have been clicked longer than // 10 minutes ago. $aClicks = array_filter($aClicks, function($click) { return (time() - $click['time']) < 600; // Less than 10 minutes elapsed } ); // We check if the article clicked is already in the list $found = false; foreach ($aClicks as $click) { if ($click['article'] === $id) { // Assuming $id holds the article id $found = true; break; } } // If it's not, we add it if (!$found) { $aClicks[$nextId] = array( 'article' => $id, // Assuming $id holds the article id 'time' => time() ); $nextId++; $this->session->set_userdata('nextId', $nextId); } $this->session->set_userdata('article_clicks', $aClicks); if (count($aClicks) > 10 && $nextId > 9) { $this->session->set_userdata('nextId', 0); echo "OK!"; } ?>
0.777778
Using Raphael_ code and your question
Sum of vlookup values on multiple sheets
Have 12 excel Sheets in a workbook for each month Jan-Dec. Each sheet contains Names and leaves marked for that month in the same row and sum value for each category of leave at the end of the table. I need to summarize these individual sheets value by looking for each person's Name in all sheets. how can I achieve this in excel.... I tried sum of vlookup from all sheet, it throws error or no result.
This summary will be much easier to accomplish if you consolidate your monthly sheets into a single database sheet for the year. Then you can set up a Pivot Table that will do the summing up by person in short order. I suspect your sum of vlookups is throwing an error because each person takes leave in only a few of the months in a year. The way to deal with this is to wrap the lookups in IFERROR functions. So the formulas would have to look like: =sum(iferror(vlookup(<person name>,<January sheet name!data range>,<leave column number>,0),0), iferror(vlookup(<person name>,<February sheet name!data range>,<leave column number>,0),0), etc. ) This could be made slightly less awkward by setting up a lookup for each month in individual columns and then summing the results across columns. Another alternative which I'm not very familiar with--but that might meet your needs--is the Data Consolidate command. An explanation of the command can be found here. I highly recommend the Pivot Table approach.
0.888889
Set up a Pivot Table that will do the summing up by person in short order
How to execute a custom script when Internet reconnects?
My Internet gets disconnected every now and then. I'd like to run a Bash script every time the Internet reconnects. The script is quite simple: #!/bin/bash mplayer /home/user/sound.mp3 It's placed in /usr/bin and works perfectly when I call it as online_notifier in Terminal. I would like to execute this script whenever the Internet reconnects. I tried adding the following line to my /etc/network/interfaces/ file: post-up sound_notifier This is the full content of that file: auto lo iface lo inet loopback post-up sound_notifier I also tried with the full path as well. But it didn't work. Here's my ifconfig output, if that helps. How can I achieve this?
Assuming, your script has the name sound_notifier and it's placed in /usr/bin: sudo chmod +x /usr/bin/sound_notifier Create a script /etc/network/if-up.d/start_sound_notifier sudo nano /etc/network/if-up.d/start_sound_notifier add the code below #!/bin/sh if [ "$METHOD" = loopback ]; then exit 0 fi # Only run from ifup. # if [ "$MODE" != start ]; then # exit 0 # fi sound_notifier Make the script executable. sudo chmod +x /etc/network/if-up.d/start_sound_notifier That's all ;)
1
sudo chmod +x /usr/bin/sound_notifier
strtotime calculates wrong when moving over to linux (webhost) from windows (localhost)
I've some problem with make a simple PHP function to work on my webspace meanwhile it works like expected at my localhost server. The problem is the following calculation: echo $Formated = date("Ymd",strtotime("last day of next month")); This script dosen't seem to work b/c i simply gets the default date 19691231 instead of the correct one 20110630 when running it on my server. I use windows (XAMP) as my localhost server so i guess there must be some form of problem that lies within the two platforms way of handling it?
dont use of if month name is not given try with date('m/d/y', strtotime('last day next month')); OR date('m/d/y', strtotime('last day of march')); // give the month name with of Reference
0.888889
if month name is not given try with date('m/d/y', strtotime('last day next month'
Insertion with Regex to format a date (Perl)
Suppose I have a string 04032010. I want it to be 04/03/2010. How would I insert the slashes with a regex?
To do this with a regex, try the following: my $var = "04032010"; $var =~ s{ (\d{2}) (\d{2}) (\d{4}) }{$1/$2/$3}x; print $var; The \d means match single digit. And {n} means the preceding matched character n times. Combined you get \d{2} to match two digits or \d{4} to match four digits. By surrounding each set in parenthesis the match will be stored in a variable, $1, $2, $3 ... etc. Some of the prior answers used a . to match, this is not a good thing because it'll match any character. The one we've built here is much more strict in what it'll accept. You'll notice I used extra spacing in the regex, I used the x modifier to tell the engine to ignore whitespace in my regex. It can be quite helpful to make the regex a bit more readable. Compare s{(\d{2})(\d{2})(\d{4})}{$1/$2/$3}x; vs s{ (\d{2}) (\d{2}) (\d{4}) }{$1/$2/$3}x;
1
How to match a regex with a variable?
Getting access denied on the destination drive partition. after using xcopy
i am wanted to copy the all the files in folder including sub-folders from one hard drive to another hard drive for this i tried below xcopy command C:\Documents and Settings\rakesh>xcopy "D:\Ganesh Drive\Trimax soft important" " H:\" /E /k /x but after executing this command i am getting access denied on the destination drive partition. Please let me why and how rectify the same.
I know this is long time ago, but since I had the same problem from the same kind of command (xcopy targeting a volume root with /x), I thought about sharing the solution. This appears to be a bug in xcopy (Windows XP SP3 version 5.1.2600.5512 at least), where the root directory entry ”.” of the target directory gets its ACL erased. Fixed it with ”CACLS [drive letter:] /g Everyone:F”.
0.777778
Fixed xcopy root directory entry with /x
Get latitude/longitude of friend's current_location using Graph FQL
I'm trying to get the latitude/longitude of all of a user's friends using a single API call. I believe I need to write a multi-query FQL statement, but I can't get the syntax correct. I believe the two queries need to be something like the following: '"friends":"SELECT uid,current_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"' '"location":"SELECT location FROM page WHERE id IN (SELECT current_location_id FROM #friends)"'; My problem is that somehow I need to get the ID of the current_location in the first query so that I can reference it in the second query, but I only know how to get an array that contains the id. Thanks for any help! Clarification: I'm not trying to get check-ins of friends. Instead I want to graph the "current_location" (i.e. where they live) of all of a user's friends on a Geo map. I can get a user's "current_location" with the following FQL query: "SELECT uid,sex,current_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())" This query returns the following array: [current_location] => Array ( [city] => New York [state] => New York [country] => United States [zip] => [id] => 108424279189115 [name] => New York, New York ) Which does not contain the longitude and latitude of the of the current_location (New York in the above example) Therefore I now need to take the ID of the current_location (e.g. 108424279189115) and run a second FQL query such as: "SELECT location,name FROM page WHERE page_id = 108424279189115)" To get the latitude and longitude of the current_location. Currently, I have a working code that runs the first FQL query, then extracts page_id in php, and then runs a second FQL query to get the current_location latitude/longitude. However, for performance reasons I would like to run only one multi-query if this is possible.
Edit: The query should work by adjusting the second query to: '"location":"SELECT location FROM page WHERE id IN (SELECT current_location.id FROM #friends)"'; When working with an array type in the FB API you can access the value in any query by doing array.value Also, if all you need is the page's id, you'll probably get better performance by doing current_location.id in your first query You're going to want to use a fql.multiquery, there is a similair answer here that can be tailored to your needs: Facebook Graph API get all users and their status The FQL documentation on multiquery is located here: http://developers.facebook.com/docs/reference/fql/ Also are you trying to get the lat/long of a checkin object? If so you need to take a look at this resource: http://developers.facebook.com/docs/reference/fql/checkin/ Edit: I'm not sure that what you are trying to do is possible. I just looked through the api and tested some queries, the only way you could get the lat/long from a friend seems to be based on a checkin, from there you can get details on the page if necessary... Even looking at your second query, current_location_id is not referenced anywhere in the page table, and selecting location from the page table is going to give you location info on the place that it pertains to. Maybe you could elaborate more on what you're trying to accomplish. Here is a multiquery statement I wrote in PHP using FQL (it will select the coordinates of all your friends check ins, then from there get details on the place of the checkin pertaining to that friend): try{ $multiQuery = "{ 'query1':'SELECT coords, tagged_uids, page_id FROM checkin WHERE author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me())', 'query2':'SELECT name, description FROM page WHERE page_id IN (SELECT page_id FROM #query1)' }"; $param = array( 'method' => 'fql.multiquery', 'queries' => $multiQuery, 'callback' => '' ); $queryresults = $facebook->api($param); print_r($queryresults); } catch(Exception $o){ print_r($o); }
0.777778
How do you get the lat/long of a checkin object?
when to use "of" and when not?
I have a question: it's been months that I watch movies for improving my listening skill(it was quite awful:-D). now my question. I know that we should use "warlord" instead of "Lord of war" or "landlord" instead of "Lord of land" but I don't know why "The lord of the rings" is correct? isn't it better to use Ringslord ??? I meant how to know when I should use "of" ?
"Warlord" and "landlord" are English words. "Lord of war" and "lord of land" do not happen to be established English phrases, but they can certainly be used: but they do not mean the same as the words. (For example, a "landlord" may be quite a humble person, provided only that they have some property which is let to somebody else - and that is leaving aside the special meaning of "landlord" as "publican" or "proprietor of a pub"). In a feudal setting, you could reasonably use the phrase "lord of the land" - this would mean the lord who ruled over the land: a quite different meaning from "landlord". In the case the Rings, neither "Ringlord" nor "Lord of the rings" existed in English before Tolkien wrote them, as far as I know. We cannot know why he used the phrase for the title, but my guess is it has a more sonorous sound at the time he wrote it, I think that using a neologism like "Ringlord" in the title of a book would have puzzled both editors and readers.
1
"Lord of war" and "lord of land" are English words, but not the same as the words
Can the Mage Wars Warlock be played without any Demon cards?
As the subject states, I was wondering if the Mage Wars Core Set comes with enough Fire type cards to allow the Warlock Mage to build a spellbook with absolutely no Demon cards. Without seeing the cards, I will assume that most, if not all of the other Dark magic cards are OK, but I would ultimately prefer a pure Fire Magic spellbook. So as to preemptively answer the almost inevitable 'Why?', I will simply say that, as an orthodox Christian, my conscience doesn't allow me to play a game with such cards. I would prefer not to debate/explain this further, as I believe such a discussion is well beyond the scope of this site.
Google "mage wars Warlock strategy" one of the results will be a 4 minute youtube video of a Warlock tearing a beastmaster apart, winning the game in 9 rounds, without summoning a single creature, demons or otherwise.
1
Google "mage wars Warlock strategy" 4 minute video of a Warlock tearing a beastmaster apart .
Can I use opencv 64 bit in visual studio 32 bit version in a 64 bit machine?
The question is just same as the topic. Can I use opencv 64 bit in visual studio 32 bit version in a 64 bit machine?
Yes, Visual Studio is always a 32 bit application (at least so far), but you can compile your code into application that can run in 64 bit mode, and even run and debug the application in 64 bit mode from Visual Studio.
1
Visual Studio is always a 32 bit application (at least so far)
I don't have a dedicated GPU and I can't install DirectX to play NFS Most Wanted
I want to play NFS Most Wanted on the PC and I do not have any Graphic Card. While installing this system asks to install Directx (Even I have already installed it) and displays an Internal system error. Please somebody guide me about this game and Directx Issues.
Every computer built in the last 5 years or so has a 3D capable graphics card. Need for Speed Most Wanted has modest system requirements, so it's likely that if you have a fairly recent computer, you'll be able to play it. You can identify the model and type of your graphics card by going into the device manager. You may also need to update your graphics drivers before you'll be able to play. As far as your DirectX error goes, I found one guide that gave a hint: DirectX Error when Installing: When installing the game if you get an error that DirectX9.0c is not installed, even if you've installed DX9.0c already, then find the game's Autorun.exe file (in the base directory of the game CD), right-click on it, select Properties, go to the Compatibility tab, tick the 'Run this program in compatibility mode for' and select 'Windows 2000'. Then double-click on Autorun.exe to begin installation. Make sure to turn off compatibility mode after installing the game. If this doesn't fix your problem, you're going to have to provide more detail in your question.
0.666667
How to identify the model and type of your graphics card
Is ZIP archive capable of storing permissions?
I am using Maven Assembly plugin to bundle my application along with configuration/settings files. It allows to specify persmissions to be stored along with files, which is quite convenient. Still I never found a confirmation, that ZIP archive is capable of storing UNIX permissions. Is it? (please, post some proof if you answer either yes or no).
From the unzip(1) manpage: Dates, times and permissions of stored directories are not restored except under Unix. (On Windows NT and successors, timestamps are now restored.) So yes, permissions can be stored.
1
Dates, times and permissions of stored directories not restored except under Unix
Is it possible to encrypt a file so that it can not be brute forced?
Is there any program or method that allows encryption that can not be brute forced or is it just that any encrypted file can be decrypted by brute force?
The difficulty of brute forcing an encryption system is based on the degree of randomness produced by the key. When a key is less than the length of a file, there has to be some type of reuse, and this means less than perfect randomness and thus some small susceptibility to being brute forced. Thus, in order to make something truly brute force proof against an attacker with unlimited resources and time, the only option is a truly random key that is the same length as the input and that has never been used as a key on another message. This technique is actually very, very old and is known as a one time pad (or OTP). An OTP is completely future secure as long as the key remains secret. Since the key is random and only used once, the input bears no resemblance to the output and "jfeidj" could just as easily be "attack" as it could be "dinner". That said, attackers don't have unlimited time or resources, so practically speaking, almost any modern symmetric algorithm will provide more than enough security even at key lengths as low as 128 bits or lower. 128 bit AES, for example, while "technically" able to be brute forced would take so long trying to brute force that chances are good that if every computer on the planet worked on nothing but cracking the message, the sun would die and the solar system get sucked in to a black hole before they finished cracking the message. (Provided there aren't any unknown flaws in the algorithm and that the key is properly generated.) If you make it 256bit, the heat death of the universe will come before you successfully brute force it. So practically speaking, just about any modern algorithm is secure against brute forcing with sufficient key length.
1
brute forcing an encryption system is based on the degree of randomness produced by the key
Crossplatform "jail" for an application
We currently have a variety of systems (Linux, Solarix, *BSD, HP-UX ...) on which we are not allowed to install anything into / (but I have root access. That's strange, I know). But we'd like to run Puppet on all of them. So, the obvious idea is to install Puppet with all prebuilt dependencies into some isolated tree, something like "jail", which will allow to use dependences from some prefix and to access the host system. The big advatanges would be uniform deployment and updates. One solution that came to my mind is to deploy Gentoo Prefix, and install Puppet there with package manager. However, this requires a lot of extra space and some manual patching for each system. Maybe there are some more elegant and simple solutions?
Puppet Enterprise installs all of its libraries into the /opt/puppet directory to avoid messing with system Ruby. It will add cache and logs to parts of /var, and agent configuration files into /etc, but you can configure all that in puppet.conf.
0.888889
Puppet Enterprise installs all of its libraries into the /opt/puppet directory
What type of lubricant should be used on PVC windows, and how often should it be applied?
As far as I know, the lifespan of PVC windows is highly dependent on periodic lubrication. What kind of oil should I use to lubricate the moving metal parts of my PVC windows? Additionally, what should be the time span between two applications of the lubricant?
Quality sliding PVC windows use rollers. Keep the tracks clean, using a slightly damp lint-free cloth. The rollers take care of themselves. On cheap PVC sliders, I use paste wax after cleaning the slot with a slightly damp lint-free cloth. You can also use spray silicone. Clean the track with a slightly damp lint-free cloth. Spray the silicone on another lint-free cloth and wipe the track down. Don't use any petroleum lubricants on PVC if you want it to last.
0.833333
PVC sliding windows use rollers. Keep track clean, using a slightly damp cloth.
Possible to remove p tags from a table cell in Wygwam
I have a problem that occasionally a <p> tag is being added to a table cell, usually when someone pastes something into it. Is there a way to remove that <p> and just have the cell be an empty <td> or <th>, ideally without editing the source? Is there an option that could be added through the advanced settings?
I doubt you can do it easily. A custom extension to parse the text on submission might do it, but the issue is CKEditor forces <p> tags around pretty much every inline element. You're better off just leaving it and changing the styles like GDMac suggested.
0.666667
Custom extension to parse text on submission
Should you let users know if an email has been taken during registration validation?
In many web applications, email is required to be a unique field, and users aren't allowed to register an account if their email already exists in the database. When performing validation on the registration form, you would presumably check if an email has been taken, and let the user know if it has since they can either pick a different one or try to reset their password. However, if you are providing this feedback, it seems like malicious users could test to see if users exist in the database. Someone could plausibly test your site against leaked data from big-name hacks, and if the users are reusing their passwords across sites, then your site is potentially vulnerable. The solution to this could be simply giving more generic feedback about what went wrong without specifically mentioning email, although that could be frustrating for the average user trying to sign up. And if your sign up form simply requires an email and password, it is still pretty obvious that if any error is encountered it is likely that the email already exists in the database. What is the best way from a security perspective to handle informing a user that an email has already been taken upon registration?
An intuitive and simple solution is to make sure that an automated script (malicious script) cannot try to register with a list of e-mails in order to figure out which ones are registered. For example, use CAPTCHA challenge as part of registeration to make sure it is a human trying to register an account. In this way, even if few user e-mails are tried, a massive number cannot be checked. Note we are assuming strong CAPTCHA cannot be easily broken. But if it is super sensitive and you must hide who is registered at the target website even from human users, then finish the registration and do not show any error message to the user that the e-mail is already registered; and just inform the user at the end of the process that now they have to confirm the e-mail belongs to them, please go and check your e-mail; In the backend, if the e-mail is already registered, then do nothing; just send an e-mail to the owner of the e-mail and inform them: seems you tried to re-register at our service again, if you have forgotten you have an account with us, this is your username, and if you cannot remember your password, go to the password reset page. To be at the safe side, you can mention that if you did not try to register with us again, please ignore this e-mail. If the e-mail is not registered in the database, in the backend, create a random one-time use token in a URL and send to the new e-mail registered and ask them to confirm the new account if they meant to create a new account. This way is you absolutely hide everything from the bad guys;
1
Make sure that an automated script cannot register with a list of e-mails
Is this formula in predicate logic a tautology?
$\left(\forall x \cdot p(X) \Rightarrow q(X)\right) \wedge p(Y) \Rightarrow q(Y)$ At first glance this seems like a tautlogy and that's what my notes say. But an interpretation where $p$ is always true and $q$ is always false seems to be a counterexample. Can someone confirm this or show me where I've gone wrong? Thanks.
It is valid; after restoring the parentheses for better readibility, we have : $(βˆ€x[p(x) \to q(x)] ∧ p(y)) \to q(y)$. Proof 1) $βˆ€x[p(x) \to q(x)] ∧ p(y)$ --- assumed 2) $βˆ€x[p(x) \to q(x)]$ --- from 1) by b$\land$-elimination 3) $p(y)$ --- from 1) by b$\land$-elimination 4) $p(y) \to q(y)$ --- from 2) by $\forall$-elimination 5) $q(y)$ --- from 3) and 4) by $\to$-elimination 6) $(βˆ€x[p(x) \to q(x)] ∧ p(y)) \to q(y)$ --- from 1) and 5) by $\to$-introduction.
0.888889
Restore parentheses for better readibility
Tic Tac Toe implementation in Objective-C
First off, here's the code: main.m #import <Foundation/Foundation.h> #import "PSBoard.h" #import "PSPlayer.h" #import "PSInputHandler.h" int main(int argc, const char * argv[]) { @autoreleasepool { NSLog(@"Enter Player 1 Name:"); NSString *playerOneName = [PSInputHandler getString]; NSLog(@"Enter Player 2 Name:"); NSString *playerTwoName = [PSInputHandler getString]; NSLog(@"How many rows and columns will you play with?"); NSUInteger numberOfRowsAndColumns = [PSInputHandler getInteger]; PSPlayer *playerOne = [[PSPlayer alloc] initWithSymbol:PSBoardSymbolX name:playerOneName]; PSPlayer *playerTwo = [[PSPlayer alloc] initWithSymbol:PSBoardSymbolO name:playerTwoName]; PSBoard *board = [[PSBoard alloc] initWithRows:numberOfRowsAndColumns columns:numberOfRowsAndColumns players:@[playerOne, playerTwo]]; do { PSPlayer *currentPlayer = [board playerUp]; BOOL validInputEntered = NO; //Loop until valid input is entered while(!validInputEntered) { //Get input coordinates NSLog(@"%@, enter a row (1-%lu).", currentPlayer.name, (unsigned long)numberOfRowsAndColumns); NSUInteger row = [PSInputHandler getInteger]; NSLog(@"Now enter a column (1-%lu).", (unsigned long)numberOfRowsAndColumns); NSUInteger column = [PSInputHandler getInteger]; //Verify that nothing is already placed there PSBoardSymbol symbolOfPlayerAtCoordinates = [board playerAtRow:row-1 column:column-1].symbol; if((symbolOfPlayerAtCoordinates != PSBoardSymbolX && symbolOfPlayerAtCoordinates != PSBoardSymbolO) && row > 0 && row <= numberOfRowsAndColumns && column > 0 && column <= numberOfRowsAndColumns) { [board setPlayer:currentPlayer atRow:(row-1) column:(column-1)]; validInputEntered = YES; } } //Show the board [board display]; } while(!board.winner); NSLog(@"Congrats %@! You won.", [board winner].name); } return 0; } PSBoard.h #import <Foundation/Foundation.h> @class PSPlayer; @interface PSBoard : NSObject @property (nonatomic) NSUInteger rows; @property (nonatomic) NSUInteger columns; @property (nonatomic, strong) PSPlayer *winner; -(instancetype)initWithRows:(NSUInteger)rows columns:(NSUInteger)columns players:(NSArray *)players; -(PSPlayer *)playerAtRow:(NSUInteger)row column:(NSUInteger)column; -(void)setPlayer:(PSPlayer *)player atRow:(NSUInteger)row column:(NSUInteger)column; -(void)display; -(PSPlayer *)playerUp; @end PSBoard.m #import "PSBoard.h" #import "PSPlayer.h" @interface PSBoard () @property (nonatomic, strong) NSMutableArray *internalBoardRepresentation; @property (nonatomic, strong) NSArray *players; @property (nonatomic, strong) PSPlayer *oldPlayerUp; @end @implementation PSBoard -(instancetype)initWithRows:(NSUInteger)rows columns:(NSUInteger)columns players:(NSArray *)players { if(self = [super init]) { self.rows = rows; self.columns = columns; self.players = players; self.internalBoardRepresentation = [[NSMutableArray alloc] initWithCapacity:rows]; PSPlayer *null = [[PSPlayer alloc] initWithSymbol:PSBoardSymbolNone name:nil]; for(NSUInteger row = 0; row < rows; row++) { NSMutableArray *currentColumn = [NSMutableArray array]; for(NSUInteger column = 0; column < columns; column++) { [currentColumn addObject:null]; } [self.internalBoardRepresentation addObject:currentColumn]; } self.oldPlayerUp = players[0]; } return self; } -(PSPlayer *)playerAtRow:(NSUInteger)row column:(NSUInteger)column { return self.internalBoardRepresentation[row][column]; } -(void)setPlayer:(PSPlayer *)player atRow:(NSUInteger)row column:(NSUInteger)column { self.internalBoardRepresentation[row][column] = player; [self checkForWinner]; } -(void)checkForWinner { NSUInteger numberOfPiecesInARowToWin = MAX(self.rows, self.columns); //Check horizontal lines for(NSUInteger row = 0; row < self.rows; row++) { PSPlayer *playerInFirstColumn = [self playerAtRow:row column:0]; NSUInteger playerPiecesInRow = 0; for(NSUInteger column = 0; column < self.columns; column++) { if([[self playerAtRow:row column:column] isEqualTo:playerInFirstColumn]) { playerPiecesInRow++; } } if(playerPiecesInRow >= numberOfPiecesInARowToWin && playerInFirstColumn.symbol != PSBoardSymbolNone) { self.winner = playerInFirstColumn; return; } } //Check vertical lines for(NSUInteger column = 0; column < self.columns; column++) { PSPlayer *playerInFirstRow = [self playerAtRow:0 column:column]; NSUInteger playerPiecesInColumn = 0; for(NSUInteger row = 0; row < self.rows; row++) { if([[self playerAtRow:row column:column] isEqualTo:playerInFirstRow]) { playerPiecesInColumn++; } } if(playerPiecesInColumn >= numberOfPiecesInARowToWin && playerInFirstRow.symbol != PSBoardSymbolNone) { self.winner = playerInFirstRow; return; } } //Check top left to bottom right diagonal PSPlayer *playerInFirstSlotOfLeftDiagonal = [self playerAtRow:0 column:0]; NSUInteger playerPiecesInLeftDiagonal = 0; for(NSUInteger row = 0, column = 0; row < self.rows; column++, row++) { if([[self playerAtRow:row column:column] isEqualTo:playerInFirstSlotOfLeftDiagonal]) { playerPiecesInLeftDiagonal++; } } if(playerPiecesInLeftDiagonal >= numberOfPiecesInARowToWin && playerInFirstSlotOfLeftDiagonal.symbol != PSBoardSymbolNone) { self.winner = playerInFirstSlotOfLeftDiagonal; return; } //Check bottom left to top right diagonal PSPlayer *playerInFirstSlotOfRightDiagonal = [self playerAtRow:self.rows-1 column:0]; NSUInteger playerPiecesInRightDiagonal = 0; for(NSInteger row = self.rows-1, column = 0; row >= 0; row--, column++) { if([[self playerAtRow:row column:column] isEqualTo:playerInFirstSlotOfRightDiagonal]) { playerPiecesInRightDiagonal++; } } if(playerPiecesInRightDiagonal >= numberOfPiecesInARowToWin && playerInFirstSlotOfRightDiagonal.symbol != PSBoardSymbolNone) { self.winner = playerInFirstSlotOfRightDiagonal; return; } } -(void)display { NSMutableString *displayString = [NSMutableString stringWithFormat:@"\n"]; for(NSUInteger row = 0; row < self.rows; row++) { NSMutableString *rowDisplayString = [[NSMutableString alloc] init]; NSString *innerFillerString = (row == self.rows-1) ? @" " : @"_"; for(NSUInteger column = 0; column < self.columns; column++) { NSString *columnSeparator = (column == self.columns-1) ? @" " : @"|"; NSString *playerSymbol = ([self playerAtRow:row column:column].symbolStringRepresentation); if(playerSymbol.length == 0) { playerSymbol = innerFillerString; } [rowDisplayString appendString:[NSString stringWithFormat:@"%@%@%@%@", innerFillerString, playerSymbol, innerFillerString, columnSeparator]]; } [displayString appendString:[NSString stringWithFormat:@"%@\n", rowDisplayString]]; [rowDisplayString setString:@""]; } NSLog(@"%@", displayString); } -(PSPlayer *)playerUp { PSPlayer *nextPlayerUp = self.players[1-([self.players indexOfObjectIdenticalTo:self.oldPlayerUp])]; PSPlayer *previousPlayerUp = self.oldPlayerUp; self.oldPlayerUp = nextPlayerUp; return previousPlayerUp; } @end PSPlayer.h #import <Foundation/Foundation.h> typedef NS_ENUM(NSInteger, PSBoardSymbol) { PSBoardSymbolX = 0, PSBoardSymbolO, PSBoardSymbolNone }; @interface PSPlayer : NSObject -(instancetype)initWithSymbol:(PSBoardSymbol)symbol name:(NSString *)name; @property (nonatomic) PSBoardSymbol symbol; @property (nonatomic) NSString *symbolStringRepresentation; @property (nonatomic, strong) NSString *name; @end PSPlayer.m #import "PSPlayer.h" @implementation PSPlayer -(instancetype)initWithSymbol:(PSBoardSymbol)symbol name:(NSString *)name{ if(self = [super init]) { self.symbol = symbol; self.symbolStringRepresentation = (symbol == PSBoardSymbolO) ? @"O" : ((symbol == PSBoardSymbolX) ? @"X" : @""); self.name = name; } return self; } @end PSInputHandler.h #import <Foundation/Foundation.h> @interface PSInputHandler : NSObject +(NSString *)getString; +(NSInteger)getInteger; @end PSInputHandler.m #import "PSInputHandler.h" @implementation PSInputHandler +(NSInteger)getInteger { int temp; scanf("%i", &temp); return (NSInteger)temp; } +(NSString *)getString { char input[256]; scanf("%s", input); return [NSString stringWithUTF8String:input]; } @end So my questions are: In the PSInputHandler.m class, I wasn't so sure about how to get input from the command line. I read that fgets() is a potential alternative to scanf(), but is there any reason for me to use one over the other? The method in PSBoard.m that checks for a winner, checkForWinner, is very long. Is there a simplified design I can use to shorten it? I struggled to name the playerUp method, which returns the player whose turn it is. Is there a more suitable name? When the user inputs which row and column to place an X or O in, I made it so that the coordinates they enter are from 1 to the number of rows and not 0 to the number of rows minus one (like with zero-based array indexing). Is this more user-friendly, or should I change it to zero-based indexing? In PSPlayer.m, I use nested ternary operators. Is this too hard to understand? Should I change it to if statements? When getting the user's input for how many rows and columns to use, which I expect to be an integer, how can I sanitize the input so that the program doesn't crash when a string (for example) is inputted? Any other critique welcome!
I will update this post over the weekend as I go through your question more and come up with some examples to iterate over my points, but I thought for now, I'd answer some of the easier questions. Question 1. I'm not sure and cannot remember (I will try to find out). At the end of the day, you might consider implementing this with a GUI. If you're using Xcode, it's quite easy to develop a GUI for either OSX or iOS, and most of your logic is already in place. You'd just have to write the logic to hook the GUI up to the business logic. Question 2. One immediate thought on speeding up this process would be to use a flag to mark whether or not a row/column is a potential winner. AND, if you do find a row that's a winner, immediately return the winner. For a row to be a winner, every piece in the row must belong to the same player, correct? So set the owner of the piece in the first box, and check every box. As soon as you get to a box that doesn't match the first box, break;. You don't need to check any more boxes in that row/column/diagonal. You can move to the next row/column/diagonal. And if you get to the end of the inner loop and haven't had to break; because you've found the winner, then you can set the winner and return; and stop checking. So basically, refactor into something more like this: for(NSUInteger row = 0; row < self.rows; row++) { PSPlayer *playerInFirstColumn = [self playerAtRow:row column:0]; BOOL winnerFound; for(NSUInteger column = 0; column < self.columns; column++) { if(![[self playerAtRow:row column:column] isEqualTo:playerInFirstColumn]) { winnerFound = false; break; } else { winnerFound = true; } } if (winnerFound) { self.winner = playerInFirstColumn; return; } } This will improve performance some. You can probably still do better, but this is still a drastic improvement, especially for exceptionally large boards. Now... the BEST performance improvement I can think of would actually mean you're running this check after every turn (which you're already doing, right?). In this case, you only need to check ONE row, ONE column, and ZERO, ONE, or TWO diagonals. And this would be a massive performance boost. You only need to check a the row the piece was played in, the column the piece was played in, and the diagonal the piece was played in. Every other row, column, and diagonal has been checked on a previous turn and a winner was not found otherwise the game would be over and we wouldn't've had this turn. AND, even if we modified the rules to continue playing after a winner has been found, you can just use an array to keep track of each row and column and diagonal and who won that row/column/diagonal, and still only need to check the relevant rows (and only check them for the player who played the piece). Question 3. playerUp is probably an alright method name. Maybe activePlayer? If you feel it's not descriptive enough, don't hesitate to leave a comment explaining it. // returns the player whose turn it is Question 4. As a programmer, I am used to 0-based indexing systems, but your assumption is correct. Most people who use programs aren't programs and would be more comfortable with a 1-based coordinate system. Though... back to question 1... if this were given a GUI, it wouldn't matter. ;) Question 5. Personally, I hate the ternary operators and never use them. Whether or not they're acceptable would depend largely on who you're working with though. In this case, it's a simple one. Again, personally, I hate them and I wouldn't use it, because I never use it, but this one is simple enough that if you and everyone working on the project are comfortable with them, then go ahead and keep it. Question 5.1. The exact way you want to handle non-number input is an implementation detail that'd be up to you. Do you want to request another input? Do you want to just strip out the non-numbers and use the numbers that are there? But as for actually checking the string itself, once you've got it into an NSString, it's quite easy: NSCharacterSet *nonNumbers = [[NSCharacterSet decimalDigitCharacterSet] invertedSet]; if([yourString rangeOfCharactersFromSet:nonNumbers].location == NSNotFound) { // string is all numbers and is good to go } else { // string contains non-number characters }
0.666667
How do you handle non-number input?
Setting up form table checkboxes
I'm trying to create a form table with a column of checkboxes. The theming isn't working with the code below. All help is appreciated :) myadmin.module function myadmin_menu() { $weight=0; $t = get_t(); $items = array(); $items['myadmin_dispute'] = array( 'title' => 'Dispute Queue', 'access arguments' => array('view myadmin'), 'page callback' => 'drupal_get_form', 'page arguments' => array('myadmin_dispute'), 'file' => 'myadmin_dispute.php', 'type' => MENU_NORMAL_ITEM, 'expanded' => true, 'weight' => $weight++, 'menu_name' => 'myadmin', 'module' => 'myadmin', ); } myadmin_dispute.php function myadmin_dispute($form_state) { //add output - css and javascript to include drupal_add_js ( drupal_get_path ( 'module', 'myadmin' ) . '/scripts/jquery.tablesorter.js' ); drupal_add_js ( drupal_get_path ( 'module', 'myadmin' ) . '/scripts/myadmin.js' ); drupal_add_css ( drupal_get_path ( 'module', 'myadmin' ) . '/blue/style.css' ); $disputes = array ( array('uid' => 1, 'first' => 'Joe', 'last' => 'Smith'), array('uid' => 2, 'first' => 'Susan', 'last' => 'Doe'), array('uid' => 3, 'first' => 'John', 'last' => 'Doe'), ); foreach($disputes as $dispute) { $checkboxes[$dispute['uid']] = ''; $form[$dispute['uid']]['first_name'] = array ( '#value' => $dispute['first'], ); $form[$dispute['uid']]['last_name'] = array ( '#value' => $dispute['last'], ); } $form['checkboxes'] = array ( '#type' => 'checkboxes', '#options' => $checkboxes, ); $form['#theme'] = 'dispute_theme'; return $form; } function myadmin_dispute_theme() { return array ( 'dispute_theme' => array ( 'arguments' => array('form' => NULL), ), ); } function theme_dispute_theme($form) { $rows = array(); foreach(element_children($form['checkboxes']) as $uid) { $row = array(); $row[] = drupal_render($form['checkboxes'][$uid]); $row[] = drupal_render($form[$uid]['first_name']); $row[] = drupal_render($form[$uid]['last_name']); $rows[] = $row; } if(count($rows)) { $header = array(theme('table_select_header_cell') , t('First Name'), t('Last Name')); } else { $header = array(t('First Name'), t('Last Name')); $row = array(); $row[] = array ( 'data' => t('No users were found'), 'colspan' => 2, 'style' => 'text-align:center', ); $rows[] = $row; } $output = theme('table', $header, $rows); return $output . drupal_render($form); } function myadmin_dispute_submit($form_id, &$form_state) { } Update, this is needs to work for drupal 6 instance.
Drupal has a built-in tableselect element type for situations just like this, it would be a lot easier to use that instead: $disputes = array( 1 => array('Joe', 'Smith'), 2 => array('Susan', 'Doe'), 3 => array('John', 'Doe') ); $header = array(t('First Name'), t('Last Name')); $form['checkboxes'] = array( '#type' => 'tableselect', '#header' => $header, '#options' => $disputes, '#empty' => 'No users were found.' ); The above code produces this table: In your form submit function you can get the selected user ids with code like this: $selected_uids = array_filter($form_state['values']['checkboxes']); EDIT The above is for Drupal 7, if you're using Drupal 6 you can use the same code but you need to install the Elements module.
0.888889
Drupal 7 uses tableselect element type
What is the proper way to change the section title font in LaTeX?
Suppose I wanted to use a different font for a title then the body text in LaTeX (pdflatex). (For example, if I wanted to use a slightly fancier font for titles, or a sans-serif one.) How would I do that, change the font of a class of thing throughout the document, in a proper way. (Likewise, if I wanted to change the document title, captions, etc. Is there a general way of doing this?)
The titlesec or sectsty packages are your friends for the standard classes. If you want some more control, try the komascript classes or memoir. See the UKTeXFAQ.
1
The titlesec or sectsty packages are your friends for the standard classes
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?
As reported by the NOAD and the OED, Epitome is pronounced /Ι™ΛˆpΙͺdΙ™mi/ in American English and /ΙͺˈpΙͺtΙ™mi/ (or /Ι›ΛˆpΙͺtΙ™mi/) in British English.
1
Epitome is pronounced in American and British English
Combine multiple unix commands into one output
I need to search our mail logs for a specific e-mail address. We keep a current file named maillog as well as a week's worth of .bz2 files in the same folder. Currently, I'm running the following commands to search for the file: grep [email protected] maillog bzgrep [email protected] *.bz2 Is there a way combine the grep and bzgrep commands into a single output? That way, I could pipe the combined results to a single e-mail or a single file.
You can tie the commands together with && which will allow you to run each command. you could also add >> textfile.txt to the end of each command and have the output hit a file then mail that file out.
0.888889
How to tie the commands together with &&amp
Are there /Ι”/ and /ʌ/ sounds in informal American English?
I read a book about American English. It reports that, in standard informal conversations, American English doesn't use the /Ι”/ sound; it uses the /Ι‘/ sound and /ʌ/ and /Ι™/ are not different. Are they really? That book would not use the /Ι”/ and /ʌ/ sounds, but when I look in my American English Dictionary for some words, such as more, door, and love, they are reported to be pronounced /mΙ”r/, /dΙ”r/, and /lʌv/. How should I pronounce these words, if there are no /Ι”/and /ʌ/ sounds? Should they be /mΙ‘r/, /dΙ‘r/, and /lΙ™v/? Can /Ι‘/ sound replace /Ι”/, and /Ι™/ replace /ʌ/ in every word? What about formal American English? Does it have /Ι” /and /ʌ/ sounds or not?
Standard English has all of the sounds you mention, but, yes there are some quirks. Some dialects of English don't distinguish between /Ι”/ and /Ι‘/; this is known as the caught-cot merger. It is so called because caught and cot are both pronounced the same: (/kɒːt/ or /kΙ‘t/ depending on the region). As you can see in the Wikipedia article and the accompanying map, some dialects have merged these vowels together, but many have not. Now, as for /Ι™/ and /ʌ/ β€”Β AmE does have both of these sounds, but in most cases the pattern is totally predictable. In stressed syllables, /ʌ/ can occur, while in unstressed syllables, only /Ι™/ is used. In Standard British English, there is more use of /Ι™/, in part because Standard BrE doesn't pronounce /ΙΉ/ (henceforth /r/) syllable-finally. So a word like nurse, which in American English would be pronounced /nɝs/ (with an r-colored vowel), can be pronounced /nΙ™:s/ in British English (though it isn't always). So, with this information in mind, on to your examples: "More" and "door" Examples with syllable-final /r/ are generally going to be special, as indeed these are. In Standard AmE, these are pronounced /mΙ”r/ and /dΙ”r/, as you read. In dialects that don't pronounce /Ι”/, the words are pronounced /mor/ and /dor/. In situations that aren't r-colored, it is indeed /Ι‘/ (again, in certain US dialects). "Love" Following the rules I laid out above, you may have figured out that love is pronounced /lʌv/ in AmE, as it is a stressed syllable. But, if it were unstressed, it would theoretically be pronounced with a schwa. So, let's take a different example: the word "just" /dΚ’ΚŒst/ is sometimes stressed and sometimes unstressed. When unstressed (often when saying something like "just do it already"), the word becomes /dΚ’Ι™st/.
1
// and /kt/ merged vowels together in Standard English
Going round in Circles..Buffering/ArcObjects/VBA
I've just started learning VBA and Arcobjects, and at the moment just playing around tyring to do different things. What i am trying to do is Click on a tool, and allow the user to put a point graphic on the map, but also buffer the point(marker) that has been added. I can get the point on the map, but seem to be going round in circles getting the buffer to work. Can someone give me some hints ( i dont want the exact answer just some guidance on where I am going wrong. Code is here. Private Sub Buffer_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long) Dim pMxDoc As IMxDocument ' Create Object for current document Set pMxDoc = ThisDocument ' Set object to current Document Dim pMap As IMap ' Create object for current map Set pMap = pMxDoc.FocusMap ' Set object to the current active map Dim pPoint As IPoint 'Create object for point on map Set pPoint = pMxDoc.CurrentLocation ' Set object to current location Dim pElement As IElement ' Create object for graphic THAT IS ADDED TO THE MAP!!!! Set pElement = New MarkerElement ' Set object to a new marker element (point graphic) pElement.Geometry = pPoint ' Assign the geometry of the element to the Point. Dim pGraphics As IGraphicsContainer ' Create object to hold the graphic Set pGraphics = pMap ' Set object to current active map pGraphics.AddElement pElement, 0 ' Set the graphic that will be added Dim pActiveView As IActiveView ' Create object for active map display Set pActiveView = pMxDoc.ActiveView ' Set object to the Active view '--------------CREATE BUFFER------------------------' Dim pSpaRef As ISpatialReference3 Set pSpaRef = pMap.SpatialReference Dim pFCBuffer As IFeatureCursorBuffer2 ' Create Object for buffer Set pFCBuffer = New FeatureCursorBuffer ' Set object for new buffer pFCBuffer.Dissolve = True pFCBuffer.ValueDistance = 100 Set pFCBuffer.BufferSpatialReference = pSpaRef Set pFCBuffer.DataFrameSpatialReference = pSpaRef Set pFCBuffer.SourceSpatialReference = pSpaRef Set pFCBuffer.TargetSpatialReference = pSpaRef Dim pCGLayer As ICompositeGraphicsLayer2 Set pCGLayer = New CompositeGraphicsLayer Dim pGLayer As IGraphicsLayer Set pGLayer = pMap.ActiveGraphicsLayer pFCBuffer.BufferToGraphics pGLayer pActiveView.PartialRefresh esriViewGraphics, pElement, Nothing ' [partial refresh of the graphics element. End Sub Thanks Halil
Halil, The interface you are using to create the buffers IFeatureCursorBuffer2 creates buffers for selected features. Your point that you create based upon the users button click is not a feature but a graphic which you are adding to the graphics container of the map. A Feature is essentially a row in a table or featureclass. As you are adding your point as a graphic I assume the buffer you want to create will also end up as a graphic. Use the interface ITopologicalOperator and it's method Buffer to create a polygon then do as you did with your point, create a graphic element. Duncan
0.888889
IFeatureCursorBuffer2 creates buffers for selected features
Resistance of superconducting wire in parrallel with standard wire
The formula for parrallel resistors is $\frac{1}{R_T} = \frac{1}{R_1} + \frac{1}{R_2}$ But how can you use this formula when one of the branches is a superconductor, eg: Where the red resistor represents a wire with some resistance and the blue line represents a superconducting wire, how can the above equation be used to find the resistance between A and B, as it would mean dividing by zero?
That formula is not in any way fundamental, the singularity at $R_i\to 0$ doesn't have much of a physical meaning, rather it means that the assumptions with which this formula was derived are violated. Namely that the voltage is nonzero. The total resistance must be such that $$ U = R_{\mathrm{tot}}\cdot I_{\mathrm{tot}}. $$ Since it's a parallel circuit, this is also $$ U = R_1\cdot I_1 = R_2\cdot I_2. $$ But if one of the resistances is zero, this expression must be zero, and therefore (the total current being nonzero) we have $R_{\mathrm{tot}}=0$. Which is quite intuitive as said in Chris Gerig's comment: if there's a perfect shortcut, why would any electrons bother to take the path with nonzero resistance? They don't, so it wouldn't change anything to simply take the resistor away, in which case only the superconductor would be left, still with a resistance $0$. Also note that a superconductor doesn't actually have zero resistance, just very much less than ordinary conductors. So you could still use the formula $$ \frac1{\tfrac1{R_1}+\tfrac1{R_2}} $$ where, since $R_1\gg R_2$, $$ \tfrac1{R_1}+\tfrac1{R_2}\approx \tfrac1{R_2} $$ and therefore $$ \frac1{\tfrac1{R_1}+\tfrac1{R_2}} \approx \frac1{\frac1{R_2}} = R_2 \approx 0. $$
0.666667
Why would electrons bother to take the path with nonzero resistance?
Why are the ringwraiths fearful of coming in contact with water?
At least twice in LoTR:FotR, ringwraiths cower away from bodies of water. The second time (the ford of Bruinen) can be explained away by their fear of some Elvish magical trap through the enchantment of the water; but what about the first time, at the ferry? One of the Nazgul could have easily made the jump onto the barge and quickly dispatched those pesky Hobitsses.
It is very plausible that it is a holdover of the power of Ulmo. See this forum thread for more... http://forum.barrowdowns.com/archive/index.php?t-201.html
1
Ulmo's power is a holdover
Setting a default placeholder image WITHOUT link
Can anyone help? I'm trying to show a default placeholder image on my posts when the user hasn't uploaded an image. I have the below code BUT i need to rewrite it so that the link isn't applied to the placeholder image - only the uploaded image. Unfortunately my PHP isn't great at all so would appreciate some help.. <div class="imageContainer"><a href="<?php the_permalink(); ?>"> <?php // Must be inside a loop. if ( has_post_thumbnail() ) { the_post_thumbnail('size-2'); } else { echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/shared/placeholder.jpg" />'; } ?> </a></div>
You can filter the thumbnail HTML before it is printed out. If it is empty – return the placeholder. This should go into your theme’s functions.php: add_filter( 'post_thumbnail_html', 'wpse_63591_default_thumb' ); function wpse_63591_default_thumb( $html ) { if ( '' !== $html ) { return '<a href="' . get_permalink() . '">' . $html . '</a>'; } return '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/shared/placeholder.jpg" />'; } In your template just use the_post_thumbnail('size-2'); No conditionals or complicated PHP needed anymore. :)
0.777778
How to filter thumbnail HTML before printing out
Oracle: function only returning null
The following function is supposed to return information relating to a particular meeting, stored in a meeting table: CREATE TABLE "MEETING" ( "MEETING_ID" NUMBER(10,0) NOT NULL ENABLE, "TIME" TIMESTAMP (4) NOT NULL ENABLE, "LOCATION" VARCHAR2(40), "MAP_HREF" VARCHAR2(140), "FK_INTEREST_ID" CHAR(4) NOT NULL ENABLE, "ADDITIONAL_INFO" CLOB, "PASSED" NUMBER(1,0), "TITLE" VARCHAR2(20), CONSTRAINT "MEETING_PK" PRIMARY KEY ("MEETING_ID") ENABLE ) ; The code compiles just fine, and runs fine as well. However, if the meeting exists, only null is returned. If the meeting doesn't exist the exception prints 'UNKNOWN APPOINTMENT' correctly. CREATE OR REPLACE FUNCTION GetMeeting (meetingnumber MEETING.MEETING_ID%TYPE) RETURN VARCHAR IS CURSOR current_meeting(meetingnumber MEETING.MEETING_ID%TYPE) IS SELECT TITLE FROM MEETING WHERE MEETING_ID = meetingnumber; r_meeting current_meeting%ROWTYPE; BEGIN OPEN current_meeting(meetingnumber); FETCH current_meeting INTO r_meeting; IF current_meeting%NOTFOUND THEN r_meeting.TITLE := 'UNKNOWN APPOINTMENT'; END IF; CLOSE current_meeting; RETURN r_meeting.TITLE; END; SELECT GetMeeting (27) appointment FROM MEETING;
PL/SQL Function works fine. It returns the desired result, but your select returns as much datasets, as are present in MEETING. You should select from dual instead.
0.777778
PL/SQL Function returns the desired result
How to use AJAX.BeginForm?
I am developing an ASP.NET MVC 3 application. I want to use AJAX.BeginForm. What are some links to resources/tutorials where this could be studied in detail?
Try at Unobtrusive Ajax helpers in MVC3. Updated Or try ASP.NET MVC 3 Beta & Razor View Engine Using Ajax.BeginForm with ASP.NET MVC 3 Razor Walkthrough: Adding ASP.NET AJAX Scripting to an MVC Project
0.888889
Unobtrusive Ajax Helpers in MVC3 Updated Or Try ASP.NET MVC 3 Beta &
Where would one find thermal heat sink cases?
I am looking for a case that would work well as a heat sink. Thinking that something like a car amplifier case? Anyone know where one could find cases like this? Would be using it to house H-Bridges and fill it with thermal conductive epoxy to water proof it....
One of these extruded aluminium ones?
1
extruded aluminium ones?
ERR_SSL_PROTOCOL_ERROR in chrome 39 and 40 but works in chrome 36.Help fix in chrome 39
I am able to access a URL in Chrome 36 and IE8 but in Chrome 39 or 40 or Firefox 35 it throws the error: Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have. Error code: ERR_SSL_PROTOCOL_ERROR}. It seems that it is an issue related to the SSL certificate. How can I fix this?
Google announced that they would begin removing support for SHA-1 cryptographic hash algorithm beginning with Chrome 39. According to Google: HTTPS sites whose certificate chains use SHA-1 and are valid past 1 January 2017 will no longer appear to be fully trustworthy in Chrome’s user interface. There are several sites which can provide detailed analysis of your SSL certificate chain, such as Qualys SSL Labs' SSL Test. Google Chrome does have a highly risky command-line option --ignore-certificate-errors which might bypass certain certificate errors. Be aware that ignoring certificate errors puts all of your SSL traffic at risk of being eavesdropped on. It's also possible that this is a new bug. Google switched from using OpenSSL library to it's own "BoringSSL" library in Chrome 38. To report a bug in Chrome visit chrome://help/ and click "Report an issue".
0.833333
removing support for SHA-1 cryptographic hash algorithm beginning with Chrome 39
How can I superimpose LaTeX / TeX output over a PDF file?
I have a form as a PDF file. I would like to use LaTeX/TeX to overlay my text over the form, and send the output to either a print or another PDF file. Is this possible? How would I go about it?
You can use TikZ to place the form as image at the center of an otherwise empty page and then draw on it. This is similar to the suggested pdfpages solution but avoid passing around the tikzpictures, which isn't really necessary. See also Drawing on an image with TikZ and Is there the easiest way to toggle (show/hide) navigational grids in TikZ? for related code. You could even add real PDF form fields to it. See Creating fillable PDFs for how it can be done. \documentclass[letterpaper]{article}% ensure identical page size \usepackage{tikz} \pagestyle{empty} \begin{document} % Page 1 \begin{tikzpicture}[remember picture,overlay] \node at (current page.center) {\includegraphics[page=1]{form}}; \begin{scope}[shift={(current page.south west)},every node/.style={anchor=base west}] % Grid to help find the positions (remove in final version) \draw [help lines] (0,0) grid (current page.north east); \draw [help lines,thick] (0,0) grid [step=5cm] (current page.north east); % \node at (2cm,9.75cm) {John Doe}; \node at (13cm,9.75cm) {\today}; \end{scope} \end{tikzpicture} \clearpage % Page 2 \begin{tikzpicture}[remember picture,overlay] \node at (current page.center) {\includegraphics[page=2]{form}}; \begin{scope}[shift={(current page.south west)},every node/.style={anchor=base west}] % Grid to help find the positions (remove in final version) \draw [help lines] (0,0) grid (current page.north east); \draw [help lines,thick] (0,0) grid [step=5cm] (current page.north east); % %\node at (2.5cm,10.75cm) {John Doe}; \end{scope} \end{tikzpicture} \clearpage \end{document} This example used the IEEE copyright form. Just download it and rename it to form.pdf. The second page actually does not include any fillable form fields, but I found it important to show how to handle multiple pages.
1
How to use TikZ to place the form as image at the center of an otherwise empty page
Woocommerce: change user role after completing order
:) I'm using wordpress with woocommerce, and I would like to automate the following step. When an order is completed, I would like to change the user role associated with that order id from 'customer' to 'subscriber'. By searching around, I think I should be able to accomplish this by using a hook in functions.php: add_action( 'woocommerce_order_status_completed', 'change_role_from_customer_to_subscriber' ); Then add the function: function change_role_from_customer_to_subscriber($order_id){ // code to change role to subscriber } In the code, I think I need to do 2 things: 1) get the user id that is associated with that order id 2) change role of that user id to subscriber I've tried a lot, but I couldn't get it to work (neither getting the right user id, nor changing the role of a user id). So any help would be appreciated! I've seen 2 related questions asked before on stack overflow, but unfortunately the answers there did not work for me. I hope someone can help me out! Thanks a lot! :) Edit: Someone helped me out with the second part of the problem, so that's great news for me :) Unfortunately, I still haven't figured out the first part: how to get the user id that is associated with the order id. Any ideas?
Looking through the code there is a very relevant example: function woocommerce_paying_customer( $order_id ) { $order = new WC_Order( $order_id ); if ( $order->user_id > 0 ) { $old_spent = absint( get_user_meta( $order->user_id, '_money_spent', true ) ); update_user_meta( $order->user_id, '_money_spent', $old_spent + $order->order_total ); $old_count = absint( get_user_meta( $order->user_id, '_order_count', true ) ); update_user_meta( $order->user_id, '_order_count', $old_count + 1 ); } } add_action( 'woocommerce_order_status_completed', 'woocommerce_paying_customer' ); which reminds us that the $order_is passed to the woocommerce_order_status_completed hook. From the $order_id, you can create a new order object, with the user_id as a property. Armed with that knowledge, I think we can just fix the inner guts of the function get a new user object from that user ID, and remove the old role and finally apply the new role. function wpa_120656_convert_paying_customer( $order_id ) { $order = new WC_Order( $order_id ); if ( $order->user_id > 0 ) { update_user_meta( $order->user_id, 'paying_customer', 1 ); $user = new WP_User( $order->user_id ); // Remove role $user->remove_role( 'customer' ); // Add role $user->add_role( 'subscriber' ); } } add_action( 'woocommerce_order_status_completed', 'wpa_120656_convert_paying_customer' );
1
wpa_120656_convert_paying_customer
Amazon Ec2: Problem In Setting up FTP Server
after setting up My vsFtp Server ON Ec2 i am facing problem , my client is Filezilla and i am getting this error Response: 230 Login successful. Command: OPTS UTF8 ON Response: 200 Always in UTF8 mode. Status: Connected Status: Retrieving directory listing... Command: PWD Response: 257 "/" Command: TYPE I Response: 200 Switching to Binary mode. Command: PASV Response: 500 OOPS: invalid pasv_address Command: PORT 10,130,8,44,240,50 Response: 500 OOPS: priv_sock_get_cmd Error: Failed to retrieve directory listing Error: Connection closed by server this is the current setting in my vsftpd.conf #nopriv_user=ftpsecure #async_abor_enable=YES # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd/banned_emails # chroot_local_user=YES #chroot_list_enable=YES # (default follows) #chroot_list_file=/etc/vsftpd/chroot_list GNU nano 2.0.6 File: /etc/vsftpd/vsftpd.conf # #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd with two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES pasv_enable=YES pasv_min_port=2345 pasv_max_port=2355 listen_port=1024 pasv_address=ec2-xxxxxxx.compute-1.amazonaws.com pasv_promiscuous=YES Note: i have already open those port in security group i mean listen port, min max if someone shows me how to fix this i will be very greatful thanks
pasv_address= IP address you need an Elastic IP
1
pasv_address= IP address
I can't find a PFET protected against ESD
I like to use OmniFETs for MOSFETs because they have internal protection against ESD so I am unlikely to damage them while handling and then when they don't work I don't have to wonder if it was damaged or I have a circuit mistake. These are n-channel FETs, but now I need a p-channel FET. I tried to find one Mouser and Digikey, but was unsuccessful. Is there such a thing? It would basically be a MOSFET and a diode in one package. Other things like over-current and over-temperature protection would also be nice, but are less important.
I suspect the device you are looking for is known as a "intelligent high-side switch" (a), (b) or a "smart high-side switch". Such as the following (which all mention electrostatic discharge protection in their datasheets): the STM VN540-E the INF BTS50080-1TMA the INF BTS50080-1TMB the INF BTS50085-1TMB the IRF AUIPS7081 the IRF IPS521 etc.
0.888889
a "intelligent high-side switch" (a), (b) or "smart high side switch"
Wordpress 4 invalid username special charachters issue
I have some danish users that uses special chars like æøΓ₯ and they can't log in to my wordpress blog. I tried on a fresh install on 4.2.2 and on 4.1.5 and it did not work, for example Andrew SchΓΈnnemann with a simple password and it did not work, got message ERROR: Invalid username. Lost your password?. But with user Andrew Schonnemann works fine, what could be the issue?
Are you creating your users via regular means or somehow importing them? Trying to create such user WP prevents me from doing so: ERROR: This username is invalid because it uses illegal characters. Please enter a valid username. The reason for that is that username is validated with validate_username(), which runs sanitize_user() in strict mode. That reduces available characters to basic ASCII set. In a nutshell WP doesn't consider that a valid username. So the question is β€” is that actually a username in your case? Your users might be confusing Username with First/Last name fields, which are not used for login. If you do want to support usernames like that you will have to override WP validation via hooks. That would probably take some serious testing to make sure it works properly and doesn't introduce security issues.
0.888889
WP doesn't consider that a valid username
How can adversarial game mechanics be added to a game?
Some systems have the concept of an adversarial relationship between the game master and the players. These games typically have a series of mechanics to enforce this behavior and prevent one side from becoming too powerful and running away with the game - essentially accentuating the "game" aspect of a RPG. What mechanics of this nature are most likely to be easily adapted into another role-playing game? To illustrate what I'm talking about, in D&D, there are guidelines for encounter creation to create balanced encounters. How could we change this to add hard game mechanics that would enforce fairness in encounter design? As an addenda, it would also be nice to see what games these mechanics come from and how easy they are to extract from the system they were built for.
In Rune, Robin Laws' Viking RPG, the GM has to create all challenges via a very strict budgeting system as players earn Victory Points with the goal of "winning" the game. This allows for adversarial play within tightly defined bounds. Unfortunately, it also means it's a colossal pain to create adventures for as a GM - I'm a big Laws fan and bought Rune sight unseen on the heels of Feng Shui but then it just sat on my shelf, as my desire to be a Norse accountant is extremely low. This is similar to the direction D&D has taken in 3e and 4e with set rules for encounter CR and now in 4e with set treasure parcels. Although in my opinion that's less fostering GM vs players as it is attempting to remove the GM or at best make them the engine under the hood. Paranoia is a good game where the gamemaster is encouraged to "hose" the players. This is mitigated by a) them having six clones, so an arbitrary death isn't the worst thing in the world and b) it being a humor game, so effectively you win by the GM stomping you out in entertaining ways. This is before everyone was obsessed with "mechanical rewards" for the point of the game, though, so it's not like you get extra "points" of some sort when it happens. But people have played it and had fun for many years. In Mutants & Masterminds they had Hero Points and when they'd spend them the villains would get Villain Points. This went over very poorly with my group - rightly or wrongly, they felt like people besides themselves having resource driven plot immunity sucked.
1
In Rune, Robin Laws' Viking RPG, the GM must create all challenges via a strict budgeting system .
I can get visual studio for free through school, should I?
I am currently using dev++, I am a complete beginner, (Freshman CS major) learning C++. I can get one of the newest versions of visual studio (2008 or 2009 i think) for free through my school. Not sure if it is worth the trouble of getting. thoughts?
If by "dev++" you mean this monstrosity, then drop it as fast as you can. There have been no updates to Dev-C++ in over six years, it's buggy, comes with a really ancient version of gcc and is not worth the cost of the download. Visual C++, on the other hand, is a world-class compiler and one of the best the IDEs available. That you can get it for free is great (even the Express Editions are light years ahead of Dev-C++) and I wouldn't hesitate.
0.777778
No updates to Dev-C++ in over six years .
Increasing number of decimal places with FixedPoint
I've tried: In[169]:= newton3[x_] := N[1/2 (x + 3/x)]; FixedPointList[newton3, 1.0] Out[170]= {1., 2., 1.75, 1.73214, 1.73205, 1.73205, 1.73205} Of course: In[164]:= N[Sqrt[3], 20] Out[164]= 1.7320508075688772935 How do you use the FixedPointList to increase the number of decimal places?
You can also change the number of digits in the solution by setting smaller the criterion for convergence through SameTest, as in: FixedPointList[(# + 3/# )/2 &, 1`20, SameTest -> (Abs[#1 - #2] < 1*^-10 &)] {1.0000000000000000000, 2.0000000000000000000, 1.7500000000000000000, \ 1.7321428571428571429, 1.7320508100147275405, 1.7320508075688772953, \ 1.7320508075688772935}
0.888889
Change the number of digits in the solution using SameTest
MVC3 Actionlink with submit
I am new MVC user and I am trying to make shopping cart as following MVC Music Store tutorial I am trying to pass the radiobutton value which is different price types through actionlink. Is it possible to pass the value with productId? When I click the link, it will call 'AddToCart' method. Could you help me? thanks. Product model namespace MvcApplication2.Models { public class Product { [Key] public int productId { get; set; } public int categoryId { get; set; } [Required(ErrorMessage = "Product model name is required")] public String model { get; set; } [DisplayFormat(DataFormatString = "{0:0.#}")] public decimal displaySize { get; set; } public String processor { get; set; } public int ramSize { get; set; } public int capacity { get; set; } public String colour { get; set; } public String description { get; set; } public decimal price { get; set; } public decimal threeDayPrice { get; set; } public decimal aWeekPrice { get; set; } public decimal twoWeekPrice { get; set; } public decimal aMonthPrice { get; set; } public decimal threeMonthPrice { get; set; } public decimal sixMonthPrice { get; set; } //public decimal sixMonthPrice { get { return price * 0.25M; } } public int stock { get; set; } public virtual Category Category { get; set; } } } details.cshtml @model MvcApplication2.Models.Product <td> Rental Period: <br /> @using (Html.BeginForm()) { <div class="display-label"> @Html.RadioButtonFor(model => model.price, Model.threeDayPrice) 3 day: Β£@Model.threeDayPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, Model.aWeekPrice) 1 week: Β£@Model.aWeekPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, @Model.twoWeekPrice) 2 week: Β£@Model.twoWeekPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, @Model.twoWeekPrice) 1 month: Β£@Model.twoWeekPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, @Model.threeMonthPrice) 3 month: Β£@Model.threeMonthPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, @Model.sixMonthPrice) 6 month: Β£@Model.sixMonthPrice </div> } </td> </tr> </table> <p class="button" style="margin-left:200px; width:90px;"> //Is it possible to submit the selected radiobutton value through this? @Html.ActionLink("Add to cart", "AddToCart", "ShoppingCart", new { id = Model.productId }, "") </p> ---Added controller--- ShoppingCartController.cs public ActionResult AddToCart(int id) { // Retrieve the product from the database var addedProduct = db.Product .Single(product => product.productId == id); // Add it to the shopping cart var cart = ShoppingCart.GetCart(this.HttpContext); cart.AddToCart(addedProduct); // Go back to the main store page for more shopping return RedirectToAction("Index"); }
Just use a submit button instead of an ActionLink. This way all the input values will be sent to the controller when you submit the form: @model MvcApplication2.Models.Product <td> Rental Period: <br /> @using (Html.BeginForm("AddToCart", "ShoppingCart", new { id = Model.productId }, FormMethod.Post)) { <div class="display-label"> @Html.RadioButtonFor(model => model.price, Model.threeDayPrice) 3 day: Β£@Model.threeDayPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, Model.aWeekPrice) 1 week: Β£@Model.aWeekPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, @Model.twoWeekPrice) 2 week: Β£@Model.twoWeekPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, @Model.twoWeekPrice) 1 month: Β£@Model.twoWeekPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, @Model.threeMonthPrice) 3 month: Β£@Model.threeMonthPrice </div> <div class="display-label"> @Html.RadioButtonFor(model => model.price, @Model.sixMonthPrice) 6 month: Β£@Model.sixMonthPrice </div> <button type="submit">Add to cart</button> } </td>
1
Use a submit button instead of an ActionLink
What is inspiration?
I've noticed a new mechanic in the 5th edition rules that stands out from the rest. It's called Inspiration. What is this, what is it good for and how should I as a DM grant it? It looks like it's simply a way to grant advantage for good role-playing? Is this what it's meant for or does it have more meaning than this?
You asked what's it good for? As a DM I've often struggled with players who may prefer to meta-game rather than react to a situation in character. For some groups a very tactical, min-max play style may be fine--but for other groups the DM may want to encourage playing in character. This mechanic gives the DM a nice discretionary tool to reward play that may be out of the tactical norm but might be a TON of fun for the group. For more information see page 35 of the D&D Basic Rules.
1
What's good for a meta-game?
Passing a string as function argument
I would like to use a string as argument of a function in order to use this string for the plotting of the result, but R plots the argument variable name instead of its string value. I tried different solutions (diparse, as.character...) but still no solution. Do you have any idea? mcnemar_test <- function (c1,c2,class1, class2) { name1=label(class1) name2=deparse(substitute(class2)) v1 = c1$encerts v2 = c2$encerts e00 = sum(ifelse(v1+v2==0,1,0)) #bad classification for both e01 = sum(ifelse(v1<v2,1,0)) #bad classification for 1 e10 = sum(ifelse(v1>v2,1,0)) #bad classification for 2 e11 = sum(ifelse(v1+v2==2,1,0)) #good classification for both matriu <- matrix(c(e00,e01,e10,e11),nrow = 2, dimnames = list(name1 = c("Disapprove", "Approve"), name2 = c("Disapprove", "Approve"))) print (matriu) t <- mcnemar.test(matriu) return (t) } mcnemar_test(classifiers.NaiveBayes,classifiers.CART,"aa","bb") I would like to see "aa" and "bb" but see "name1 and name2
Edit: Within your function code drop the label(.) and deparse(substitute(.)) attempts and use this: dimnames = setNames( list( c("Disapprove", "Approve"), c("Disapprove", "Approve")), c(class1, class2) )
1
Deparse (substitute(.))
cancel(getIntent().getExtras().getInt(β€œnotificationID”)); what is the return...?
cancel(getIntent().getExtras().getInt(β€œnotificationID”)); why we use of dot operator in between these methods? as cancel(int) method takes only one integer parameter.it has 3 methods as parametr.....what exactly the code will do..?
You should try going through the concepts of object oriented programming first. To answer your question, getIntent() returns an object of type intent. We call the getExtras() on the Intent object which returns an object of type Bundle. Then we call getInt() on the Bundle object to finally get the int we want to pass to the cancel() method. The statement is equivalent to : Intent i = getIntent(); Bundle b = i.getExtras(); int id = b.getInt("notificationID"); cancel(id); If we don't need any of the intermediate objects, we can write the whole thing in a single line. Hope that helps.
0.666667
GetIntent() returns an object of type intent
Problem in blitting a clean, crisp sprite
I am having a bit of a tooling problem...and I am unsure of how to solve it. I am currently using PyGame to try and write a simple Minesweeper clone, except my sprites that I made are hexagon based and therefore have diagonal lines. I drew up a nice, clean, crisp vector sprite set which looks very nice in Inkscape, however once I export it everything goes to hell. I'm going to outline what I've done below and hopefully somebody here can set me straight :D Disclaimer: Unfortunately I'm behind a proxy and cannot provide screenshots at the moment..I'll do my best to describe. If I attempt to use a color key (0xFF00FF), then when I set the color key in PyGame I get a bunch of jagged pink edges along my sprite. I believe this could be an anti-aliasing issue with Inkscape, but unfortunately my Googling didn't turn up a way to disable it. If I import my PNG into Photoshop or the Gimp and delete the background, then I run into an issue where the background appears to be black when running the game. I have tried to follow the instructions I saw on SO, but to no avail. I am open to suggestions, but at this point I'm debating importing another library which can handle SVG graphics, in order to keep my clean, crisp diagonal lines.
Try this in Photoshop: Make a new document. Make a new layer. It will be transparent. Delete the background layer. Your document should be all transparent now. It will look like a checkerboard. Draw the hexagon onto that transparent layer. Save this as a 24-bit PNG with transparency. Now bring that into PyGame. You may need to do some convert_alpha() thing to enable the alpha channel. That should give you correct anti-aliased transparency.
0.666667
Make a new layer. Delete the background layer.
What does mathematics have to do with programming?
I just started a diploma in software development. Right now we're starting out with basic Java and such (so right from the bottom you might say) - which is fine, I have no programming experience apart from knowing how to do "Hello World" in Java. I keep hearing that mathematics is pertinent to coding, but how is it so? What general examples would show how mathematics and programming go together, or are reliant on one another? I apologize of my question is vague, I'm barely starting to get a rough idea of the kind of world I'm stepping into as a code monkey student...
A problem with your question is that "mathematics" and "programming" are both very wide and deep subjects about which there is more to know than anyone could master in a lifetime (no exaggeration). I personally hold an MA degree in mathematics. During my time in university, it seemed as if the more I learned, the less I knew compared to my peers; it felt is if I became less intelligent over the years. When I presented my master's thesis to a group of professors, even most of them seemed to be largely unfamiliar with what I studied. Likewise, I am now a database-driven web application developer. If you compared me to someone who does embedded assembler language programming, you might think of us as two very talented professionals, but we would have vastly different expertise even though we're both "programmers". As you progress in your study of higher mathematics (beyond freshman calculus), you will find that mathematics instills a discipline for abstract reasoning that will serve you well when you program. I think that this discipline is very important because you will deal with abstract concerns as you program. Sure, in freshman programming, you will likely learn about pointer arithmetic. You will write short programs to illustrate this concept and your understanding of how it drives your computer obey your will. However, learning about how pointer arithmetic works in the abstract will not make you good at using pointers in a real program. When it comes time to take on a mess of 10K lines of code and make some changes to the pointer arithmetic, you will need to be able to reason at a very abstract level, making strategic decisions to balance different concerns about how your changes will affect the code. As a programmer, you must balance "readability" of your code, performance of your code, ease-of-use of the resulting programs, among many other concerns. You must be able to make very abstract comparisons to balance these concerns among one another. You will make many of these comparisons every day. I haven't even gotten started about time-management. You will abstractly reason about the probability that something you do will affect your ability to do your tasks on time, and once again, you will make many decisions every day that will affect your work. Finally, you must maintain your philosophical discipline to be able to assimilate new ideas and concepts in order to be able to continue on as old methodologies and practices fall out of use. Once again, you will have to be able to evaluate the ideas that come along and make an abstract comparison to what you already know. In short, programming, as most of us know it, doesn't have a whole lot to do with mathematics, as most of us know it; but when you look at it at an abstract level, they have a lot in common.
1
Mathematics instills a discipline for abstract reasoning when you program .
Is conditional compilation a valid mock/stub strategy for unit testing?
In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but one answer suggested using conditional compilation, retaining static binding in the production code. This answer was modded -2 at the time of reading, so at least 2 people really thought this was a wrong answer. Perhaps misuse of DEBUG was the reason, or perhaps use of fixed value instead of more extensive validation. But I can't help wondering: Is the use of conditional compilation an inappropriate technique for implementing unit test stubs? Sometimes? Always? Thanks. Edit-add: I'd like to add an example as a though experiment: class Foo { public Foo() { .. } private DateTime Now { get { #if UNITTEST_Foo return Stub_DateTime.Now; #else return DateTime.Now; #endif } } // .. rest of Foo members } comparing to interface IDateTimeStrategy { DateTime Now { get; } } class ProductionDateTimeStrategy : IDateTimeStrategy { public DateTime Now { get { return DateTime.Now; } } } class Foo { public Foo() : Foo(new ProductionDateTimeStrategy()) {} public Foo(IDateTimeStrategy s) { datetimeStrategy = s; .. } private IDateTime_Strategy datetimeStrategy; private DateTime Now { get { return datetimeStrategy.Now; } } } Which allows the outgoing dependency on "DateTime.Now" to be stubbed through a C# interface. However, we've now added a dynamic dispatch call where static would suffice, the object is larger even in the production version, and we've added a new failure path for Foo's constructor (allocation can fail). Am I worrying about nothing here? Thanks for the feedback so far!
I thought of another reason this was terrible: Many times you mock/stub something, you want its methods to return different results depending on what you're testing. This either precludes that or makes it awkward as all heck.
0.777778
How to mock/stub something?
1 GHz RF bandpass filter
Is it possible to design a good bandpass filter with center around 1GHz, using capacitors and inductors? Or does these components perform too poorly at these frequencies? I would rater not try to design my filter as a cavity filter (soldering pipes and all).
A 1 GHz filter can be built using lumped elements and might be suitable for your purposes, but a better filter could be built using microstrip or a cavity. It depends on your requirements. The filter type depends on the performance you require; for instance, a Butterworth filter is optimal in terms of pass-band ripple. I use this software for LC filter design: http://tonnesoftware.com/elsie.html. It's excellent. I'd prototype the filter on a piece of PCB material, and test and adjust it using a suitable signal generator and RF meter. If it's a one-off, you can simply mount it in a screened enclosure with the input and output connectors.
1
a 1 GHz filter can be built using lumped elements .
How to mount a NTFS USB harddrive to Mac OS X that was unsave removed from Windows?
I have a hard drive that gets plugged into several machines. One MacBook Pro running Mac OS X, some Ubuntu and Fedora Installations and sometimes Windows XP or Vista. Therefore, I formatted it NTFS to be able to read and write on it no matter which machine is used. On Mac OS I installed MacFUSE to do this. The Problem is, when the USB device is removed from a Windows box, without using the "remove hardware" function from the task bar, the drive is locked. When I wnat to mount it in Mac OS, I get an error message and have to connect it to back to Windows and cleanly unmount it. So, my question is: Is there an easy way to use the drive on every computer / OS without mounting problems?
The latest version of NTFS-3G for Mac allows you to force mount the disk, even when it wasn't disconnected properly.
0.777778
mount the disk when it wasn't disconnected properly
qemu-img: error while reading sector 327680: Invalid argument
I am trying to convert vmdk image to raw format but I am getting an error statement. qemu-img convert -f vmdk Ubuntu-12.04-LTS-Jeos-1.0-disk1.vmdk -O raw myImage.raw and I am getting following error. qemu-img: error while reading sector 327680: Invalid argument However it creates myImage.raw image with 0 disk size. I have googled it but couldn't find any solution. I am using qemu-img version 1.0 on Ubuntu 12.04 64bit. Any suggestions would be helpful
The syntax needs adjusting. Flag arguments need to come first, then the input file and then the output file. qemu-img convert -f vmdk -O raw Ubuntu-12.04-LTS-Jeos-1.0-disk1.vmdk myImage.raw If you're still getting that, it might suggest a corrupted VMDK. I just downloaded the appliance VMDK and ran: $ qemu-img convert -f vmdk -O raw Ubuntu-12.04-LTS-Jeos-1.0-disk1.vmdk myImage.raw $ ls -l myImage.raw -rw-r--r-- 1 oli oli 2147483648 Jan 16 13:35 myImage.raw That seems to work fine. Edit: This seems like it might be a side-effect of an old version of qemu. I'm using Ubuntu 13.10 with version 1.5.0 of qemu-utils. Either upgrade the version of qemu (per the question I linked to) or upgrade Ubuntu.
0.777778
qemu-img convert -f vmdk -O raw Ubuntu-12.04-LTS-
Is a VPN really secure at the VPN providers side?
Please forgive my basic ignorance regarding a VPN connection. As I understand it, a VPN connection encrypts all the data between my computer and the VPN provider. Thus preventing my ISP from seeing my data. But on the VPN providers side of the connection, surely the VPN provider uses an ISP of some sort. So they send out requests I have made over their ISP, just as if I were sitting there using the ISP they pay for. And they send the data back to me, encrypted. So on the ISP side they use, the data they send is unencrypted, so it can be understood by other sites/services. If this is the case, am I not just pushing my data further along. Its still unencrypted but at a different end (VPNs Webside). Its only the data back to me, which is encrypted. Thanks.
Keep in mind that just because some traffic is not flowing inside a VPN doesn't necessarily mean that it is not secure or encrypted. The easy example would be HTTPS: the information you are exchanging with the server is encrypted even if you are not on a VPN. So, no VPN doesn't necessarily equal no security. A VPN will not make you more secure in terms of anonimity (e.g. if you are trying to perform some not-so-legal operations online), but it will make communications more secure than they would be without it. Sure, the information will be unencrypted sooner or later, but in the meantime, you are encrypting it so that anybody listening on that section of the network will not be able to access your information. I will give you another example: suppose you are running your own VPN server at home. You are out in a coffee shop and decide to browse the internet, but you connect first to the VPN. Of course the information will not be encrypted after it has reached your VPN server, but the chances of somebody actively sniffing your home connection are much lower than somebody doing the same thing in the coffee shop.
0.888889
No VPN doesn't necessarily equal no security .
Who to involve when making user tasks/scenarios for a usability test?
I am conducting my first usability test in our in-house testlab. I have asked my team (and the rest of the company) for hypotheses and aches regarding the service we are goint to test. Based on these (and pther things as well) I have made some tasks. My question is: Who should I invite to comment or review the tasks? I am thinking that the product owner should definitely look at them/have a say – and of course my UX colleagues. But what about the rest of the team (developers and testers)?
I've always asked the product manager (hopefully a single person, not a committee), whom I understand to be the person who decides which qualities (like performance, usability, security, and what @ripu1581 mentions) are important to the product and who decides which features are developed. If that responsibility lies with somebody titled "Architect" or "Developer", that's fine as well. You need to synch with this person to ensure results from the test are implemented and thus, will become visible. If you have knowledge in the business area and with previous version of the product, they are usually happy to consider proposals for tasks from you. If you are new to the team, you probably cannot press your own agenda of what should be changed, but need to follow their ideas of what is important. (That's not bad, since it's usually taken me a single usability test to surprise the team what users find intuitive and what not - so after the test results are out, your opinion will be appreciated much more.) I would not extend the scope of the test across what is feasible to tackle in the near future. Preparing and conducting the test is effort for everybody, and the closer the connection between this effort and immediate changes, the clearer the value of a usability test becomes. In addition to the tasks, you most likely also need a screener: A document describing your target group, which allows you to sort out people who your product is not addressing. Be careful when preparing this with the product manager! If anybody wants to question your results, a marginal fit between target group and test participants is their best argument. To ensure everyone is informend, invite everyone from developer to manager to tester to watch the sessions - stories about users being stuck stay with the team and help you in subsequent priority settings.
1
Product manager is the person who decides which qualities are important to the product .
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 can't post this as a comment, but I feel like it's worthy of an answer anyway. it expands on what Bankuei answered about pre-planned scenes. Be flexible in your plot If at all possible, allow the investigators to go at a faster pace than you accounted for. Maybe they figured out where the criminals will strike next before you expected them to, even before the criminals actually strike there. Maybe they decyphered what the big bad is up to at such an early time that they get there before he actually starts a crucial part of his master plan. In that case, avoid the temptation of slowing them down by throwing a couple of not-so-random encounters at them. Players like to think they outsmarted the GM, but don't like it if the GM punishes them for it. Instead, allow them to halt the big bad before he even gets going. Or let them warn the town watch about the criminals, or even let them go after them themselves. Then, when they're patting themselves on the shoulder, PLOT TWIST! The party gets arrested by the town watch because the watch doesn't know that the esteemed noble is actually a demon. Or the criminals get bailed out and immediately attack the party at their inn. Or the party is actually completely wrong in their clues. This is a goldmine. Go with the flow. Let the party think they caught a major criminal, while they actually caught a petty thief with no relation to the plot. They think that everything is fixed, but when you then unleash the next part of the plot, they actually realize that there is more to it all.
1
Don't slow the criminals down by throwing a couple of not-so-random encounters at them
How do I establish international copyright to my works?
What should I do to establish rights on my work? Does it depend on the country where it was created?
Yes - it completely depends on which country you are in. If you want to make it really fun, post it on the internet and then try to chase after copyright infringement in multiple countries. Copyright laws of the United States: http://www.copyright.gov/title17/ Copyright laws in Canada: http://www.media-awareness.ca/english/resources/legislation/canadian_law/federal/copyright_act/cdn_copyright_ov.cfm Copyright laws in Great Britian: http://www.copyrightservice.co.uk/copyright/p01_uk_copyright_law Copyright laws of Burkino Faso: http://afro-ip.blogspot.com/2011/07/to-z-of-african-official-ip-websites-no_18.html What you have to do to register your image (file a form, put a copyright notice on it, rent a billboard, etc.) as well as your rights and options will vary from country to country. Best bet is to google the copyright laws of your particular country.
1
Copyright laws of the United States
Why was this grammar & formatting edit rejected?
About: http://stackoverflow.com/review/suggested-edits/1962857 Recently, I've been suggesting a lot of edits - to make the site better. Scrolling through the list of my suggestions, I saw that this was rejected: http://stackoverflow.com/review/suggested-edits/1962857 - mostly with the This edit is too minor; suggested edits should be substantive improvements addressing multiple issues in the post. reason. However, if you look at the edit, it is substantial. It clarifies the question, and provides grammar and formatting fixes. Any help?
I would have either skipped it (see below) or rejected it for the same reason. The question was understandable before the edit. The "in-app purchases" part was the potentially redeeming part–and the reason I might have skipped it, since I don't know if that's a useful, correct, or valuable change. Nothing's wrong from the correctness standpoint. Once edits don't have to be reviewed making edits like this doesn't strike me as being bad. The goal is to get new-ish editors to make significant changes that make a Big Difference in question quality. There's a a wide range of what people consider "Big Enough", though. (I do tend to code-format classnames as a general rule.)
1
"Big Enough" is a big difference in question quality
How do I find a vacuum leak? I'd highly prefer not to use a carb cleaner spray
The car is a 1998 Oldsmobile Intrigue with 3.8L V6 engine (3800 Series). I've been doing my research and due diligence, but please understand I'm very inexperienced with automobiles. I went to Autozone and the reading I got from the OBD II tool was a P0171 error code. A lean or rich condition on Bank 1. First, I don't know where Bank 1 is. I have a feeling it's a cracked intake-manifold, an intake-manifold gasket leak, or both. But let's assume I have no clue where the vacuum leak is coming from. And I don't want to use a carb cleaner -- I read that I could cause a fire and I don't think I'm experienced enough to use something like that. I'd prefer to err on the side of caution. I've seen on youtube a long-time mechanic who uses a cigar as a cheap alternative to a smoke test machine. But I'm not sure if something like that could be used if you have no idea where the leak is coming from. So I ask those who are far, far more experienced than me. What ares some methods I can use if I have a vacuum leak, but I literally don't have a clue where it could be? Thank you.
if you have an idle and stalling problem with a 3800 series 2, don't mess around with it. change the upper and lower intake manifold gaskets, and the upper plastic intake manifold plenum itself. and cross it off your list. that problem will drive you f-ing nuts. they can leak internally and defy all diagnostics. the lower intake manifold can leak vacuum by pulling from the lifter valley area, under the manifold, from the engine internally. IMPOSSIBLE to find with smoke, spray, etc. just change it. the gaskets are usually mush.
1
Change upper and lower intake manifold gaskets, and upper plastic intake plenum itself
How to add additional photos to a status update
I created a Facebook status update with three photos. I'd like to add one more. Note that I did not create an album, I simply uploaded all three photos at the time of creating the Facebook status update. I can delete photos... but don't see a way to add one.
Once you posted it, you can’t add a new photo to a status update. The only moment when you can add more photos to a status update is between the time one or more photos are uploaded and the one you click Post (see picture below). The only thing you can do is to delete the first pictures and re-upload them together with the fourth. (FYI: the photos you upload directly (as status updates) are grouped in the album called Timeline Photos.)
1
Add a new photo to a status update
What's the meaning of "guest spot" in "We have a guest spot on the Tonight Show"?
I think that "solo spot" has the same meaning, but I don't know the meaning either.
A person who is set to appear on a talk show makes a "guest spot". See this example: Matt Damon makes first official guest spot on 'Jimmy Kimmel Live'.
1
Matt Damon makes official guest spot on 'Jimmy Kimmel Live'
Magento aggregate and between collections?
1) How to write the below SQL query in Magneto collection : SELECT * FROM 'table1' WHERE active=0 AND '2014-07-08' between 'not_available_from_date' and 'not_available_to_date' 2) Also how to write this SQL query in Magneto Collection : Select sum(qty + product_id - any_other_columns) as total from table2 GROUP BY product_id; Without using ->columns(' ') function. Thanks for your help
Assuming you have a model mapped to your table1 and one mapped to table2 you can try something like this. $date = '2014-07-08'; $collection = Mage::getModel('[module]/table1')->getCollection() ->addFieldToFilter('active', 0) ->addFieldToFilter('not_available_from_date', array('date' => true, 'to' => $date)) ->addFieldToFilter('not_available_to_date', array('date' => true, 'from' => $date)); And for the second one. $collection = Mage::getModel('[module]/table2')->getCollection() ->addExpressionFieldToSelect('total', 'SUM({{qty}} + {{product_id}} - {{any_other_columns}})', array('{{qty}}'=>'qty', '{{product_id}}'=>'product_id', '{{any_other_columns}}'=>'any_other_columns')); //since SUM requires a GROUP BY...group by some column $collection->getSelect()->group('product_id'); The examples above are for flat entities. If you have an EAV entity similar to products or categories use addAttributeToFilter instead of addFieldToFilter addExpressionAttributeToSelect instead of addExpressionFieldToSelect EDIT After an other investigation I found that for flat entities you can use directly the column names. The attribute placeholders {{...}} are needed only for EAV entities. So your second collection should look like this: $collection = Mage::getModel('[module]/table2')->getCollection() ->addExpressionFieldToSelect('total', 'SUM(qty + product_id - any_other_columns)', array('qty', 'product_id', 'any_other_columns')); $collection->getSelect()->group('product_id'); The third parameter for addExpressionFieldToSelect is required but it can be an empty array. for addExpressionAttributeToSelect that last parameter should contain the mapping between the placeholders and the attribute codes. In this case seams that they are useless. I don't know if this is a bug or a feature.
0.777778
If you have an EAV entity similar to products or categories use addAttributeToFilter instead of addExpressionFi
PySpark reduceByKey? to add Key/Tuple
I have the following data and what I want to do is [(13, 'D'), (14, 'T'), (32, '6'), (45, 'T'), (47, '2'), (48, '0'), (49, '2'), (50, '0'), (51, 'T'), (53, '2'), (54, '0'), (13, 'A'), (14, 'T'), (32, '6'), (45, 'A'), (47, '2'), (48, '0'), (49, '2'), (50, '0'), (51, 'X')] Is for each key count the instances of the value (a 1 string character). So I first did a map: .map(lambda x: (x[0], [x[1], 1])) Making it now a key/tuple of: [(13, ['D', 1]), (14, ['T', 1]), (32, ['6', 1]), (45, ['T', 1]), (47, ['2', 1]), (48, ['0', 1]), (49, ['2', 1]), (50, ['0', 1]), (51, ['T', 1]), (53, ['2', 1]), (54, ['0', 1]), (13, ['A', 1]), (14, ['T', 1]), (32, ['6', 1]), (45, ['A', 1]), (47, ['2', 1]), (48, ['0', 1]), (49, ['2', 1]), (50, ['0', 1]), (51, ['X', 1])] I just cant for the last part figure out how to for each key count the instances of that letter. For instance Key 13 will have 1 D and 1 A. While 14 will have 2 T's, etc.
If i understood you right, you can do it in one operation combineByKey: from collections import Counter x = sc.parallelize([(13, 'D'), (14, 'T'), (32, '6'), (45, 'T'), (47, '2'), (48, '0'), (49, '2'), (50, '0'), (51, 'T'), (53, '2'), (54, '0'), (13, 'A'), (14, 'T'), (32, '6'), (45, 'A'), (47, '2'), (48, '0'), (49, '2'), (50, '0'), (51, 'X')]) result = x.combineByKey(lambda value: {value: 1}, ... lambda x, value: value.get(x,0) + 1, ... lambda x, y: dict(Counter(x) + Counter(y))) result.collect() [(32, {'6': 2}), (48, {'0': 2}), (49, {'2': 2}), (53, {'2': 1}), (13, {'A': 1, 'D': 1}), (45, {'A': 1, 'T': 1}), (50, {'0': 2}), (54, {'0': 1}), (14, {'T': 2}), (51, {'X': 1, 'T': 1}), (47, {'2': 2})]
0.666667
combineByKey: from collections import Counter x = sc.parallelize
Was Rakata's "Force-enhanced" hyperdrive technology ever replicated (or something similar used)?
We know that Rakatan empire in Star Wars EU was one of the earliest hyperdrive capable species, and their hyperdrive was powered by the Dark Side of the Force: The first interstellar space drive known to make use of hyperspace was developed by the Rakata, who built their Infinite Empire around technology using the dark side of the Force to travel through hyperspace. (Wikia). Has anyone used hyperdrive technology that was powered by the Force (any side) since the Rakata? It could have been a clone of Rakata's, or totally different, as long as it wasn't simply someone taking and using existing surviving Rakatan unit. If not, was there an explicit in-universe explanation as to why the Force was never used to enhance Hyperspace travel? (the predictable "well the Rakata were screwed up via their use of Dark Side" doesn't seem to be plausible in a universe full of Sith, and assorted other Dark Force users).
Around 200 years after the fall of the Rakata's Empire (the Infinite Empire) the civilizations from both the planets Correllia and Duro managed to build workarounds using the Rakata's force-based technology, making it common use in around twenty years or so. Even the Tionese managed to build a really basic form of hyperspace technology around the Rakata's force-only requirement. As for a reason why force sensitive hyperdrive was not further looked into, a huge problem the Rakata's had was because the hyperdrive relied on the use of the force, they could only travel to planets with high-force signatures, allowing other civilizations to take control of the planets in between. Hope this helps!
0.888889
Rakata's force-based technology used in the fall of the Infinite Empire
Would it be a problem if all Amazon links were converted to affiliate links?
I'm thinking that one way Jeff and the Stack Overflow team could squeeze some extra money out of this site would be to automatically convert all Amazon links posted here into affiliate links, e.g. Stick "tag=codinghorror-20" (or more likely a new site-specific tag) onto every Amazon link. This would bring in some additional revenue every time someone purchased a book via a link on this site. They could do similar things with other links as well. Amazon's simply the most obvious choice. So my question is, would anyone have a problem with this? I know I wouldn't mind, but I don't know how other people would react. What does everyone think? Is this a horrible idea, a great idea, a waste of time?
In my experience, affiliate links never pay out well. Perhaps with such a huge member base SO might do better. But how often do you click a link from SO and buy the item right away? I have certainly bought one book I've seen mentioned here (and other places), but I didn't buy it straight away, I went back to Amazon a week later, searched for it and bought it.
1
How often do you click a link from SO and buy it right away?
How to make extra crispy and crunchy breading like KFC?
I'm wondering how I would go about making extra crispy chicken breading like they do at many places like KFC and the like. Is there a certain ingredient that makes the breading like that? Any assistance would be very much appreciated, and feel free to share any of your own recipes for crispy chicken breading if you have them. I'll be sure to put them to good use! Thanks!
I normally use all purpose flour cornmeal onion powder garlic powder paprika and meat tenderizer.Just wet the chicken with water or with marinade,toss in a ziploc with flour and seasonings.Then fry for 20 or 25 min in the fry daddy and presto!!!!
1
Cook chicken for 20 or 25 min in fry daddy and presto
How to forcibly disconnect a application listening on a port
I have an app that doesn't properly stop listening on a port. How do I force it to stop so I can open the application again/use that port again?
If the application is running under unix, Kill -9 <pid> will forcefully kill a process releasing all it's resources. The <pid> can be found by doing a ps aex at the command line.
1
Kill -9 <pid&gt
How to update non-property value with entity_metadata_wrapper?
I wish to update values in commerce_payment_transaction entity. I am using such code: <?php $transaction = commerce_payment_transaction_load(58); $digests = array( 'DIGEST' => '456', 'DIGEST2' => '478' ); $transaction_wrapper = entity_metadata_wrapper('commerce_payment_transaction', $transaction); $transaction_wrapper->payload->set($digests); $transaction_wrapper->field_my_custom_field->set(1458); $transaction_wrapper->save(); The problem is, that such code throws me error, that payload is not property of commerce_payment_transaction entity. Although "payload" is column in database table of this entity type. But it is not set as property. When I don't use entity_metadata_wrapper, this code works for me: <?php $transaction = commerce_payment_transaction_load(58); $digests = array( 'DIGEST' => '456', 'DIGEST2' => '478' ); $transaction->payload = $digests; commerce_payment_transaction_save($transaction); ?> But is it possible to use also entity_metadata_wrapper to update data of entity, that are neither properties nor fields, like payload in commerce_payment_transaction?
The payload column is a property of the commerce payment transaction type already (property is a Drupal core term for any base fields on an entity), but for whatever reason the authors of the module have chosen not to expose it to the Entity API module through commerce_payment_entity_property_info(). Fortunately you can just use hook_entity_property_info_alter() in a custom module to provide the metadata on its behalf. See hook_entity_property_info() for details of the options available.
0.888889
The payload column is a property of the commerce payment transaction type already .
How does Christianity deal with biblical criticism related to the Old Testament?
As an orthodox Jew I have seen quite a stir lately regarding the topic of biblical criticism, specifically towards the Old Testament (Torah). I have perused several questions in this stack which seem to address this topic in general, and learned a lot about apologetics, but I have not seen answers that address some of the major claims of biblical criticism, especially as it pertains to the Old Testament. For example: The story of Noah and the flood seems to be contradicted by archaeological evidence as well as having been 'borrowed' from earlier flood narratives such as the Gilgamesh story Many of the portions of the Old Testament seem to be borrowed from earlier near eastern texts such as the Hammurabi code The notion that there are multiple authors (documentary hypothesis) of the Old Testament. In short, how does Christianity deal with some of the major contentions of biblical criticism towards the Old Testament? I apologize if any parts of my question offend any sensibilities to which I am unaware.
In short, how does Christianity deal with some of the major contentions of biblical criticism towards the Old Testament? The literalists contend the academic assertions are false (intentionally or otherwise). The accommodationists attempt to find a way to build a compromise usually at the expense of what is written in the Bible. This is similar to what passes for science these days in regard to evolution. However with literary criticism the flaws are more apparent. For example, the assertion of multiple authors is often based on the declaration of someone that they have detected a stylistic difference that "proves" that the same person could not have written a document attributed to him. Using an example from evolutionary "science", the measurement of something like ice cores is hindered by the fact that the weight of the ice causes anything more than a few centuries old to be fused together. A person attempting to discover something beyond the point of differentiation has to make assumptions and interpret his measurements using "fudge factors". Most people are bored by the details of both literary criticism and evolutionary science. They usually take at face value whatever the media tells them which is usually a distillation of what is popular or sensational. As a literalist, I expect there to be accusations and declarations from a variety of sources against the Bible and God. John 15:19 If ye were of the world, the world would love his own: but because ye are not of the world, but I have chosen you out of the world, therefore the world hateth you.
0.888889
How does Christianity deal with major contentions of biblical criticism towards the Old Testament?
XLConnect loadWorkbook error - POIXMLException (Java)
I'm trying to load a hefty Excel workbook (.xlsm format, ~30 mb) that has a large number of array calcs. > wb1 <- loadWorkbook("Mar_SP_20130227_V6.1.xlsm") Error: POIXMLException (Java): java.lang.reflect.InvocationTargetException But I am able to successfully load a values-only/no-macro version of the workbook. > wb2 <- loadWorkbook("Mar_SP_20130227_V6.1_VALUES_ONLY.xlsx") > wb2 [1] "Mar_SP_20130227_V6.1_VALUES_ONLY.xlsx" What could be causing the error? From the maintainer's website I can see that there can be issues with workbooks containing array calcs or unsupported formula functions, but this doesn't look like the same errror. Java Info: C:\> java -version java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode)
It turns out that the root of this error was the JVM running out of memory (even with options(java.parameters = "-Xmx1024m")). I tried to increase the memory, but couldn't get the JVM to take more than -Xmx2048m, which still wasn't enough to load the workbook. So I upgraded the JRE from 32 bit to 64 bit and ran 64 bit R. I was then able to set -Xmx4096m and successfully load my 30mb workbook.
0.888889
JVM running out of memory
Key-agreement protocol in a REST API
I have a C# REST API which exposes some methods over the HTTP protocol. The API is intended to be used my my Android applocation (Java) which is currently in the makings. Since the app is in an early development stage, and hasn't been released yet, I access the API methods using http://example.com/resources/item17 without any additional security. However, as soon as the app is released, I don't want anyone but my app users to access the API. My idea is to generate some kind of unique key in my C# + Android code. A simplified version to give you the idea: int key = DateTime.Now.Minute * Math.PI * 5; This would make the request look something like: `http://example.com/resources/item17?key=1234567` The C# API would verify this before sending a response. The only way to figure out how the key is generated would be to reverse my Android code (which will be obfuscated at that point). Does this sound like a good solution, or do you have any other suggestions?
Your solution relies on the assumption that reverse-engineering of an obfuscated app is hard. However, this assumption does not match experience. Therefore, one cannot really tell that your solution is good. However, maybe your solution is the best that can be done (not the same thing as "good"). The alternative is user authentication. Namely, each app instance would get its own authentication key; then, it is up to the server to accept a key or reject it. This gives you the ability to revoke a key which appears to have been reverse-engineered; it may also give you legal leverage to prosecute offenders. If you do pursue the concept of generating a time-based key in the app, then at least do it with the proper cryptographic tools. In this case, use HMAC: encode the current time into some bytes, then compute HMAC/SHA-1 (or HMAC/SHA-256, whichever is easiest for you) on these bytes, using a hardcoded key. The hardcoded key is the target for reverse-engineering. Using HMAC will at least protect you from key reconstruction by analysis of the output: the attacker will really have to do some actual code disassembly. You will also need the app to send its notion of "current time" as an extra parameter, because you cannot rely on the client device being well synchronized. (None of this being exclusive with running the whole thing in HTTPS, which is usually a good idea when security matters, but is really another subject here.)
0.888889
Reverse-engineering of an obfuscated app
It's possible change dynamically devise configuration without app restart?
I'm using devise v.2.2.4 on my Rails 3.2.17 and I need some features related with security policies. The admin user will change the security policies at any time like show next image: but I don't know how make it with devise, because devise read configuration of initializers/devise.rb and on production all initializer are loading the first time only.
I believe you can pre-seed some table with default preferences data for devise (or any other gem/library) and then get it from the db in your initializer. Then add some crud to let admin user change this preferences. But full restart of app will be needed for update this preferences.
0.666667
Pre-seed table with default preferences data for devise
How to restore a site from a backup done with Backup and Migrate module using Drush
Just that. I've a backup using the backup and migrate module. I've done some changes and now the site is down. I can't restore the site using the admin interface (because it's broken). Can I use Drush to restore it?
Yes, you can restore your backup with Drush. Here are Backup and Migrate commands for Drush explained: http://www.only10types.com/2011/03/drush-backup-and-migrate-command.html I think drush bam-restore command is what you are looking for. bam-restore Restore the site's database with Backup and Migrate. Examples: drush bam-restore db manual "LCC-31.03.2011-14.01.59.mysql.gz" - restore the default database using the given dump file, which can be found in the destination called "manual" Arguments: source - Required. The id of the source (usually a database) to restore the backup to. Use 'drush bam-sources' to get a list of sources. Defaults to 'db' destination - Required. The id of destination to send the backup file to. Use 'drush bam-destinations' to get a list of destinations. Defaults to 'manual' backup id - Required. The id of a backup file restore. Use 'drush bam-backups' to get a list of available backup files.
0.888889
Backup and Migrate commands for Drush