layout | author | title | revision | version | description |
---|---|---|---|---|---|
default |
mattmc3 |
Modern SQL Style Guide |
2019-01-17 |
1.0.1 |
A guide to writing clean, clear, and consistent SQL. |
#!/usr/bin/env sh | |
# NOTE: First, have to ignore the following warnings to make it build on M1 Chip. | |
# | |
# -Wno-constant-logical-operand -Wno-format-nonliteral -Wno-self-assign | |
# | |
# To do so the above line should be appended to consts CFLAGS and CXXFLAGS | |
# under the 'Programs producing files for the HOST machine' section of | |
# the generated Makefile in dir 'build-gdb'. |
object game { | |
case class Lens[S, A](set: A => S => S, get: S => A) { self => | |
def >>> [B](that: Lens[A, B]): Lens[S, B] = | |
Lens[S, B]( | |
set = (b: B) => (s: S) => self.set(that.set(b)(self.get(s)))(s), | |
get = (s: S) => that.get(self.get(s)) | |
) | |
} | |
case class Prism[S, A](set: A => S, get: S => Option[A]) { self => |
vi /etc/environment | |
add these lines... | |
LANG=en_US.utf-8 | |
LC_ALL=en_US.utf-8 |
I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.
This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea
import http.server as httpserver | |
import socketserver | |
def main(port=None): | |
if port is None: | |
port = 8000 | |
handler = httpserver.SimpleHTTPRequestHandler | |
try: | |
httpd = socketserver.TCPServer(("", port), handler) | |
print("serving at port", port) |
import Numeric.Implicits._
def mean[T: Numeric](xs: Iterable[T]): Double = xs.sum.toDouble / xs.size
def variance[T: Numeric](xs: Iterable[T]): Double = {
val avg = mean(xs)
xs.map(_.toDouble).map(a => math.pow(a - avg, 2)).sum / xs.size
}
The only way I've succeeded so far is to employ SSH.
Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config
file in a .ssh
directory. The config
file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh
directory by default. You can navigate to it by running cd ~/.ssh
within your terminal, open the config
file with any editor, and it should look something like this:
Host * AddKeysToAgent yes
> UseKeyChain yes
def loadResource(filename: String) = { | |
val source = scala.io.Source.fromURL(getClass.getResource(filename)) | |
try source.mkString finally source.close() | |
} |
Gist title: "BASH: ISO 8601 Timestamp with Milliseconds" | |
Summary: How to get an ISO 8601 timestamp with milliseconds in BASH |