Skip to content

Instantly share code, notes, and snippets.

int location_wait_time = getApplicationContext().getResources()
.getInteger(R.integer.location_poll_minutes);
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Intent intent = new Intent(this, LocationReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),
0, intent, 0);
//Register for broadcast intents
package com.midwestfleet.receivers;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
int[] location = new int[2];
this.anchor.getLocationOnScreen(location);
Rect anchorRect =
new Rect(location[0], location[1], location[0] + this.anchor.getWidth(), location[1]
+ this.anchor.getHeight());
this.anchorRectangle = anchorRect;
this.root.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
# Import the settings dev file if we are developing
if os.environ.get('DEVELOPMENT', None):
from login.settings_dev import *
@jmif
jmif / create_client.rb
Created April 22, 2012 18:32
Rails Two Legged OAuth DB Migration
class Client < ActiveRecord::Migration
def change
create_table :client do |t|
t.string :api_key
t.string :secret
t.timestamps
end
end
end
@jmif
jmif / application_controller.rb
Created April 22, 2012 18:33
Rails Two Legged OAuth before_filter
require 'rack'
require 'rack/request'
require 'oauth'
class ApplicationController < ActionController::Base
before_filter :run_oauth_check
# ...
protected
def run_oauth_check
@jmif
jmif / navbar.html
Created April 22, 2012 18:46
Twitter Bootstrap Navbar HTMl
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container"><!-- Collapsable nav bar -->
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<!-- Your site name for the upper left corner of the site -->
@jmif
jmif / login_form.html
Created April 22, 2012 18:47
Twitter Bootstrap Navbar Login Form HTML
<form action="[YOUR ACTION]" method="post" accept-charset="UTF-8">
<input id="user_username" style="margin-bottom: 15px;" type="text" name="user[username]" size="30" />
<input id="user_password" style="margin-bottom: 15px;" type="password" name="user[password]" size="30" />
<input id="user_remember_me" style="float: left; margin-right: 10px;" type="checkbox" name="user[remember_me]" value="1" />
<label class="string optional" for="user_remember_me"> Remember me</label>
<input class="btn btn-primary" style="clear: left; width: 100%; height: 32px; font-size: 13px;" type="submit" name="commit" value="Sign In" />
</form>
@jmif
jmif / login_form.js
Created April 22, 2012 18:47
Twitter Bootstrap Login Form JavaScript
$(function() {
// Setup drop down menu
$('.dropdown-toggle').dropdown();
// Fix input element click problem
$('.dropdown input, .dropdown label').click(function(e) {
e.stopPropagation();
});
});
@jmif
jmif / gist:4615274
Last active December 11, 2015 14:38
Resque::Job.create('jobs', QuickJob)
Resque::Job.create('jobs', QuickJob)
w1 = Resque::Worker.new('*')
w2 = Resque::Worker.new('*')
w1.work(0) do.
w2.work(0) do.
4.should == 3
end
end