Skip to content

Instantly share code, notes, and snippets.

View caarlos0's full-sized avatar
๐Ÿ„

Carlos Alexandro Becker caarlos0

๐Ÿ„
View GitHub Profile
@egonSchiele
egonSchiele / rons.rb
Last active October 30, 2022 06:16
The dining philosophers problem in Ruby, solved using the resource hierarchy solution
require 'thread'
class Ron
def initialize(name, left_fork, right_fork)
@name = name
@left_fork = left_fork
@right_fork = right_fork
while true
think
dine
@carlosspohr
carlosspohr / README.md
Last active August 31, 2023 00:35
Functional Apache2 route for Gitlab 5.0

For your Ruby, you'll must install this gems:

sudo gem install passenger

sudo passenger-install-apache2-module

At this moment, you'll asked to install some Apache2's deps (three deps):

sudo apt-get install apache2-prefork-dev

@mrflip
mrflip / 20130416-todo.md
Last active March 18, 2025 10:38
Elasticsearch Tuning Plan

Next Steps

  • Measure time spend on index, flush, refresh, merge, query, etc. (TD - done)
  • Take hot threads snapshots under read+write, read-only, write-only (TD - done)
  • Adjust refresh time to 10s (from 1s) and see how load changes (TD)
  • Measure time of a rolling restart doing disable_flush and disable_recovery (TD)
  • Specify routing on query -- make it choose same node for each shard each time (MD)
  • GC new generation size (TD)
  • Warmers
  • measure before/after of client query time with and without warmers (MD)
@patjackson52
patjackson52 / LandingPage.java
Created April 9, 2013 14:24
GWT-Bootstrap implementation of the masthead as shown in the twitter bootstrap marketing example. The second file is how to use the Masthead.
MastHead mastHead=new MastHead();
NavLink logIn=new NavLink("Log In");
NavLink aboutButton=new NavLink("About");
mastHead.setText("My Awesome App");
mastHead.setSubtext("Subtitle");
mastHead.addButton(logIn);
mastHead.addButton(aboutButton);
@massahud
massahud / 1-README.md
Last active June 28, 2017 14:15
flyingsaucer xhtml to pdf servlet filter

Filter to generate PDF from Servlet dynamic pages

This filter intercepts the response and runs Flying Saucer ITextRenderer on it, returning a pdf instead.

Configuration

Just put the filter on your code and configure the url patterns where it will run on web.xml. The filtered pages will return as pdf documents.

@caarlos0
caarlos0 / color.js
Last active December 10, 2015 14:18
document.body.innerHTML="";setInterval(function(){document.body.style.background='#'+(Math.random()*0x1000000<<0).toString(16)},50);
@jussi-kalliokoski
jussi-kalliokoski / git-pick-file.sh
Last active July 11, 2022 10:08
Cherry-picks commits from master that have changes to specified files.
$!/usr/bin/env sh
branch=`git symbolic-ref --short HEAD`
git checkout master
commits=`git log --pretty="%H" --reverse -- $*`
git checkout $branch
for commit in $commits; do
git cherry-pick $commit
done
@derekstavis
derekstavis / DigitalClock.java
Created October 15, 2012 18:43
DigitalClock HH:MM for Android
package com.derekstavis;
public class DigitalClock extends TextView {
private int hours;
private int minutes;
private int seconds;
private Timer clockTimer;
private final TimerTask clockTask = new TimerTask() {
@Override
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@brandonb927
brandonb927 / osx-for-hackers.sh
Last active April 3, 2025 13:20
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx