Skip to content

Instantly share code, notes, and snippets.

View gpbmike's full-sized avatar
👋

Mike Horn gpbmike

👋
View GitHub Profile
var arr = [1,3,2,4];
console.log(arr);
var sorted_arr = arr.sort();
console.log(sorted_arr);
console.log(arr);
// prints what i don't want
// [1,3,2,4]
// [1,2,3,4]
// [1,2,3,4]
// preventing click behavior when sorting links using jquery-ui's (1.6b) sortable widget
'stop': function(e,ui) {
ui.item.find('a').click(function(e){
e.preventDefault();
});
setTimeout(function(){
ui.item.find('a').unbind('click');
},10);
addFeatured();
},
// event handler for queuing a file
'fileQueued': function(file) {
// check if you queued a video
// get upload url
if (file.name.toLowerCase().match("(mov|avi|wmv|3gp|mkv|mpg|mpeg|mp4|m4v)$")) {
var input = {'get_fields[]': ['url','key'],'file': file.name };
$.getJSON('/media/get_video_upload_url',input,function(output){WU.sv_urls[file.id] = output;});
}
// switch to upoad view
<style type="text/css">
.wrap { position: relative; }
.centered { position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; margin-left: -10px; margin-top: -10px; }
</style>
<div class="wrap"><div class="centered">I'm centered</div></div>
$button_color: orange !default
=button($color: $button_color, $size: large)
display: inline-block
outline: none
cursor: pointer
text-align: center
text-decoration: none
line-height: 137%
font-weight: bold
@gpbmike
gpbmike / gist:722738
Created December 1, 2010 00:53 — forked from snide/gist:722735
<a href="#js_table_1" class="toggle-table">table 1</a>
$('.toggle-table').click(function(e) {
e.preventDefault();
var table = $($(this).attr('href'));
if (table.is(':visible')) {
table.fadeOut('slow')
} else {
table.fadeIn('slow')
}
@gpbmike
gpbmike / Streamer.php
Created July 6, 2011 21:08
php backend for streaming file upload with XMLHttpRequest
<?php
class File_Streamer
{
private $_fileName;
private $_contentLength;
private $_destination;
public function __construct()
{
if (!isset($_SERVER['HTTP_X_FILE_NAME'])
// INPUT
(function() {
function this_is_my_great_function(msg) {
alert(msg);
}
this_is_my_great_function('yay');
});
// YUI COMPRESSED OUTPUT
(function(){function a(b){alert(b)}a("yay")});
dl
dt
something
dd
something else
@gpbmike
gpbmike / yui_compressor.py
Created July 18, 2011 15:51
sublime text 2 plugin to compress javascript
import os
import sublime, sublime_plugin
import urllib, urllib2
#view.run_command("compress")
class CompressCommand(sublime_plugin.TextCommand):
def run(self, edit):
folder_name, file_name = os.path.split(self.view.file_name())
sublime.status_message(("Compressing %s...") % file_name)