This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'matrix' | |
class RPS | |
attr_accessor :scoring, :choices | |
def initialize | |
@scoring = Matrix[ | |
[1, 0, 2], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-derived-mode | |
jshell-mode comint-mode "JShell" | |
"An Emacs mode to interact with an inferior JShell | |
process. JShell is an interacive Java REPL included from JDK 9 | |
and up." | |
:syntax-table java-mode-syntax-table | |
(setq comint-prompt-regexp (concat "^" (regexp-quote "jshell>"))) | |
(make-comint-in-buffer "JShell" nil "jshell")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <arpa/inet.h> | |
#include <assert.h> | |
#include <netinet/ip.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
if ARGV.length == 0 | |
puts "\nUSAGE:\n\tpom_editor.rb path/to/pom.xml\n\n" | |
end | |
filename = ARGV[0] | |
@doc = Nokogiri::XML.parse(File.read(filename)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun cjw-load-env-from-file (filename) | |
"Open a file of environment variable definitions like: | |
export FOO=bar | |
export BAZ=quux | |
and load them into the current environment using `setenv`" | |
(with-temp-buffer | |
(insert-file-contents filename) | |
(goto-char (point-min)) | |
(while (re-search-forward "^export \\(.*\\)=\\(.*\\)$") | |
(apply 'setenv (list (match-string 1) (match-string 2)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* #include "private.h" */ | |
#include "public.h" | |
#include "s.h" | |
int main() { | |
struct s foo; | |
init_s(&foo); | |
printf("foo.public.a %d\n", foo.public.a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef INCLUDE_TRACE_H | |
#define INCLUDE_TRACE_H | |
#include <stdio.h> | |
#include <stdint.h> | |
#define TRACE_STR(variable) do { fprintf(stderr, __FILE__":%d "#variable"=%s\n", __LINE__, variable); } while(0) | |
#define TRACE_INT(variable) do { fprintf(stderr, __FILE__":%d "#variable"=%d\n", __LINE__, variable); } while(0) | |
#define TRACE_PTR(variable) do { fprintf(stderr, __FILE__":%d "#variable"=0x%016lx\n", __LINE__, (uint64_t)(variable)); } while(0) | |
#define TRACE_SIZ(variable) do { fprintf(stderr, __FILE__":%d "#variable"=%zu\n", __LINE__, variable); } while(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdio.h> | |
#define BUFFER_SIZE 16 | |
struct Buffer { | |
uint8_t data[BUFFER_SIZE]; | |
uint8_t newest_index; | |
uint8_t oldest_index; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APP | |
Start* | |
app created -> NewPolicy | |
NewPolicy | |
submit to new business -> Policy | |
Policy | |
underwriting accept -> PolicyUnderwritten | |
underwriting reject -> PolicyClosed | |
PolicyUnderwritten | |
PolicyClosed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int | |
main(int argc, char **argv) { | |
int i = 0; | |
switch(i) { | |
case 0 ... 10: | |
printf("0 through 10\n"); | |
break; | |
default: |