Skip to content

Instantly share code, notes, and snippets.

View RX14's full-sized avatar

Stephanie Wilde-Hobbs RX14

View GitHub Profile
@RX14
RX14 / ghrecentrepos.user.js
Created May 22, 2020 17:03 — forked from maxpowa/ghrecentrepos.user.js
recent repos on sidebar
// ==UserScript==
// @name Github Chronological Repo List
// @namespace https://gist.github.com/maxpowa/d3eb439b990fbee8cff2ae45d726c834
// @description Bring back chronological repo list on the github home page
// @include https://github.com/
// @version 0.0.2
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
@RX14
RX14 / libraries.ps1
Last active March 9, 2024 17:56
Compile libraries needed for Crystal on Windows
.\vs_buildtools.exe --passive --norestart --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended | Out-Default
$script = @'
$installdir = "$pwd"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
echo "Downloading cmake"
iwr https://cmake.org/files/v3.11/cmake-3.11.4-win64-x64.zip -OutFile cmake.zip
Expand-Archive cmake.zip -DestinationPath .
@RX14
RX14 / json_with_annotations.cr
Last active May 4, 2018 23:32 — forked from asterite/json_with_annotations.txt
How JSON serialization would look like if Crystal had user-defined annotations like Java/C#
require "spec"
require "json"
require "uuid"
require "uuid/json"
require "big/json"
module JSON
annotation SerializableAnnotation
end
@RX14
RX14 / cr1.cr
Last active January 1, 2018 17:40 — forked from kingsleyh/cr1.cr
crystal
def isLoggedIn(context, repo)
sessionId = context.session.string?("userId")
if sessionId
user = repo.findUserByUserId(sessionId)
case user
when DB::Success
groupId = user.value["activeChannel"].as_h.fetch("groupId", "")
channelId = user.value["activeChannel"].as_h.fetch("channelId", "")
@RX14
RX14 / alisp.cr
Last active December 16, 2017 18:12 — forked from simenge/alisp.cr
module Lisp
alias Value = Symbol | String | Int64 | Bool | Nil | Builtin | List
record Symbol, value : String
struct List
getter list : Array(Value)
def initialize(@list = Array(Value).new)
end
require "big_decimal"
require "benchmark"
def new(str : String) : BigDecimal
reader = Char::Reader.new(str)
value = BigInt.new(0)
scale = 0_u64
if reader.current_char == '-'
negative = true
require "http"
require "radix"
class WebServer
alias Route = HTTP::Server::Context, Hash(String, String) -> Nil
def initialize(@config : Config, @db : DB::Database)
@tree = Radix::Tree(Route).new
draw_routes
@RX14
RX14 / video_file.cr
Last active September 19, 2016 19:55
module MediaManager
class VideoFile
CHUNK_SIZE = 64 * 1024
def self.compute_hash(file_path : String)
filesize = File.size(file_path)
hash = filesize
# Read 64 kbytes, divide up into 64 bits and add each
# to hash. Do for beginning and end of file.
require "benchmark"
STATUS_CODE = "200"
METHOD = "GET"
PATH = "api/v1/users"
IO = MemoryIO.new(100)
Benchmark.ips do |x|
x.report "Normal String" do
IO << "|#{STATUS_CODE}| #{METHOD} #{PATH}"
@RX14
RX14 / fsm.svg
Created July 4, 2016 16:58
Multipart::Generator FSM
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.