Ruby on Rails – How to print log messages in color

Basically what you want to do is embed ANSI escape sequences for color into your debug strings, just like you would in a regular Ruby program. There are several ways to go about this: Use the rainbow gem, which allows you to do this: require ‘rainbow’ Rails.logger.debug(Rainbow(“This message is Green”).green) or require the mixin to … Read more

Why there are only 75 visible characters in Intellij Idea’s embedded terminal?

Notice: since IDEA 2016.3.2 this breaks the terminal and is not required anymore. So just delete it when you update to a version it cannot create the Terminal. For windows change the terminal shell path (File->Settings->Tools->Terminal) from cmd.exe to: cmd.exe “/K mode con:cols=500 lines=9999&cmd.exe” or if using the bash for windows subsystem: cmd.exe “/K set … Read more

How can I print to the console in color in a cross-platform manner?

You can use the ANSI colour codes. Here’s an example program: #include <stdio.h> int main(int argc, char *argv[]) { printf(“%c[1;31mHello, world!\n”, 27); // red printf(“%c[1;32mHello, world!\n”, 27); // green printf(“%c[1;33mHello, world!\n”, 27); // yellow printf(“%c[1;34mHello, world!\n”, 27); // blue return 0; } The 27 is the escape character. You can use \e if you prefer. … Read more

PowerShell steps to fix slow startup

When PowerShell starts to become slow at startup, an update of the .NET framework might be the cause. To speed up again, use ngen.exe on PowerShell’s assemblies. It generate native images for an assembly and its dependencies and install them in the Native Images Cache. Run this as Administrator $env:PATH = [Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory() [AppDomain]::CurrentDomain.GetAssemblies() | ForEach-Object … Read more

In Xcode, is there a way to disable the timestamps that appear in the debugger console when calling NSLog?

NSLog() is what is doing that, not the debugger console. The easiest way to avoid it is to not use NSLog at all. You could use fprintf(), but that is a pain in that it doesn’t support %@ format types. I generally write a function for this: void MyLog(NSString *format, …) { va_list args; va_start(args, … Read more

Powershell output column width

I encountered a similar problem a while back. Here’s what I did to fix it: # Update output buffer size to prevent clipping in Visual Studio output window. if( $Host -and $Host.UI -and $Host.UI.RawUI ) { $rawUI = $Host.UI.RawUI $oldSize = $rawUI.BufferSize $typeName = $oldSize.GetType( ).FullName $newSize = New-Object $typeName (500, $oldSize.Height) $rawUI.BufferSize = $newSize … Read more

how to print a string to console in c++

yes it’s possible to print a string to the console. #include “stdafx.h” #include <string> #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string strMytestString(“hello world”); cout << strMytestString; return 0; } stdafx.h isn’t pertinent to the solution, everything else is.