console
This is a pretty simple question, at least it seems like it should be, about sudo permissions in Linux.
There are a lot of times when I just want to append something to /etc/hosts
or a similar file but end up not being able to because both >
and >>
are not allowed, even with root.
Is there someway to make this work without having to su
or sudo su
into root?
Source: (StackOverflow)
Killswitchcollective.com's old article, 30 June 2009, has the following inputs and outputs
git co master
git merge [your_branch]
git push
upstream A-B-C-D-E A-B-C-D-E-F-G
\ ----> \
your branch C-D-E G
I am interested how you get the tree like-view of commits in your terminal without using Gitk or Gitx in OS/X.
How can you get the tree-like view of commits in terminal?
Source: (StackOverflow)
I need to write JUnit tests for an old application that's poorly designed and is writing a lot of error messages to standard output. When the getResponse(String request)
method behaves correctly it returns a XML response:
@BeforeClass
public static void setUpClass() throws Exception {
Properties queries = loadPropertiesFile("requests.properties");
Properties responses = loadPropertiesFile("responses.properties");
instance = new ResponseGenerator(queries, responses);
}
@Test
public void testGetResponse() {
String request = "<some>request</some>";
String expResult = "<some>response</some>";
String result = instance.getResponse(request);
assertEquals(expResult, result);
}
But when it gets malformed XML or does not understand the request it returns null
and writes some stuff to standard output.
Is there any way to assert console output in JUnit? To catch cases like:
System.out.println("match found: " + strExpr);
System.out.println("xml not well formed: " + e.getMessage());
Source: (StackOverflow)
Is there a way to disable SQL query logging when I'm executing commands in the console? Ideally, it would be great if I can just disable it and re-enable it with a command in the console.
I'm trying to debug something and using "puts" to print out some relevant data. However, the sql query output is making it hard to read.
Edit:
I found another solution, since setting the logger to nil sometimes raised an error, if something other than my code tried to call logger.warn
Instead of setting the logger to nil
you can set the level of the logger to 1
.
ActiveRecord::Base.logger.level = 1
Source: (StackOverflow)
In Chrome the console
object defines two methods that seem to do the same thing:
console.log(...)
console.dir(...)
I read somewhere online that dir
takes a copy of the object before logging it, whereas log
just passes the reference to the console, meaning that by the time you go to inspect the object you logged, it may have changed. However some preliminary testing suggests that there's no difference and that they both suffer from potentially showing objects in different states than when they were logged.
Try this in the Chrome console (Ctrl+Shift+J) to see what I mean:
> o = { foo: 1 }
> console.log(o)
> o.foo = 2
Now, expand the [Object]
beneath the log statement and notice that it shows foo
with a value of 2. The same is true if you repeat the experiment using dir
instead of log
.
My question is, why do these two seemingly identical functions exist on console
?
Source: (StackOverflow)
Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.
Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I'm wondering if, and how, to clear the Python interpreter console.
I've heard about doing a system call and either calling cls
on Windows or clear
on Linux, but I was hoping there was something I could command the interpreter itself to do.
Note: I'm running on Windows, so Ctrl+L doesn't work.
Source: (StackOverflow)
I would like to be able to trap ctrl-c in a C# console application so that I can carry out some cleanups before exiting. What is the best way of doing this?
Source: (StackOverflow)
I want to print something in console, so that I can debug it. But for some reason, nothing prints in my Android application.
How do I debug then?
public class HelloWebview extends Activity {
WebView webview;
private static final String LOG_TAG = "WebViewDemo";
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new HelloWebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebChromeClient(new MyWebChromeClient());
webview.loadUrl("http://example.com/");
System.out.println("I am here");
}
Source: (StackOverflow)
Since I'm building a dynamic site, I need to track the changes between pages, ie. Ajax calls, POST, GET stuff and similar stuff.
I'm looking for the same functionality like in Firebug (where you can enable "persistent" and the console is not cleared every time you reload a page or submit a form.
So, my questions is: is there a way to make Google Chrome JavaScript console persistent?
(And if yes, how?)
Update: Copying the answer here, if anyone's still looking for this, Chrome 14+ has a setting in Developer Tools > Settings labelled "Console: Preserve log on navigation".
Update 2: the latest versions of Chrome (33+) have this option by right-clicking in the console.
Source: (StackOverflow)
When I load script/console
, some times I want play with the output of a controller or a view helper method.
Are there ways to:
- simulate a request?
- call methods from a controller instance on said request?
- test helper methods, either via said controller instance or another way?
Source: (StackOverflow)
When building a Windows Console App in C#, is it possible to write to the console without having to extend a current line or go to a new line? For example, if I want to show a percentage representing how close a process is to completion, I'd just like to update the value on the same line as the cursor, and not have to put each percentage on a new line.
Can this be done with a "standard" C# console app?
Source: (StackOverflow)
Is there a way in python to programmatically determine the width of the console? I mean the number of characters that fits in one line without wrapping, not the pixel width of the window.
Edit
Looking for a solution that works on Linux
Source: (StackOverflow)