Skip to content

Instantly share code, notes, and snippets.

View sleepingfrog's full-sized avatar

sleepingfrog

  • 10:37 (UTC +09:00)
View GitHub Profile
-- =============================================================================
-- Basic Editor Settings
-- =============================================================================
vim.g.mapleader = ' '
vim.opt.number = true
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
-- =============================================================================
query = \
'query CompareBranches($owner: String!, $repo: String!, $baseRef: String!, $headRef: String!, $cursor: String) {
repository(owner: $owner, name: $repo) {
base: ref(qualifiedName: $baseRef) {
compare(headRef: $headRef) {
status
aheadBy
commits(first: 1, after: $cursor) {
nodes {
oid
FROM ruby:3.0.4-bullseye
ENV VOLTA_HOME="/opt/.volta" PATH="/opt/.volta/bin:/usr/local/bin:$PATH"
RUN curl https://get.volta.sh | bash && volta install node yarn
RUN mkdir /app
RUN useradd app --create-home --shell /bin/bash && \
chown -R app:app /app
WORKDIR /app
require 'benchmark/ips'
def one(a, b)
a.quo(b).ceil
end
def two(a, b)
- (a.div(-b))
end
@sleepingfrog
sleepingfrog / foo.rb
Created August 23, 2023 20:21
min heap
class Foo
def initialize
@ary = []
end
def size
@ary.size
end
def top
@sleepingfrog
sleepingfrog / access.rb
Last active July 16, 2023 20:57
with query with arel
class Access < ApplicationRecord
module Aggs
class << self
# SELECT
# DISTINCT
# "accesses"."user_token",
# FIRST_VALUE("accesses"."access_date") OVER (PARTITION BY "accesses"."user_token" ORDER BY "accesses"."access_date") AS first_access
# FROM "accesses"
# WHERE
# "accesses"."access_date" BETWEEN '2000-01-01' AND '2000-02-01'
mail = Mail.new(**)
File.open("tmp/mail.html", "w") { |f| f.write(mail.html_part.body.decoded)}
File.open("tmp/mail.txt", "w") { |f| f.write(mail.text_part.body.decoded.force_encoding(mail.content_type_parameters["charset"]).encode("UTF-8"))}
Get-ChildItem . | Where-Object { $_.BaseName -like "1*" } | measure -Sum Length
Get-ChildItem . | Where-Object {($_.Extension -like ".jsx" )} | measure -Sum Length
Get-ChildItem . | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-7))} | measure -Sum Length
@sleepingfrog
sleepingfrog / call.rb
Created March 23, 2022 10:33
newをprivateにしてendpointを明示する感じ
module CallWith
def call_with(method)
module_eval <<~RUBY
def self.#{method}(*args, **kwargs)
private_class_method :new
new(*args, **kwargs).public_send(:'#{method}')
end
RUBY
end
end
require "uri"
require "json"
require "net/http"
module GoogleChatWebHook
class Client
attr_reader :response, :thread_name
def initialize(url, thread_name: nil)
@url = URI.parse(url)
@request = Net::HTTP::Post.new(@url)