Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl
package No::Headers;
use Mojo::Base "Mojo::Headers";
sub to_string { "" };
package main;
use Mojolicious::Lite;
get "/" => sub {
my $c = shift;
$.fn.passThrough = function() {
this.hover(
function() { $(this).fadeTo('fast', 0.2); },
function() { $(this).fadeTo('fast', 1.0); }
);
this.each(function() {
var self = this;
var last;
$(self).bind('click mousemove mouseout', function (e) {
@jhthorsen
jhthorsen / add-style-attr.js
Last active December 15, 2015 21:29
How to add inline styling (<tag style="...">) from calculated styles.
/*
add inline styling (<tag style="...">) from calculated css.
1. Paste the code below into the javascript console
2. Go back to the "Elements" view, where all the selected element and all sub elements has inline styling
*/
// add to whole document
$('body, body *').each(function(){var $e=$(this);$e.attr('style',$.map(["opacity","filter","azimuth","background","background-attachment","background-color","background-image","background-position","background-repeat","border","border-collapse","border-color","border-spacing","border-style","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width","border-width","bottom","caption-side","clear","clip","color","content","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","elevati
@jhthorsen
jhthorsen / jquery.disableouterscroll.js
Created November 22, 2012 23:55
disable outer scroll
(function($) {
$.fn.disableOuterScroll = function() {
return this.bind('mousewheel DOMMouseScroll', function(e) {
var scrollTo = null;
if(e.type == 'mousewheel') {
scrollTo = (e.originalEvent.wheelDelta * -1);
}
else if(e.type == 'DOMMouseScroll') {
scrollTo = 40 * e.originalEvent.detail;
@jhthorsen
jhthorsen / queue.js
Created November 22, 2012 10:52
Queue callbacks in javascript
/*
* queue.js allow you to run async callbacks in serial.
*/
var Queue = {
callbacks: [],
idle: true,
// Queue.add(function() {});
// Used to add a new function to the callback queue
@jhthorsen
jhthorsen / jquery.fixedheader.js
Created November 2, 2012 23:24
Fixed table header
(function($) {
$.fn.fixedHeader = function() {
this.each(function() {
var $table = $(this);
var $dummy = $('<table><tr></tr></table>');
var $th = $table.find('thead:first tr:first th').clone();
var $td = $table.find('tbody:first tr:first td');
var place = function() {
$dummy.css({
@jhthorsen
jhthorsen / whiteboard.pl
Created October 27, 2012 14:08
digital whiteboard websocket demo
#!/usr/bin/env perl
use Mojolicious::Lite;
my $connections = {};
my $drawings = {};
# demo here: http://whiteboard-jhthorsen.dotcloud.com/
get '/' => sub {
my $self = shift;
@jhthorsen
jhthorsen / corelist.pl
Created October 15, 2012 15:36
perl corelist
#!perl
qw/
abs accept alarm atan2 bind binmode bless break caller chdir
chmod chomp chop chown chr chroot close closedir connect
continue cos crypt dbmclose dbmopen default defined delete die
do dump each endgrent endhostent endnetent endprotoent endpwent
endservent eof eval exec exists exit exp fcntl fileno flock fork
format formline getc getgrent getgrgid getgrnam gethostbyaddr
gethostbyname gethostent getlogin getnetbyaddr getnetbyname
getnetent getpeername getpgrp getppid getpriority getprotobyname
@jhthorsen
jhthorsen / glob.pl
Created August 28, 2012 13:22
Perl globs
package Foo {
our $bar = 123;
sub bar { 'hello' }
warn join ', ', keys %{ "Foo::" }; # bar
my $gv = ${ "Foo::" }{bar};
my $scalar = *$gv{SCALAR};
my $code = *$gv{CODE};
@jhthorsen
jhthorsen / shotwell-mounter.desktop
Created July 31, 2012 12:05
Mount Nokia C5-00 and load shotwell
[Desktop Entry]
Version=1.0
Name=DC50 Nokia import
GenericName=Photo Manager for Nokia DC50
Comment=Import your photos from Nokia DC50
Exec=/usr/local/bin/shotwell-mounter %U
Icon=shotwell
Terminal=false
Type=Application
MimeType=x-content/image-dcf;