Skip to content

Instantly share code, notes, and snippets.

View Cosmo's full-sized avatar
📎
It looks like you're looking at my profile. Would you like help?

Devran Cosmo Uenal Cosmo

📎
It looks like you're looking at my profile. Would you like help?
View GitHub Profile
@kaylareopelle
kaylareopelle / otel_workshop_code_snippets.md
Last active August 9, 2025 19:44
Code snippets to accompany 2025 RailsConf OpenTelemetry Workshop

How to instrument your Rails application with OpenTelemetry

This gist accompanies a workshop titled "How to instrument your Rails app with OpenTelemetry" that was held at RailsConf 2025 in Philadelphia on July 9, 2025.

  • Repository
  • Slides (coming soon)
  • Recording (coming soon)
@xiaohui-zhangxh
xiaohui-zhangxh / application_controller.rb
Last active November 19, 2024 03:07
Make active_model_serializers render Pagy result as jsonapi response, with pagination meta and links
class Api::ApplicationController < ActionController::API
include Pagy::Backend
include PagyCollectionSerializer::ControllerMixin
end
@lingceng
lingceng / plain_chatgpt_client.rb
Created May 29, 2023 00:34
Ruby chatgpt chat api when stream mode, deal with error handle and chunk break.
class Chatgpt::PlainChatgptClient
def self.chat(parameters)
@client ||= generate_client
res = @client.post("/v1/chat/completions") do |req|
if parameters[:stream].is_a?(Proc)
req.options.on_data = to_json_stream(user_proc: parameters[:stream])
parameters[:stream] = true
end
@Reiss-Cashmore
Reiss-Cashmore / disable.sh
Created February 19, 2023 22:35
disable.sh
#!/bin/zsh
#Credit: Original idea and script disable.sh by pwnsdx https://gist.github.com/pwnsdx/d87b034c4c0210b988040ad2f85a68d3
#*****Work in progress*****
#Disabling unwanted services on macOS 11 Big Sur
#Modifications written in /private/var/db/com.apple.xpc.launchd/ disabled.plist, disabled.501.plist & disabled.205.plist
#Disabling SIP might not be required, still testing.
sudo mkdir mnt
sudo mount -o nobrowse -t apfs /dev/disk1s5 mnt/
@equivalent
equivalent / README.md
Last active July 25, 2025 10:22
Rails 7 importmaps dropzone.js direct upload ActiveStorage

This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.

@memoryleak
memoryleak / create-monterey-iso.sh
Last active November 12, 2024 11:41
Create a Mac OS Monterey ISO file from the official installation DMG file
#!/usr/bin/env bash
sudo hdiutil create -o /tmp/Monterey -size 16g -volname Monterey -layout SPUD -fs HFS+J
sudo hdiutil attach /tmp/Monterey.dmg -noverify -mountpoint /Volumes/Monterey
sudo /Applications/Install\ macOS\ Monterey.app/Contents/Resources/createinstallmedia --volume /Volumes/Monterey --nointeraction
hdiutil eject -force /Volumes/Install\ macOS\ Monterey
hdiutil convert /tmp/Monterey.dmg -format UDTO -o ~/Downloads/Monterey
mv -v ~/Downloads/Monterey.cdr ~/Downloads/Monterey.iso
sudo rm -fv /tmp/Monterey.dmg
@hopsoft
hopsoft / Dockerfile
Last active May 17, 2023 19:58
Dockerize your Rails app
FROM ruby:3.0-alpine
RUN apk add --no-cache --update \
ack \
bash \
build-base \
curl \
git \
htop \
less \
@iccir
iccir / SimStatusBar.sh
Last active June 2, 2025 12:20
iOS Simulator Status Bars
# iPhone with home button
xcrun simctl status_bar booted clear
xcrun simctl status_bar booted override \
--time "9:41 AM" \
--wifiBars 3 --cellularBars 4 --operatorName ""
xcrun simctl spawn booted defaults write com.apple.springboard SBShowBatteryPercentage 1
# iPhone X
xcrun simctl status_bar booted clear
xcrun simctl status_bar booted override --time "9:41" --wifiBars 3 --cellularBars 4
@ole
ole / !swiftui-reflection-dump.md
Last active November 24, 2024 03:26
A dump of the SwiftUI.framework binary for the iOS simulator (as of Xcode 12.0 beta 2) using the swift-reflection-dump tool.

A dump of the SwiftUI.framework binary for the iOS simulator (as of Xcode 12.0 beta 2) using the swift-reflection-dump tool.

Note: I used a Swift 5.3 compiler build from a few weeks ago that I had laying around. Because of ABI stability, I don't think the swift-reflection-dump version has to match the compiler version that was used to build the binary, but I'm not 100% sure.

@mfts
mfts / letsencrypt.sh
Created January 29, 2020 18:19
Create Letsencrypt wildcard certificate
brew install certbot
# change <my.domain> to preferred domain
certbot certonly --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory --manual-public-ip-logging-ok -d '*.<my.domain>' -d <my.domain>
# add certificates to heroku
heroku certs:add -a eduqai-prod /etc/letsencrypt/live/<my.domain>/fullchain.pem /etc/letsencrypt/live/<my.domain>/privkey.pem
# may need to run with sudo