Skip to content

Instantly share code, notes, and snippets.

View stevecondylios's full-sized avatar

Steve Condylios stevecondylios

View GitHub Profile
@rbitr
rbitr / timing.md
Created January 27, 2024 18:02
Timing counting in assembly

The following assembly code counter.asm counts to 10^9, using a linux system call to print:

section .data
    count dd 0          ; Define a 32-bit integer for the count

section .text
    global _start

_start:
@andynu
andynu / show_method_history.rb
Created August 26, 2022 18:56
Given a ruby file and method name shows you all the different versions across the git history.
#!/usr/bin/env ruby
# Given a file and method_name
# Show all the different implementations across the git history (first commit per implementation).
#
# show_method_history <file> <method_name> --html
#
# e.g. show_method_history test/test_helper.rb sign_in --html
#
# WARNING: the --html output just dumps html files into your current folder.
#
library(ggplot2)
library(ggirl)
# create the plot
plot <- ggplot() +
geom_polygon( data=map_data("state"), aes(x=long, y=lat, group=group),
fill="#cdddee", color="#7296bc" )+
geom_point(data = data.frame(long = -77.01728, lat = 38.78125),
aes(x=long, y=lat),
@andynu
andynu / routes_check.rake
Last active June 1, 2022 01:40
Parses production logs and checks which routes are used out of all the routes that are defined.
desc 'Show basic controller usage stats'
task :controllers => :environment do
logfiles = Dir['log/%s.log*' % Rails.env].sort
logs_gz, logs_txt = logfiles.partition{|f| Pathname.new(f).extname == '.gz' }
results = `ag Started -A 1 #{logs_txt.join(' ')}`
unless logs_gz.empty?
results << `zcat #{logs_gz.join(' ')} |ag Started -A 1`
end
Event = Struct.new(:http_method, :uri_path, :client_ip, :requested_at_str, :controller_name, :controller_action, :format) do
def requested_at
@natematykiewicz
natematykiewicz / unroutable_routes.rake
Last active June 9, 2022 19:47
Find routes that will raise a routing error when requested
desc 'Find routes that will raise a routing error when requested'
task unroutable_routes: :environment do
# A lot of this code was taken from how `rake routes` works
# https://github.com/rails/rails/blob/f95c0b7e96eb36bc3efc0c5beffbb9e84ea664e4/railties/lib/rails/commands/routes/routes_command.rb
require 'action_dispatch/routing/inspector'
unroutables = Rails.application.routes.routes.
map { |r| ActionDispatch::Routing::RouteWrapper.new(r) }.
reject { |r| r.internal? || r.engine? || r.path.starts_with?('/rails/') || !r.controller }.
@andynu
andynu / rfluff.rb
Created May 18, 2022 12:53
rfluff a way to list TODOS|XXX|HACK|etc /w optional vim quickfix formatting.
#!/usr/bin/ruby
#
# gather a few statistics and find all flagged comments
#
# Usage:
# rfluff [-qf] [tag] [tag] ...
#
# -qf outputs a vim compatible quickfix format, otherwise
# the output is human readable
Twitter ID Screen name Followers Removal observed Before After
17461978 SHAQ 15612791 2022-02-26T22:24:52Z SHAQ.ETH SHAQ.SOL
21910850 jakeowen 2119904 2022-02-26T15:45:18Z jakeowen.eth Jake Owen
7846 ijustine 1811449 2022-03-09T14:43:37Z iJustine.eth iJustineUltra
1666038950 BoredElonMusk 1752290 2022-02-17T08:05:47Z bored.eth Bored
381051960 ethRuby 1267133 2022-03-19T08:08:11Z CryptoSolis.eth Ruby
1282418324228337665 wsbmod 832406 2022-02-24T06:52:07Z wsbmod.eth wsbmod
20882981 EclecticMethod 495235 2022-02-18T04:39:30Z eclecticm.eth Eclectic Method
811350 alexisohanian 479340 2022-02-08T06:31:55Z AlexisOhanian.eth 7️⃣7️⃣6️⃣ Alexis Ohanian 7️⃣7️⃣6️⃣
22784458 Fwiz 410813 2022-03-22T08:54:42Z Ryan Wyatt - fwiz.eth 💜 Ryan Wyatt - @ GDC
@martinwoodward
martinwoodward / mermaid.md
Created February 11, 2022 20:34
GitHub HTML Rendering Pipeline
```mermaid
sequenceDiagram
    participant dotcom
    participant iframe
    participant viewscreen
    dotcom->>iframe: loads html w/ iframe url
    iframe->>viewscreen: request template
    viewscreen->>iframe: html & javascript
 iframe-&gt;&gt;dotcom: iframe ready
@brenogazzola
brenogazzola / migrate_im_to_vips.md
Last active March 17, 2024 21:56
Steps to migrate ImageMagick to Libvips

For apps built before the image_processing gem became the default, the migration will involve two steps:

  1. Migrating to the image processing syntax while still using ImageMagick;
  2. Switching to Vips and updating the compression options;

Migrate to the image processing syntax

Before changing from ImageMagick to Vips, it's better to first test the new syntax and ensure everything is still working.

1. Move everything that has to do with compression to a saver hash:

variant(format: :jpg, strip: true, quality: 80)
@navicore
navicore / nvim-r.txt
Last active January 24, 2024 13:48
R cheatsheet and nvim-r commands
Menu entry Default shortcut~
Start/Close
. Start R (default) \rf
. Start R (custom) \rc
--------------------------------------------------------
. Close R (no save) \rq
. Stop (interrupt) R :RStop
-----------------------------------------------------------