Skip to content

Instantly share code, notes, and snippets.

View rpereira's full-sized avatar
🌱
​[object Object]

Rui Afonso Pereira rpereira

🌱
​[object Object]
View GitHub Profile
@druska
druska / engine.c
Created September 17, 2018 15:18
Quant Cup 1's winning order book implementation
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@dtchepak
dtchepak / echo.rb
Last active September 12, 2022 07:24
Simple Ruby HTTP server to echo whatever GET or POST requests come through. Largely based on https://www.igvita.com/2007/02/13/building-dynamic-webrick-servers-in-ruby/.
# Reference: https://www.igvita.com/2007/02/13/building-dynamic-webrick-servers-in-ruby/
require 'webrick'
class Echo < WEBrick::HTTPServlet::AbstractServlet
def do_GET(request, response)
puts request
response.status = 200
end
def do_POST(request, response)
puts request
@junegunn
junegunn / gist:f4fca918e937e6bf5bad
Last active March 30, 2024 23:40
Browsing git commit history with fzf
# fshow - git commit browser (enter for show, ctrl-d for diff, ` toggles sort)
fshow() {
local out shas sha q k
while out=$(
git log --graph --color=always \
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" |
fzf --ansi --multi --no-sort --reverse --query="$q" \
--print-query --expect=ctrl-d --toggle-sort=\`); do
q=$(head -1 <<< "$out")
k=$(head -2 <<< "$out" | tail -1)
@juanbrujo
juanbrujo / fullCalendarDisablePrevNext.js
Last active November 16, 2020 07:35
jQuery FullCalendar.js: disable prev/next button for past/future dates
$('#calendar').fullCalendar({
viewRender: function(currentView){
var minDate = moment(),
maxDate = moment().add(2,'weeks');
// Past
if (minDate >= currentView.start && minDate <= currentView.end) {
$(".fc-prev-button").prop('disabled', true);
$(".fc-prev-button").addClass('fc-state-disabled');
}
else {
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
@gennad
gennad / BFSDFS.java
Created January 23, 2011 09:14
Breadth-first search and depth-first search Java implementation
Class Main {
public void bfs()
{
// BFS uses Queue data structure
Queue queue = new LinkedList();
queue.add(this.rootNode);
printNode(this.rootNode);
rootNode.visited = true;
while(!queue.isEmpty()) {
Node node = (Node)queue.remove();