Skip to content

Instantly share code, notes, and snippets.

@jonathan-beebe
jonathan-beebe / Facebook Friend Request via js
Created December 9, 2010 22:53
Using the Facebook Javascript API you can execute a friend request
FB.ui(
{
method: 'friends.add',
id: fbid // assuming you set this variable previously...
},
function(param){
console.log(param);
@jonathan-beebe
jonathan-beebe / UIImage+UISegmentIconAndText.h
Created September 28, 2012 18:59
Create a UIImage from an icon file and string for use in a UISegmentControl - Allows for UISegment buttons with icons and text.
#import <UIKit/UIKit.h>
@interface UIImage (UISegmentIconAndText)
+ (id) imageFromImage:(UIImage*)image string:(NSString*)string color:(UIColor*)color;
@end
@jonathan-beebe
jonathan-beebe / index.html
Created December 14, 2012 15:55
Leaflet.js - Mark Radius
<!doctype html>
<html>
<head>
<title>Leaflet.js - Mark Radius</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.ie.css" /><![endif]-->
<link rel="stylesheet" href="styles.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
@jonathan-beebe
jonathan-beebe / NSString+isNumeric.h
Created February 15, 2013 19:09
Check if an NSString is numeric and/or contains only numeric characters. Inspired by StackOverflow http://stackoverflow.com/questions/6644004/how-to-check-if-nsstring-is-numeric
// Inspired by StackOverflow
// http://stackoverflow.com/questions/6644004/how-to-check-if-nsstring-is-numeric
#import <Foundation/Foundation.h>
@interface NSString (isNumeric)
- (BOOL) isAllDigits;
- (BOOL) isNumeric;
<!DOCTYPE html>
<html lang="html">
<head>
<style>
.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
@jonathan-beebe
jonathan-beebe / ruby-rails-erb-comments.erb
Created February 20, 2014 19:06
Comment lines in ruby rails html.erb files, as answered on StackOverflow http://stackoverflow.com/a/3901665/123781
To comment a single line use
<%-# commented line -%>
This also works
<%# my comment %>
To comment a whole block use a if false to surrond your code like this
@jonathan-beebe
jonathan-beebe / jquery-scrolllock.js
Last active August 29, 2015 13:56 — forked from theftprevention/jquery-scrolllock.js
A small jQuery extension that disables the propagation of scroll events from the first element in the set of matched elements. Original function by Troy Alford of Stack Overflow. $("#object").scrollLock() enables the lock, and .scrollRelease() disables it. In response to this SO question: http://stackoverflow.com/a/16324762/123781
$.fn.scrollLock = function () {
return $(this).on("DOMMouseScroll mousewheel", function (h) {
var g = $(this),
f = this.scrollTop,
d = this.scrollHeight,
b = g.height(),
i = h.originalEvent.wheelDelta,
a = i > 0,
c = function () {
h.stopPropagation();
@jonathan-beebe
jonathan-beebe / css-transitions.scss
Last active August 29, 2015 13:57
Using css transitions
// Transition Everything
transition: all 0.5s ease-in-out;
// becomes these discrete properties
transition-property: all;
transition-duration: 0.5s;
transition-timing-function: ease-in-out;
transition-delay: initial;
@jonathan-beebe
jonathan-beebe / assemble-io-looping.html
Last active August 29, 2015 13:57
Looping through data using Assemble.io + Handlebars
---
headings: [1, 2, 3, 4, 5, 6]
---
<div data-section="headings">
{{#each headings}}
{{#withHash num=this text="Heading"}}
<h{{num}}>{{text}} {{num}}</h{{num}}>
{{/withHash}}
{{/each}}
@jonathan-beebe
jonathan-beebe / assemble-io-parseJSON.html
Last active August 29, 2015 13:57
parseJSON & Assemble.io
{{#parseJSON '{"type":"text--primary", "text":"Text, Primary Button"}'}}
<button class="btn btn--{{type}}">{{text}}</button>
{{/parseJSON}}