Skip to content

Instantly share code, notes, and snippets.

# RingBuffer class:
# https://github.com/celluloid/celluloid/blob/master/lib/celluloid/logging/ring_buffer.rb
# added the moving average method
class RingBuffer
attr_reader :buffer
def initialize(size)
@size = size
require './ring_buffer.rb'
iterations = 1000
RING_SIZE = 25
ring = RingBuffer.new(RING_SIZE)
iterations.times do |i|
time_start = Time.now
400000.times do |t|
@nkokkos
nkokkos / filter_Select_listbox.html
Last active May 23, 2021 17:58
Filter Select List Box with ES6
/* Stolen from here: https://esausilva.com/2017/02/21/filter-select-list-options-typeahead-in-javascript-es6/ */
/* Added document.getElementByID instead of querySelectorAll
<html>
<head>
<style>
div {
width: 280px;
margin: 10 auto;
}
input {
@nkokkos
nkokkos / gist:9495540852395161c58a84916de235b1
Created October 15, 2018 09:47
Break a pdf file to subparts with ghostscript on windows
c:\gswin32c.exe -sDEVICE=pdfwrite \
-dNOPAUSE \
-dBATCH \
-dSAFER \
-dCompatibilityLevel=1.6 \
-dPDFSETTINGS=/prepress
-dEmbedAllFonts=true \
-dSubsetFonts=false \
-dFirstPage=1 -dLastPage=100 \
@nkokkos
nkokkos / gist:9ffddfb1f47e7690c381b429f2925123
Created January 19, 2018 15:14
Rescue Commands in Postgresql
Rescue Commands in Postgresql
#start with:
$sudo su postgres
$psql
#then do :
#show all databases
\dl
var RTCPeerConnection = null;
var getUserMedia = null;
var attachMediaStream = null;
var reattachMediaStream = null;
var webrtcDetectedBrowser = null;
var webrtcDetectedVersion = null;
function trace(text) {
if (text[text.length - 1] === "\n") {
text = text.substring(0, text.length - 1);
@nkokkos
nkokkos / gist:4f8c8d56bba3762a11fa
Created September 16, 2014 08:13
cache_store.yml and redis.yml files
#cache_store.yml file:
production:
cache_store: redis_store
servers:
- redis://localhost
database: 1
#redis.yml file:
production:
@nkokkos
nkokkos / unicorn.rb
Created September 8, 2014 07:59
Unicorn file for serving Canvas lms
# canvas-lms/config/unicorn.rb:
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
@nkokkos
nkokkos / nginx.conf
Created May 30, 2013 09:50
This is an nginx configuration file for serving 2 or more rails applications at their own suburi using the passenger gem. That is, if you have a server http://myserver.com and you want to serve your app at http://myserver.com/app1 and your app2 at http://myserver.com/app2
#/opt/nginx/conf/nginx.conf
user nginx;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;