Provide params hash for put / post requests in rails console

If you want to put or post to a URL there are also methods for that. You can copy/paste the parameters exactly as they are displayed in your Rails production log: app.post(‘/foo’, {“this” => “that”, “items” => [“bar”, “baz”]}) app.put(‘/foo’, {“this” => “that”, “items” => [“bar”, “baz”]}) If you want to sent a custom header, … Read more

Create HTTP post request and receive response using C# console application

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO; namespace WebserverInteractionClassLibrary { public class RequestManager { public string LastResponse { protected set; get; } CookieContainer cookies = new CookieContainer(); internal string GetCookieValue(Uri SiteUri,string name) { Cookie cookie = cookies.GetCookies(SiteUri)[name]; return (cookie == null) ? null : cookie.Value; } public string GetResponseContent(HttpWebResponse response) … Read more

Getting terminal size in c for windows?

This prints the size of the console, not the buffer: #include <windows.h> int main(int argc, char *argv[]) { CONSOLE_SCREEN_BUFFER_INFO csbi; int columns, rows; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); columns = csbi.srWindow.Right – csbi.srWindow.Left + 1; rows = csbi.srWindow.Bottom – csbi.srWindow.Top + 1; printf(“columns: %d\n”, columns); printf(“rows: %d\n”, rows); return 0; } This code works because srWindow “contains the … Read more

How can I write these variables into one line of code in C#?

Look into composite formatting: Console.WriteLine(“{0}.{1}.{2}”, mon, da, yer); You could also write (although it’s not really recommended): Console.WriteLine(mon + “.” + da + “.” + yer); And, with the release of C# 6.0, you have string interpolation expressions: Console.WriteLine($”{mon}.{da}.{yer}”); // note the $ prefix.

Output Unicode to console Using C++, in Windows

What about std::wcout ? #include <iostream> int main() { std::wcout << L”Hello World!” << std::endl; return 0; } This is the standard wide-characters output stream. Still, as Adrian pointed out, this doesn’t address the fact cmd, by default, doesn’t handle Unicode outputs. This can be addressed by manually configuring the console, like described in Adrian’s … Read more