Skip to content

Instantly share code, notes, and snippets.

View Mark24Code's full-sized avatar
💻
Exploring

Mark24 Mark24Code

💻
Exploring
View GitHub Profile
@Mark24Code
Mark24Code / rdoc_example.rb
Created January 12, 2025 09:56 — forked from hunj/rdoc_example.rb
Ruby RDoc Example
## Found in: http://blog.firsthand.ca/2010/09/ruby-rdoc-example.html
# * Style guide based on Rails documention
module Namespace #:nodoc: don't document this
# Generic Namespace exception class
class NamespaceError < StandardError
end
# Raised when...
@Mark24Code
Mark24Code / terminal_size.rb
Created December 28, 2024 06:08 — forked from KINGSABRI/terminal_size.rb
Getting Terminal size by ruby
# Here are many ways to get terminal size from ruby
# By Readline
require 'readline'
Readline.get_screen_size #=> [31, 268]
# Get terminal size in Environemtn like IRB
[ENV['COLUMNS'].to_i, ENV['LINES'].to_i]
@Mark24Code
Mark24Code / gist:522457390bd7d94356017b404c1754a1
Created August 13, 2024 15:51 — forked from jauderho/gist:6b7d42030e264a135450ecc0ba521bd8
HOWTO: Upgrade Raspberry Pi OS from Bullseye to Bookworm
### WARNING: READ CAREFULLY BEFORE ATTEMPTING ###
#
# Officially, this is not recommended. YMMV
# https://www.raspberrypi.com/news/bookworm-the-new-version-of-raspberry-pi-os/
#
# This mostly works if you are on 64bit. You are on your own if you are on 32bit or mixed 64/32bit
#
# Credit to anfractuosity and fgimenezm for figuring out additional details for kernels
#
@Mark24Code
Mark24Code / instructions.md
Created July 12, 2024 09:45 — forked from matthewjberger/instructions.md
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

@Mark24Code
Mark24Code / middleware.rb
Created September 27, 2023 02:36 — forked from marcelobbfonseca/middleware.rb
Sinatra ruby JWT authentication middleware
# To connect this middleware.rb file to your sinatra app
# add 'use JWTAuthorization' as one of your first lines in
# your Application class.
# e.g.
# require 'middlewares.rb'
# class Application < Sinatra::Base
# use JWTAuthorization
# ...
# end
@Mark24Code
Mark24Code / process_rss.rb
Created January 21, 2022 07:22 — forked from pvdb/process_rss.rb
Get real memory (resident set) used by current Ruby process
#
# This first version should work on Mac OS X and Linux, but it spawns a process
#
# http://stackoverflow.com/questions/7220896/
# https://github.com/rdp/os/blob/master/lib/os.rb#L127
# http://www.ruby-doc.org/core-2.0/Process.html
#
# the real memory (resident set) size of the process (in 1_024 byte units).
def Process.rss() `ps -o rss= -p #{Process.pid}`.chomp.to_i ; end
@Mark24Code
Mark24Code / debug_httparty_request.rb
Created January 12, 2022 04:47 — forked from natritmeyer/debug_httparty_request.rb
How to debug HTTParty requests
class MyResource
include HTTParty
debug_output $stdout # <= will spit out all request details to the console
#...
end
@Mark24Code
Mark24Code / nginx.conf
Last active June 13, 2020 16:06
Nginx.conf注释版本
#总体上分成三个部分构成:基本配置、events配置、HTTP配置,以下为配置详情
#------------------------基本配置-------------------------
#user nobody; #配置worker进程运行用户
worker_processes 4; #配置工作进程数目,根据硬件调整,通常等于CPU数量或者2倍于CPU数量
#error_log logs/error.log; #配置全局错误日志及类型,[debug | info | notice | warn | error | crit],默认是error
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid; #配置进程pid文件
@Mark24Code
Mark24Code / .irbrc
Created June 5, 2020 09:58
ruby irb自动补全配置
require 'bond'
Bond.start
# For users using a pure ruby readline
Bond.start :readline => :ruby
git log --numstat --pretty="%H" <HashStart>..<HashEnd> | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d,-%d\n",plus,minus)}'\n