Skip to content

Instantly share code, notes, and snippets.

@htp
htp / curl-websocket.sh
Last active March 3, 2024 20:01
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@ThomDietrich
ThomDietrich / git-create-revisioninfo-hook.sh
Last active December 19, 2022 15:23
git hook for revision and branch version file
#!/bin/bash
## Automatically generate a file with git branch and revision info
##
## Example:
## [master]v2.0.0-beta-191(a830382)
## Install:
## cp git-create-revisioninfo-hook.sh .git/hooks/post-commit
## cp git-create-revisioninfo-hook.sh .git/hooks/post-checkout
## cp git-create-revisioninfo-hook.sh .git/hooks/post-merge
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@derwiki
derwiki / README.md
Last active September 27, 2023 17:50
Ruby module that you can use in a `before_action` on sensitive controllers for which you'd like a usage audit trail

Adding an audit log to your Rails app

If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:

  • controller entry points with parameter values
  • permanent information about the user, like user_id
  • transient information about the user, like IP and user_agent

Using the Rails framework, this is as simple as adding a before_action to your admin controllers. Here’s a basic version that I’m using in production.

@solnic
solnic / type_safe_entity_vs_ar.rb
Last active November 24, 2021 02:23
Fetching type-safe entity with rom repo vs AR
Calculating -------------------------------------
type-safe users 273.000 i/100ms
ar user models 257.000 i/100ms
-------------------------------------------------
type-safe users 2.813k (± 1.7%) i/s - 14.196k
ar user models 2.574k (±10.7%) i/s - 12.850k
Comparison:
type-safe users: 2812.7 i/s
ar user models: 2574.2 i/s - 1.09x slower
@tangqiaoboy
tangqiaoboy / iOS 技能图谱.md
Last active February 10, 2024 12:43
iOS 技能图谱

编程语言

  • Swift
  • Objective-C
  • C++/C
  • JavaScript

操作系统

  • Mac OSX
  • iOS
@vkostyukov
vkostyukov / statuses.md
Last active February 13, 2024 21:39
HTTP status codes used by world-famous APIs
API Status Codes
[Twitter][tw] 200, 304, 400, 401, 403, 404, 406, 410, 420, 422, 429, 500, 502, 503, 504
[Stripe][stripe] 200, 400, 401, 402, 404, 429, 500, 502, 503, 504
[Github][gh] 200, 400, 422, 301, 302, 304, 307, 401, 403
[Pagerduty][pd] 200, 201, 204, 400, 401, 403, 404, 408, 500
[NewRelic Plugins][nr] 200, 400, 403, 404, 405, 413, 500, 502, 503, 503
[Etsy][etsy] 200, 201, 400, 403, 404, 500, 503
[Dropbox][db] 200, 400, 401, 403, 404, 405, 429, 503, 507
@djonsson
djonsson / install_elasticsearch_osx.md
Last active November 11, 2022 21:10
OS X installation instructions for Elasticsearch + Kibana + Marvel

What is this?

Following this guide will set up a local Elasticsearch with Kibana and Marvel using Homebrew and Homebrew Cask

Prerequisites

If you already have Java installed on your system, skip steps Install Cask and Install Java

If you already have Java and Homebrew installed on your system, skip steps Prerequisites, start at Install Elasticsearch and Kibana after running $ brew update

Install Homebrew

  • $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@PurpleBooth
PurpleBooth / README-Template.md
Last active March 24, 2024 02:11
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@maxivak
maxivak / readme.md
Last active January 12, 2024 06:53
Integrating Gem/Engine and Main Rails App