Skip to content

Instantly share code, notes, and snippets.

View vicentereig's full-sized avatar
🐢

Vicente Reig Rincón de Arellano vicentereig

🐢
View GitHub Profile
@extralam
extralam / AndroidHttpService.java
Last active August 29, 2015 14:02
Custom Http Service in Background thread
package com.extralam.api;
import android.app.TaskStackBuilder;
import android.os.SystemClock;
import android.util.Log;
import org.apache.http.*;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
@dnd
dnd / gist:f250a6c0cde8e79f9b20
Created August 29, 2014 06:09
Grape ActiveSupport Instrumentation
class Logger
def initialize(app)
@app = app
end
def call(env)
payload = {
remote_addr: env['REMOTE_ADDR'],
request_method: env['REQUEST_METHOD'],
request_path: env['PATH_INFO'],
@mikhailov
mikhailov / redis_usage.rb
Created January 18, 2010 06:52
Rails on Redis - is all about high performance
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
def index
@posts.all_cached # Retrive only at once by every 5 minutes
expires_in 5.minutes, :private => false, :public => true
end
end
# app/models/post.rb
Class Post
@SebastianEdwards
SebastianEdwards / gist:945263
Created April 27, 2011 21:30
Nicest way to get barista working on heroku
# Gemfile
gem "therubyracer-heroku"
# config/initializers/barista_config.rb
Barista.configure do |c|
c.root = Rails.root.join("app", "coffeescripts")
c.output_root = Rails.root.join("tmp", "javascripts")
end
require 'fileutils'
@vinioliveira
vinioliveira / Additional Commands
Created June 30, 2011 00:04
Init.d Juggernaut2 script for Ubuntu
$ sudo adduser --system --no-create-home --disabled-login --disabled-password --group juggernaut
$ sudo mv ~/juggernaut2-for-init.d-startup.sh /etc/init.d/juggernaut
$ sudo chmod +x /etc/init.d/juggernaut
$ sudo update-rc.d -f juggernaut defaults
@ajokela
ajokela / imgscalr.rb
Created October 7, 2011 19:40 — forked from mchung/imgscalr.rb
imgscalr in jruby
require "imgscalr-lib" # https://github.com/thebuzzmedia/imgscalr
require "jruby"
java_import "javax.imageio.ImageIO"
ImageIO.write(
com.thebuzzmedia.imgscalr.Scalr.resize(
ImageIO.read(java.io.File.new("iss.jpg")),
250),
"jpg",
java.io.File.new("iss_new.jpg"))
@ahoward
ahoward / presenter.rb
Created February 22, 2012 23:09
worlds simplest presenter pattern. drop in replacement for ActiveRecord/Mongoid models in your controller
# the worlds lightest weight presenter pattern. to use simply
#
# file app/presenters/post_presenter.rb
#
# PostPresenter =
# Presenter.for(Post) do
# validates_presence_of :custom_field_for_this_form
#
# end
#
@hmcfletch
hmcfletch / AFRailsHTTPClient.h
Created May 1, 2012 18:42
AFRailsHTTPClient
//
// AFRailsHTTPClient.h
// TopHatter
//
// Created by Leslie Fletcher on 1/30/12.
// Copyright (c) 2012 Blippy. All rights reserved.
//
#import "AFHTTPClient.h"
@danielwaterworth
danielwaterworth / article.md
Created August 9, 2012 07:48
How much of your codebase is only understood by one person?

How much of your codebase is only understood by one person?

Have you seen this question before? If you're a programmer then you're likely to have. It's a question that is strongly related the concept of a bus factor; the minimum number of people that understand any part of a system. This question annoys me though, because by asking it you are assuming that the system in question is so complicated and ill documented that at least parts of it can only be understood by the people that created it or those who that knowledge was shared with.

Why is this the norm? Why is it that we accept complexity? Edsger Dijkstra famously said "Simplicity is prerequisite for reliability" and I don't anyone who would disagree. When we accept complexity by not striving for simplicity, we accept unreliability and bugs.

@mieitza
mieitza / deploy_spark.sh
Last active October 9, 2015 23:38
Deploy spark
#!/bin/sh
# installation of Oracle Java JDK.
sudo apt-get -y update
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get -y update
sudo apt-get -y install oracle-java7-installer
# Installation of commonly used python scipy tools