Skip to content

Instantly share code, notes, and snippets.

View hxegon's full-sized avatar
🎧
Always Be Coding

Cooper LeBrun hxegon

🎧
Always Be Coding
  • Vaudreuil-Dorion, QC
View GitHub Profile
# Copyright 2018 Stanko K.R. <[email protected]>
#
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the
# Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject
# to the following conditions:
@WJWH
WJWH / c10k.ru
Created October 15, 2018 09:12
The double hijack trick, serving 65k connections from a single ruby process
# This server demo does a socket hijack in Rack and then saves the socket to a global variable
# to prevent it from being GCed when the Puma thread ends. It will then write "BEEP" to each
# socket every ten seconds to prevent the connection timing out. During testing, it easily
# handled up to 65523 connections, after which it ran into the `ulimit` for open file descriptors.
# The bit with the waiting area is there because a normal `Set` is not thread safe and it would
# drop socket due to race conditions. The `Queue` is thread safe and will make sure all sockets
# are preserved.
# run with `rackup -q -p 8000 -o 0.0.0.0 c10k.ru`
# testing: install `ab` and then run `ab -c 20000 -n 20000 <ip adress of server>:8000/
@reborg
reborg / rich-already-answered-that.md
Last active September 25, 2024 17:06
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@kbussell
kbussell / ctrlTap.lua
Last active February 13, 2021 17:46
Send escape key if the ctrl key is tapped. (Used along side remapping my Caps Lock key to ctrl) Thanks to @asmagill 's examples for a starting point.
local alert = require("hs.alert")
local timer = require("hs.timer")
local eventtap = require("hs.eventtap")
local events = eventtap.event.types
local module = {}
-- timeout for ctrol key
module.timeFrame = .25
#!/usr/bin/env ruby
$elements = {
:H => { :string => "22", :evolution => [:H], },
:He => { :string => "13112221133211322112211213322112", :evolution => [:Hf,:Pa,:H,:Ca,:Li], },
:Li => { :string => "312211322212221121123222112", :evolution => [:He], },
:Be => { :string => "111312211312113221133211322112211213322112", :evolution => [:Ge,:Ca,:Li], },
:B => { :string => "1321132122211322212221121123222112", :evolution => [:Be], },
:C => { :string => "3113112211322112211213322112", :evolution => [:B], },
:N => { :string => "111312212221121123222112", :evolution => [:C], },
@mohayonao
mohayonao / morse-code.json
Created July 14, 2014 06:18
morse-code.json
{
"0": "-----",
"1": ".----",
"2": "..---",
"3": "...--",
"4": "....-",
"5": ".....",
"6": "-....",
"7": "--...",
"8": "---..",
@terjesb
terjesb / excel_core.clj
Created August 16, 2012 09:57 — forked from jramb/excel_core.clj
Creating and updating Excel files with Clojure/poi.apache.org
((ns excel.core
(:import [org.apache.poi.hssf.usermodel HSSFWorkbook HSSFSheet HSSFRow
HSSFRichTextString HSSFFont HSSFDataFormat
HSSFCellStyle HSSFCell])
(:import [java.io FileOutputStream FileInputStream IOException])
#_(:import [org.apache.poi.ss.util CellRangeAdrress]))
(defn make-excel [file-name]
(let [wb (HSSFWorkbook.)
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.