import
Importing .sql file on windows to postgresql
You should use psql command line tool: psql -h hostname -p port_number -U username -f your_file.sql databasename
ES6 – declare a prototype method on a class with an import statement
You can still attach a method on a class’ prototype; after-all, classes are just syntactic sugar over a “functional object”, which is the old way of using a function to construct objects. Since you want to use ES6, I’ll use an ES6 import. Minimal effort, using the prototype: import getColor from ‘path/to/module’; class Car { … Read more
Scala, importing class
logic.scala code package logic class Logic{ def hello = “hello” } main.scala code package runtime import logic.Logic // import object Main extends Application{ println(new Logic hello) // instantiation and invocation } compile the files with scalac scalac *.scala run your application with scala scala -cp . runtime.Main
How can I insert 10 million records in the shortest time possible?
Please do not create a DataTable to load via BulkCopy. That is an ok solution for smaller sets of data, but there is absolutely no reason to load all 10 million rows into memory before calling the database. Your best bet (outside of BCP / BULK INSERT / OPENROWSET(BULK…)) is to stream the contents from … Read more
All caps constants in JavaScript. And requireds. And imports
Generally speaking it is common practice to capitalize your constants. This is a convention which tells other programmers that the value is fixed. The javascript keyword const, though confusing is not a constant in that sense. I think that is where you got confused. A constant is a concept/construct. Not a primitive type within the … Read more
Too many imports are spamming my Java code
Yes, too many imports is a bad thing because it clutters your code and makes your imports less readable. Avoid long import lists by using wildcards. Kevlin Henney talks about this exact Stack Overflow question 27:54 into his presentation Clean Coders Hate What Happens to Your Code When You Use These Enterprise Programming Tricks from … Read more
C# DllImport with C++ boolean function not returning correctly
I found the solution for your problem. Your declaration should be preceded with this marshaling: [return:MarshalAs(UnmanagedType.I1)] so everything should look like this: [DllImport(“Whisper.dll”, EntryPoint=”Exist”, CallingConvention=CallingConvention.Cdecl)] [return:MarshalAs(UnmanagedType.I1)] public static extern bool Exist([MarshalAs(UnmanagedType.LPStr)] string name); I tested it in my very simple example and it worked! EDIT Why this happens? C defines bool as 4 bytes int … Read more
How do I read line by line a text file in ruby (hosting it on s3)?
File.open(“my/file/path”, “r”).each_line do |line| # name: “Angela” job: “Writer” … data = line.split(/\t/) name, job = data.map{|d| d.split(“: “)[1] }.flatten end Related topic What are all the common ways to read a file in Ruby?
Is it possible to turn off quote processing in the Postgres COPY command with CSV format?
Workaround (thanks to this comment!) COPY <tablename> FROM <filename> WITH CSV DELIMITER E’\t’ QUOTE E’\b’ NULL AS ”; So basically specifying a quote character that should never be in the text, but that’s pretty ugly. I’d much prefer it if there was in fact a way to turn off quote processing altogether.