Skip to content

Instantly share code, notes, and snippets.

@MaxDavila
MaxDavila / Api.java
Created July 5, 2018 22:52 — forked from imminent/Api.java
Call retrying with Retrofit 2.0
package com.example.api;
import java.util.Map;
import retrofit.Call;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
public interface Api {
@MaxDavila
MaxDavila / gist:11c2a71f8c1ff1c0417acf237d2dda3f
Last active August 31, 2016 00:57
Calling external service from qa and sbx
public TimedHttpResponse send(final HttpRequestBase request, Header ... additionalHeaders) throws TimedHttpCommunicationException {
String uriString = request.getURI().toString();
//set additional headers if any
request.setHeader("Accept", "application/json");
//let's run the actual http execution in another thread then wait for it
Future<HttpResponse> task = timeoutService.submit(new Callable<HttpResponse>() {
@Override
public HttpResponse call() throws Exception {
HttpResponse response = execute(request);
@MaxDavila
MaxDavila / evenDelegate.js
Created October 31, 2014 23:09
even delegate example
$(document).on('click', '#sidebar a', function(e) {
var fragment = $(this).data('fragment');
sscrollTo(fragment, e);
});
@MaxDavila
MaxDavila / mqScroll.js
Last active August 29, 2015 14:08
mqScroll.js
function mqScroll(element, target, event, callback) {
$(element).scrollTop(target)
preventDefault(event);
return callback()
}
//usage
mqScroll(scrollWith, targetY, event, function() {
setTimeout(function() {
@MaxDavila
MaxDavila / questions.rb
Last active August 29, 2015 14:05
Interview questions ruby/rails
# Open ended
# - What's your style of working. Pair programming vs solo
# - What's your favortite pattern. Do you use any?
# - If you accidentally pushed your branch to origin master, how would you restore
# to a clean master?
# - What have you been working on Sinatra and Node? Coffescript? APIs? how was it
# architectured
# Loading only one columsn and handling sum back in SQL
# rails/activerecord.
class Washer
attr_reader :name, :status
@@num_washers = 0
@@num_washers_washing = 0
@@num_washers_rinsing = 0
def initialize(args = nil)
@@num_washers += 1
@name = args[:name]
end