Skip to content

Instantly share code, notes, and snippets.

@critzjm
critzjm / milestone-webview.js
Last active July 12, 2017 05:23
Hide website header, nav and footer when viewing it from an iOS app
document.addEventListener('DOMContentLoaded', function() {
var userAgent = window.navigator.userAgent.toLowerCase(),
safari = /safari/.test(userAgent),
ios = /iphone|ipod|ipad/.test(userAgent);
if(ios) {
if (!safari) {
// ios webview
document.getElementById("header").style.display = "none";
document.getElementById("nav-toggle").style.display = "none";
@critzjm
critzjm / non_imap_info.rb
Created November 5, 2012 16:03
nonImapInfo
"nonImapInfo" : {
"blackhole@fusi0n_org::imap_googlemail_com" : {
"Folder_Name" : {
"attributes" : {
"HasChildren" : false,
"HasNoChildren" : true,
"Noinferiors" : false,
"Marked" : false,
"Noselect" : false
"ServerId" : "asdf-1234",
class Question < ActiveRecord::Base
attr_accessible :crowd_id, :question_type, :body, :priority, :choices_attributes
belongs_to :crowd
has_many :choices
accepts_nested_attributes_for(
:choices,
:reject_if => lambda{ |c| c[:body].blank? }
# This model represents a User of the system. The main User functionality is declared
# using the `authable_user` command which is defined as a part of the Challah gem.
#
# Users can be registered with a username and password (admin only) or directly on the site
# from Facebook. If a user was registered with Facebook, they will have a `fb_identifier`
# and a `fb_access_token` value. If these values are present, the user will not be able to log
# in with a username/password combination.
#
# ## Columns
# * :first_name - First name
@critzjm
critzjm / redis_counter.rb
Created May 9, 2012 15:06
Redis Counters
module RedisCounter
# increment counters
def self.incr(name, uniq_key=nil)
time = Time.now
REDIS.multi do |r|
key_names.each do |key_name|
# count
incr_key = send("#{key_name}_key", name, time)
@critzjm
critzjm / mobile_redirect.html
Created January 6, 2011 16:21
Javascript that will detect a mobile browse and redirect to another page, unless a querystring parameter of full=true exists
Redirecting...
<script language="javascript">
<!--
if(!window.location.search.substring(1) == "full=true") { // do not redirect if querystring is ?full=true
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/Blackberry/i) || navigator.userAgent.match(/WebOs/i)) { // detect mobile browser
window.location.replace("http://url-of-your-mobile-page"); // redirect if mobile browser detected
}
}
-->
</script>