Skip to content

Instantly share code, notes, and snippets.

@jbottigliero
jbottigliero / gist:5008262
Created February 21, 2013 21:07
iterator_map_to_array PHP funciton
function iterator_map_to_array(\Iterator $iterator, $callback, $use_keys = true){
foreach($iterator as $i){
$i = $callback($i);
}
return iterator_to_array($iterator, $use_keys);
}
return iterator_map($cursor, function($i){
return new MyObject($i);
}, false);
@jbottigliero
jbottigliero / gist:5066194
Last active December 14, 2015 09:39
mongodb - random document(s)
// mongodb collection generator for getting random documents...
// set to the collection you wish to add a random attribute to.
var collection = 'myCollection',
// the name of the random collection to be generated; what you'll run queries against
// to obtain a random document
randCollection = 'rand' + collection.charAt(0).toUppderCase(),
// wheter or not the random collection should contain full documents, or a truncated
// version of the document (the mongo $_id and random attribute only)
useTruncatedDoc = false;
@jbottigliero
jbottigliero / layers.html
Last active December 18, 2015 19:49
layers prototype of concept based on forcast.io ui
<html>
<head>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>layers</title>
<style>
@jbottigliero
jbottigliero / jquery.detect.js
Last active December 19, 2015 05:29
AMD wrapper of Zepto's 'detect' module for jQuery
(function (root, doc, factory) {
if (typeof define === 'function' && define.amd) {
define(['global/jquery'], function( $ ) {
factory( $, root, doc);
return $;
});
} else {
factory( root.jQuery, root, doc);
<html>
<head>
<style>
@-webkit-keyframes clockwise {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
@jbottigliero
jbottigliero / dabblet.css
Created July 11, 2013 16:32
Attempt for Chrome-style progress-indicator with SVG and CSS animations
/**
* Attempt for Chrome-style progress-indicator with SVG and CSS animations
*/
@keyframes spin {
to {
stroke-dashoffset: 360;
}
}
@jbottigliero
jbottigliero / select.jsx
Created December 16, 2013 04:29
React <select> Component (JSX)
/** @jsx React.DOM */
define(['reactjs'], function(React){
return React.createClass({
getDefaultProps: function(){
return {
multiple: false
/*
name: 'mySelect'
@jbottigliero
jbottigliero / repo-activity-stream.js
Last active August 29, 2015 14:01
bitbucket-fluid-fix
// Moves the BitBucket Activity Stream out of the ".sidebar"
(function(){
var o = document.getElementById('dashboard-overview') || document.getElementById('repo-overview') || document.getElementById('profile-tab-content');
if (!o) return;
a = o.querySelector('.sidebar'),
m = o.firstElementChild;
o.insertBefore(a, m);
a.classList.remove('sidebar');
if (o.id === 'profile-tab-content') {
@jbottigliero
jbottigliero / inspect.applescript
Last active August 29, 2015 14:01
inspect-ios-simulator
tell application "Safari"
activate
end tell
try
tell application "System Events" to tell process "Safari"
click menu item 2 of menu of menu item "iOS Simulator" of menu 1 of menu bar item "Develop" of menu bar 1
end tell
on error error_message
return error_message
@jbottigliero
jbottigliero / Backbone.Collection.sort.js
Last active August 29, 2015 14:04
An override for Backbone.Collection.sort to allow for simple reversing using a "reverse" boolean option.
define([
/* global Backbone */
'backbone'
], function(){
'use strict';
/**
* Override for Backbone.Collection.sort to allow for simple reversing using
* a 'reverse' boolean option.