Skip to content

Instantly share code, notes, and snippets.

View LuPoYi's full-sized avatar
🦔

Bob LuPoYi

🦔
  • Taiwan
View GitHub Profile
@beautyfree
beautyfree / snippets.js
Last active December 14, 2022 11:49
Solana Web3 Snippets
import {
Account,
clusterApiUrl,
Connection,
PublicKey,
sendAndConfirmTransaction,
SystemProgram,
Transaction,
} from '@solana/web3.js';
@JokerCatz
JokerCatz / session_store.rb
Created January 17, 2020 03:10
Rails6 Redis Session Store (serializer by JSON)
# -*- encoding : utf-8 -*-
Rails.application.config.session_store(
:redis_store,
key: "_#{Rails.application.class.parent_name.downcase}_session",
expire_after: 2.days,
threadsafe: true,
url: "redis://127.0.0.1:6379/8",
)
# Redis session store(serializer by JSON) for Rails 6
@O-I
O-I / hash_except.md
Last active August 2, 2023 17:31
[TIx 4] Remove key-value pairs from a hash and return the hash

Note: As of Ruby 3.0.0, Hash#except is now [part][1] of the language. However, Ruby does not implement Hash#except!.

Sometimes I want to remove a specific key-value pair from a Ruby hash and get the resulting hash back. If you're using Rails or ActiveSupport you can accomplish this using Hash#except:

hash = { a: 1, b: 2, c: 3 }
hash.except(:a)     # => { b: 2, c: 3 }

# note, the original hash is not modified
hash # => { a: 1, b: 2, c: 3 }