Skip to content

Instantly share code, notes, and snippets.

Avatar
✔️
Verified

Garrett T film42

✔️
Verified
View GitHub Profile
View async_controller.rb
class YoloController < ApplicationController
include ::AsyncResponse
def index
async do
sleep 2
@yolo = "I AM ASYNC"
resume_render
View simple_test.c
//////////////////////////////////
// Test Runner Code
//////////////////////////////////
#include <stdio.h>
typedef int (test_fn_t)(void);
struct test_t {
char * name;
View async-publisher-benchmark
Benchmark.measure { 10_000.times { ActionSubscriber::Publisher.publish("test", "test", "test") } }
5.590000 2.110000 7.700000 ( 14.262266)
Benchmark.measure { 10_000.times { ActionSubscriber::Publisher.publish_async("test", "test", "test") } }
0.030000 0.000000 0.030000 ( 0.025184)
View ujelly-theme-autoloads.el
;;; ujelly-theme-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil "ujelly-theme" "ujelly-theme.el" (21808 38161
;;;;;; 0 0))
;;; Generated autoloads from ujelly-theme.el
View sql_paginator.rb
class AnyPage
attr_reader :sql
def initialize(sql, options = {})
@page_size = options.fetch(:page_size) { 1000 }
@sql = sql
@total_pages = nil
end
def self.page(sql, nth, options = {})
View socket_tricks.rb
require "socket"
# Detect if a socket is in CLOSE_WAIT
def socket_in_close_wait?(socket)
# Will return empty string on EOF (closed socket)
socket.recv_nonblock(1, ::Socket::MSG_PEEK) == ""
rescue IO::WaitReadable
false
end
View service_directory.ex
defmodule Rpc do
defmodule ServiceDirectory do
defmodule Instance do
defstruct address: nil, port: nil, expires_at: nil, uuid: nil
end
##
# USAGE:
#
# Rpc.ServiceDirectory.start_link(port: 53023)
View ar.rs
trait Queryable {
fn pluralized_table_name(&self) -> String;
fn predicates(&self) -> &Vec<String>;
fn has_limit(&self) -> bool {
return self.limit_value() >= 0;
}
fn limit_value(&self) -> i64;
View broken_enums.rb
class EnumDeliveryType < ::Protobuf::Enum
define :STANDARD, 1
define :PRIORITY, 2
define :NEXT_DAY, 3
define :OVERNIGHT, 4
end
# # # # # # # # # # # # # PART 1 # # # # # # # # # # # # #
##
View thread-backtrace.rb
Thread.new do
trap(:TRAP) do
::Thread.list.each do |thread|
puts <<-THREAD_TRACE
#{thread.inspect}:
#{thread.backtrace.try(:join, $INPUT_RECORD_SEPARATOR)}"
THREAD_TRACE
end
end
end