Skip to content

Instantly share code, notes, and snippets.

View Joe8Bit's full-sized avatar
👋
@banked is hiring! Reach out!

Joe Pettersson Joe8Bit

👋
@banked is hiring! Reach out!
View GitHub Profile
var doQuery = function() {
count.exec(function(err, total) {
if (err) return sendError('database error', err);
query.exec(function(err, items) {
if (err) return sendError('database error', err);
sendResponse({
...
// the init function takes care of initialisation traditionally done
// in a constructor
init: function(options) {
this.valueSetOnInit = options.valueSetOnInit;
},
publicFunction: function() {
...
device = function(){
var flags = {}, ua = navigator.userAgent, el = document.createElement('div'), root = document.documentElement, i
function flag(names) {
root.className += (root.className ? ' ' : '') + names
names = names.split(' ')
for (i = 0; i < names.length; i++) flags[names[i]] = true
}
if (ua.indexOf('WebKit/') > -1) flag('webkit')
if (ua.indexOf('MSIE ') > -1) flag('msie')
if (ua.indexOf('Firefox') > -1) flag('firefox')
<!DOCTYPE html>
<html>
<head>
<title>jQuery Autocomplete</title>
<style>
#res {
margin: 0px;
padding-left: 0px;
width: 150px;
}
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@Joe8Bit
Joe8Bit / jasmine_json_fixtures.js
Created November 22, 2012 09:05 — forked from bunnymatic/jasmine_json_fixtures.js
Jasmine Load JSON fixtures
/**
add ability to load json fixtures into jasmine
**/
var readJsonFixtures = function() {
return jasmine.getJsonFixtures().proxyCallTo_('read', arguments);
};
var preloadJsonFixtures = function() {
jasmine.getJsonFixtures().proxyCallTo_('preload', arguments);
@Joe8Bit
Joe8Bit / Gemfile
Created September 13, 2012 21:44
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@Joe8Bit
Joe8Bit / async_loader.js
Created July 16, 2012 20:32 — forked from noonien/async_loader.js
Asynchronous Javascript/CSS loader.
AL = function(type, url, callback) {
var el, doc = document;
switch(type) {
case 'js':
el = doc.createElement('script');
el.src = url;
el.type = 'text/javascript';
el.async = true;
break;
@Joe8Bit
Joe8Bit / rails_cloc.sh
Created July 13, 2012 15:31 — forked from nlively/rails_cloc.sh
Count lines of code in a rails project
#!/bin/bash
find . \( -iname '*.rb' -o -iname '*.css' -o -iname '*.js' -o -iname '*.erb' -o -iname '*.html' -o -iname '*.scss' \) -exec wc -l {} + | sort -n
@Joe8Bit
Joe8Bit / Better version
Created June 10, 2012 13:20 — forked from gabehollombe/Better version
Capybara: a better way to check if text is visible
#A better 'I should not see' for Capybara that lets jQuery determine visibility of the text you're looking for.
Then /^"([^\"]*)" should not be visible$/ do |text|
finder_script = %{
function is_text_visible_on_page(text) {
var match = false;
$('*:visible')
.contents()
.filter(function() {
//collect text nodes