Skip to content

Instantly share code, notes, and snippets.

@mrmans0n
mrmans0n / MyLocation.java
Created November 15, 2011 11:22
Clase para obtener el Best Effort Location
package mipackage;
import java.util.Timer;
import java.util.TimerTask;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
@mrmans0n
mrmans0n / gist:1388559
Created November 23, 2011 12:31
HTTPClient SSL
// c—digo para aceptar los certificados ssl
public class MySSLSocketFactory extends SSLSocketFactory {
SSLContext sslContext = SSLContext.getInstance("TLS");
public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
super(truststore);
TrustManager tm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
@mrmans0n
mrmans0n / blog.html.erb
Created April 22, 2012 17:56
View for redirecting feeds
<%= raw @content %>
@mrmans0n
mrmans0n / derp_controller.rb
Created April 22, 2012 17:55
Controller that redirects a blog feed
require 'open-uri'
class DerpController < ApplicationController
layout nil
def blog
source = "http://www.perry.es/feed/" # url (or local file) with the feed we want to show
tmp = "" # load here rss data
open(source) do |s| tmp = s.read end
@content = tmp
@mrmans0n
mrmans0n / JQFEED.js
Created April 22, 2012 17:45
Simple RSS reader in jQuery
JQFEED = {
numNews: 5,
appendTo: '#blogfeed',
realUrl: 'http://www.perry.es',
internalUrl: '/blog_feed',
loadFeeds: function() {
$(JQFEED.appendTo).html('Loading feed...');
$.ajax({
url: JQFEED.internalUrl,
type: 'GET',
@mrmans0n
mrmans0n / git_info.rb
Created April 25, 2012 18:51
Obtain some cool information about git from a Rails application
GIT_BRANCH = `git status | sed -n 1p`.split(" ").last
GIT_COMMIT = `git log | sed -n 1p`.split(" ").last
GIT_REVISION = `git log --pretty=format:'%h' -n 1`
GIT_LASTUPDATE = `git log -1 | sed -n 3p`.split(" ").slice(1,5).join(" ")
@mrmans0n
mrmans0n / any_layout.xml
Created June 13, 2012 13:51
AspectFill iOS replacement kinda for Android
<ImageView android:id="@+id/theImage
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="5dp"
android:scaleType="centerCrop"
android:cropToPadding="true" />
@mrmans0n
mrmans0n / croppadinghack.java
Created June 13, 2012 14:01
Hacky way to set up cropPadding in Android's ImageView
try {
Field field = ImageView.class.getDeclaredField("mCropToPadding");
field.setAccessible(true);
field.set(imageView, true);
} catch (Exception e) {
e.printStackTrace();
}
@mrmans0n
mrmans0n / application.rb
Created July 31, 2012 12:24
My ActionMailer configuration
# ActionMailer data
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mydomain.com",
:user_name => "my.sender.address@gmail.com",
:password => "my_google_autogenerated_password",
:authentication => "plain",
:enable_starttls_auto => true
@mrmans0n
mrmans0n / EGOv2_Inconsolata.dvtcolortheme
Created August 22, 2012 16:08
EGOv2 modded with Inconsolata
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.7653 0.699234 0.758969 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Inconsolata - 13.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.6431 0.5881 0.637824 1</string>