Skip to content

Instantly share code, notes, and snippets.

View nebiros's full-sized avatar

Juan Alvarez nebiros

View GitHub Profile
@delebedev
delebedev / opena.sh
Created March 19, 2014 13:58
Opens Xcode workspace or project with AppCode.
opena(){
if test -n "$(find . -maxdepth 1 -name '*.xcworkspace' -print -quit)"
then
echo "Opening workspace"
open *.xcworkspace -a /Applications/AppCode.app
return
else
if test -n "$(find . -maxdepth 1 -name '*.xcodeproj' -print -quit)"
then
echo "Opening project"
package lib
import (
"bytes"
"io"
"strings"
"errors"
"syscall"
"unicode/utf8"
)
@nebiros
nebiros / App_Thumb.php
Created February 23, 2010 15:06
Thumbnails lib
<?php
class App_Thumb
{
protected $_width = null;
protected $_oldWidth = null;
protected $_height = null;
protected $_oldHeight = null;
protected $_imagePath = null;
protected $_resource = null;
@moltak
moltak / retrofit builder and request
Created September 19, 2014 05:35
retrofit builder and request
/**
* Retrofit adapter builder
* Created by moltak on 2014. 7. 9..
*/
public class LMNetworkBuilder {
public static RestAdapter getAdapter() {
return getBuilder().build();
}
public static RestAdapter.Builder getBuilder() {
@patrickhammond
patrickhammond / MockWebServerIssueTest.java
Last active September 14, 2015 22:35
Weird OkHttp API behavior where a thrown IOException (SocketTimeoutException) from onResponse does not propagate to onFailure. Discussion here: https://github.com/square/okhttp/issues/1066
package com.demo.okhttpissue;
import android.test.InstrumentationTestCase;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
// Real usage
WhiTemplater.Formatter FEATURED_FORMAT = new WhiTemplater.Formatter() {
@Override
public String format(Object value) {
return "<b>" + String.valueOf(value)+ "</b>";
}
};
WhiTemplater.Formatter NORMAL_FORMAT = new WhiTemplater.Formatter() {
@nebiros
nebiros / Cache.php
Created September 23, 2010 16:20
App_Cache
<?php
/**
* Based on FileCache class by Erik Giberti,
* http://af-design.com/blog/2010/07/30/simple-file-based-caching-in-php/
*
* @author nebiros
*/
class App_Cache {
/**
@nebiros
nebiros / Mysql.php
Created October 3, 2010 04:10
Mysql ala OOP, wrapper for some mysql_* functions
<?php
/**
* Mysql wrapper, to handle some mysql_* functions in a OOP way.
*
*/
class App_Db_Mysql {
const DEFAULT_ROW_COUNT = 10;
const DEFAULT_PAGE = 1;
@brianleroux
brianleroux / lawnchair-examples.js
Created January 27, 2011 06:32
examples for using lawnchair js
// create a new store
var store = new Lawnchair({adaptor:'dom', table:'people'});
// saving documents
store.save({name:'brian'});
// optionally pass a key
store.save({key:'config', settings:{color:'blue'}});
// updating a document in place is the same syntax
@guilleiguaran
guilleiguaran / Fibonacci.java
Created July 19, 2011 04:37
Languages benchmarks
public class Fibonacci {
public static int fib(int n) {
if(n == 0 || n == 1) {
return n;
} else {
return fib(n-1) + fib(n-2);
}
}