Skip to content

Instantly share code, notes, and snippets.

View jimjeffers's full-sized avatar

Jim Jeffers jimjeffers

View GitHub Profile
@jimjeffers
jimjeffers / article_touch_end.coffee
Created April 28, 2012 08:12
Touch Based Article Navigation Snippets
touchEnd: (event) ->
limit = window.innerWidth/3
if @slideTo > 0 and Math.abs(@slideTo) >= limit
@moveTo(window.innerWidth)
else if @slideTo < 0 and Math.abs(@slideTo) >= limit
@moveTo(-window.innerWidth)
else
@moveTo(0)
@jimjeffers
jimjeffers / article_constructor.coffee
Created April 29, 2012 02:17
Touch Based Article Navigation Snippets 2
constructor: (params={}) ->
# Store the href for reference. We'll need it for history.pushState.
@href = params["href"]
# Create a temp element to store and parse the response content.
tempElement = document.createElement("div")
tempElement.innerHTML = params['html']
# Grab and assign the article.
if params['element']?
@jimjeffers
jimjeffers / check_for_touch.coffee
Created April 30, 2012 16:10
specific_snippets
if Modernizr.touch and @article? and @touchTarget?
background-image: -webkit-radial-gradient(50% 50%, circle closest-side, #2249e1 0%, #1d1e5e 100%);
background-image: radial-gradient(50% 50%, circle closest-side, #2249e1 0%, #1d1e5e 100%);
@jimjeffers
jimjeffers / JugglingShelvesViewController.m
Created May 24, 2012 22:54
Figuring out how to juggle UIImageViews as a UIScrollview scrolls.
- (void)viewDidLoad
{
[super viewDidLoad];
// We'll want the controller to become the scrollView's delegate
// in order to respond to changes in the content offset position.
shelfScrollView.delegate = self;
// We'll generate an array of image views to serve as the shelf
// background. These shelves will reposition as they scroll out
// of the viewport.
@jimjeffers
jimjeffers / CAMMFileUpload.m
Created July 23, 2012 15:33
File upload process for CAMM resizing image, utilizing parse, and communicating to web view.
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
// Hide the image picker.
[picker dismissModalViewControllerAnimated:YES];
// Reference the image from the picker.
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
// Use the size of the image to calculate its aspect ratio.
float aspectRatio = image.size.width/image.size.height;
@jimjeffers
jimjeffers / touchEventDropDown.html
Created August 22, 2012 23:00
Basic drop down via touch events. Doesn't cover everything just a simple example.
<!DOCTYPE html>
<html>
<head>
<style type="text/css" media="screen">
.pressed {
background: #f00;
}
.js-dropDown {
display: none;
@jimjeffers
jimjeffers / carrier_wave_direct_form.html.erb
Created October 29, 2013 20:31
Form used to create a photo w/ Carrier Wave Direct.
<!-- Form Container Start -->
<div class="form-container">
<% if params[:key].nil? %>
<%= direct_upload_form_for @uploader, html: {:class => "form"} do |f| %>
<p class="field">
<label>Select a photo to upload:</label><br>
<%= f.file_field :image %>
</p>
<p class="field">
@jimjeffers
jimjeffers / staging.log
Created October 29, 2013 20:49
Staging log of carrier wave bug.
Started POST "/admin/photos/7/approve" for 199.223.122.34 at 2013-10-29 20:46:18 +0000
2013-10-29T20:46:18.589054+00:00 app[web.1]: Processing by Admin::PhotosController#approve as */*
2013-10-29T20:46:18.589054+00:00 app[web.1]: Parameters: {"id"=>"7"}
2013-10-29T20:46:18.598598+00:00 app[web.1]: Photo Load (4.2ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = $1 LIMIT 1 [["id", "7"]]
2013-10-29T20:46:18.603564+00:00 app[web.1]: (4.6ms) BEGIN
2013-10-29T20:46:18.610299+00:00 app[web.1]: Photo Load (3.8ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = $1 LIMIT 1 [["id", 7]]
2013-10-29T20:46:18.613560+00:00 app[web.1]: (2.3ms) UPDATE "photos" SET "approved" = 't', "image" = '0289da71-14cd-46c1-a42c-feff92ac0303/Screen%2520Shot%25202013%252010%252029%2520at%25201.44.20%2520PM.png', "updated_at" = '2013-10-29 20:46:18.610428' WHERE "photos"."id" = 7
@jimjeffers
jimjeffers / get_direction.js
Created November 20, 2013 20:15
Get direction from bearing.
//
// Get direction
//
this.getDirectionFromBearing = function(bearing) {
if (bearing > 330 || bearing <= 15) {
return "N";
} else if (bearing > 15 || bearing <= 60) {
return "NE";
} else if (bearing > 60 || bearing <= 105) {
return "E";