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
#[test] | |
fn iter_demo() { | |
let v1 = vec![1, 2, 3]; | |
let mut v1_iter = v1.iter(); | |
// iter() returns an iterator of slices. | |
assert_eq!(v1_iter.next(), Some(&1)); | |
assert_eq!(v1_iter.next(), Some(&2)); | |
assert_eq!(v1_iter.next(), Some(&3)); | |
assert_eq!(v1_iter.next(), None); |
For MacOS Catalina, visit Install mysql2 on MacOS Catalina
Installing mysql2
gem errors on MacOS Mojave.
Make sure openssl
is installed on Mac via Homebrew.
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
FROM ruby:2.4-alpine3.7 | |
# Install dependencies: | |
# - build-base: To ensure certain gems can be compiled | |
# - nodejs: Compile assets | |
# - postgresql-dev postgresql-client: Communicate with postgres through the postgres gem | |
# - libxslt-dev libxml2-dev: Nokogiri native dependencies | |
# - imagemagick: for image processing | |
RUN apk --update add build-base nodejs tzdata postgresql-dev postgresql-client libxslt-dev libxml2-dev imagemagick |
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
package main | |
import ( | |
"context" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" |
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
use std::cmp::{Eq}; | |
use std::collections::HashMap; | |
use std::hash::{Hash}; | |
struct Cacher<I, O, F> | |
where | |
F: Fn(I) -> O, | |
{ | |
function: F, | |
cache: HashMap<I, O>, |
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
/* | |
JPA (Java Persistence API) | |
Transaction Management with an Entity-Mananger: | |
--- | |
entityManager.getTransaction().begin(); | |
entityManager.persist(<some-entity>); | |
entityManager.getTransaction().commit(); | |
entityManager.clear(); |
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
class ApplicationController < ActionController::Base | |
protect_from_forgery with: :exception | |
around_action :global_request_logging | |
def global_request_logging | |
http_request_header_keys = request.headers.env.keys.select{|header_name| header_name.match("^HTTP.*|^X-User.*")} | |
http_request_headers = request.headers.env.select{|header_name, header_value| http_request_header_keys.index(header_name)} | |
puts '*' * 40 | |
pp request.method |
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
package main | |
import ( | |
"context" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" | |
"time" | |
) |
NewerOlder