Skip to content

Instantly share code, notes, and snippets.

View philipjkim's full-sized avatar

Soo Philip Jason Kim philipjkim

View GitHub Profile
@philipjkim
philipjkim / iter_test.rs
Last active March 15, 2024 00:15
Rust: Difference between iter(), into_iter(), and iter_mut()
#[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);
@9beach
9beach / 읽은 책.md
Last active May 2, 2025 14:55
읽은 책

읽은 책

2015년 2월부터 2019년 5월까지, 그리고 2023년부터 지금까지 읽은 책.

특별히 꼽고 싶은 책, 재미있었던 순으로

  1. Out of Africa - Karen Blixen
  2. 안나 카레니나 - 레프 톨스토이, 펭귄클래식
  3. 브로크백 마운틴 - 애니 프루
  4. 아들과 연인 - 데이비드 허버트 로런스, 열린책들
@fernandoaleman
fernandoaleman / mysql2-mojave.md
Last active February 7, 2024 19:19
Install mysql2 on MacOS Mojave

For MacOS Catalina, visit Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

@siklodi-mariusz
siklodi-mariusz / Dockerfile
Created January 30, 2018 19:40
Dockerfile example for Ruby on Rails running on Alpine Linux
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
@enricofoltran
enricofoltran / main.go
Last active April 6, 2025 09:48
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
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>,
@jahe
jahe / jpa-cheatsheet.java
Last active May 2, 2025 03:08
JPA Cheatsheet
/*
JPA (Java Persistence API)
Transaction Management with an Entity-Mananger:
---
entityManager.getTransaction().begin();
entityManager.persist(<some-entity>);
entityManager.getTransaction().commit();
entityManager.clear();
@mwlang
mwlang / application_controller.rb
Last active March 17, 2025 19:11
Logging headers, params, and body to console -- useful for debugging what a mobile app is sending Rails API backend server.
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
@peterhellberg
peterhellberg / graceful.go
Last active November 13, 2024 20:20
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)