Skip to content

Instantly share code, notes, and snippets.

@m0sys
m0sys / build_gdb.sh
Last active December 18, 2023 19:10
Apple M1 ARM GDB Build from Source with Python Support
#!/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'.
@mattmc3
mattmc3 / modern_sql_style_guide.md
Last active April 8, 2024 22:53
Modern SQL Style Guide
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.

Modern SQL Style Guide

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 =>
@rafaotetra
rafaotetra / LC_CTYPE.txt
Created January 8, 2018 11:54 — forked from thanksdanny/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8

Quick Tips for Fast Code on the JVM

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

@kabinpokhrel
kabinpokhrel / server.py
Created December 22, 2017 13:35
Simple HTTP Server Implementation in Python 3
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)
@navicore
navicore / stdDev.scala.md
Created December 11, 2017 16:47
standard deviation scala
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
}
@Jonalogy
Jonalogy / handling_multiple_github_accounts.md
Last active April 16, 2024 20:05
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

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

@banjeremy
banjeremy / load-resource.scala
Created January 29, 2017 00:18
scala: load files from resources directory
def loadResource(filename: String) = {
val source = scala.io.Source.fromURL(getClass.getResource(filename))
try source.mkString finally source.close()
}
@sloanlance
sloanlance / BASH: ISO 8601 Timestamp with Milliseconds
Last active February 9, 2023 19:33
How to get an ISO 8601 timestamp with milliseconds in BASH
Gist title: "BASH: ISO 8601 Timestamp with Milliseconds"
Summary: How to get an ISO 8601 timestamp with milliseconds in BASH