Skip to content

Commit

Permalink
added code for blog posts back to September
Browse files Browse the repository at this point in the history
  • Loading branch information
jimschubert committed Apr 24, 2012
1 parent f3c789a commit eb528e8
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 2011-09-28/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
JS = $(shell find public/javascripts -type f \( -iname "*.js" ! -name "*.min.js" \) )
MINIFY = $(JS:.js=.min.js)

all: clean $(MINIFY)

clean:
rm -f $(MINIFY)

%.min.js: %.js
node ./node_modules/uglify-js/bin/uglifyjs -o $@ $<

.PHONY: clean js minify
5 changes: 5 additions & 0 deletions 2011-09-28/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**This is not a fully-functional application**

From this [blog post](http://www.ipreferjim.com/2011/09/makefile-setup-for-minifying-js-files-in-an-expressjs-application/)

This shows how to add uglify-js as a dependency to package.json for an expressjs application and the accompanying Makefile to minify scripts.
11 changes: 11 additions & 0 deletions 2011-09-28/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// default package.js for an expressjs app using ejs and uglify-js
{
"name": "application-name"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"express": "2.4.6"
, "ejs": ">=0.4.3"
, "uglify-js": ">=1.1.0"
}
}
5 changes: 5 additions & 0 deletions 2011-10-31/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
From [this blog post](http://www.ipreferjim.com/2011/10/jquery-plugin-fixed-table-header/)

# demo

See the jsfiddle [here](http://jsfiddle.net/jimschubert/RMsqJ/) for a demo
87 changes: 87 additions & 0 deletions 2011-10-31/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script>

<script type="text/javascript">
(function($) {
$.fn.fixedHeader = function(options) {
var settings = {
selector: 'thead:first',
cssClass: 'fixed',
fixTo: 0
};

var _fixHeader = function(obj) {
var header = $(obj.selector, obj.elem);
if(header) {
var parent = header.parents('table:first') || header.parent();
(parent && parent.css({ borderCollapse: 'collapse'}) );

var data = header.data('fixedHeader') || header.data('fixedHeader', {
top: header.offset().top,
width: parent.find('tr:eq(1)').width(),
cells: parent.find('tr:eq(1) > td'),
processed: false
});
var top = data.top - $(document).scrollTop();
if( top < 0 ) {
header.addClass(obj.css);
if(!data.processed){
header.width(data.width);
for(var i = 0; i<data.cells.length;i++) {
$('th:eq('+i+')', header).width($(data.cells[i]).width());
}
}

} else {
header.removeClass(obj.css);
}
}
};
return this.each(function() {
var self = this;
if("object" === typeof options) {
$.extend(settings, options);
}
if($(self).parents('table:first')){
$(window).bind('scroll.fixedHeader', function() {
_fixHeader({
elem: self,
selector: settings.selector,
css: settings.cssClass,
top: settings.fixTo
});
});
}
});
};
})(jQuery);

$(function() {
var table = $('#example');
for(var i = 1; i < 50; i++) {
var row = $('<tr><td>first_'+i+'</td><td>second_'+i+'</td><td>third_'+i+'</td><td>fourth_'+i+'</td></tr>');
$('tbody', table).append(row);
}
$('thead:not(thead:eq(0))').remove();
table.fixedHeader();
});
</script>

<style type="text/css">
.fixed { position:fixed; background:white; border-bottom:1px dotted black;}
</style>

<table id="example">
<thead>
<tr>
<th>First</th>
<th>Second</th>
<th>Third</th>
<th>Fourth</th>
</tr>
<thead>
<tbody></tbody>
</table>

<div id="scrollTop">

</div>
53 changes: 53 additions & 0 deletions 2011-10-31/jquery.fixedheader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
(function($) {
$.fn.fixedHeader = function(options) {
var settings = {
selector: 'thead:first',
cssClass: 'fixed',
fixTo: 0
};

var _fixHeader = function(obj) {
var header = $(obj.selector, obj.elem);
if(header) {
var parent = header.parents('table:first') || header.parent();
(parent && parent.css({ borderCollapse: 'collapse'}) );

var data = header.data('fixedHeader') || header.data('fixedHeader', {
top: header.offset().top,
width: parent.find('tr:eq(1)').width(),
cells: parent.find('tr:eq(1) > td'),
processed: false
});
var top = data.top - $(document).scrollTop();
if( top < 0 ) {
header.addClass(obj.css);
if(!data.processed){
header.width(data.width);
for(var i = 0; i<data.cells.length;i++) {
$('th:eq('+i+')', header).width($(data.cells[i]).width());
}
}

} else {
header.removeClass(obj.css);
}
}
};
return this.each(function() {
var self = this;
if("object" === typeof options) {
$.extend(settings, options);
}
if($(self).parents('table:first')){
$(window).bind('scroll.fixedHeader', function() {
_fixHeader({
elem: self,
selector: settings.selector,
css: settings.cssClass,
top: settings.fixTo
});
});
}
});
};
})(jQuery);
27 changes: 27 additions & 0 deletions 2012-02-03/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Accompanies my [blog post](http://www.ipreferjim.com/2012/02/words-pl-slogan-word-generator/).

To run:

perl words.pl /usr/share/dict/words generated.txt 'Good goly, Miss Molly'

Output will resemble:

jim at schubert in ~/projects/gist-1733871 on master*
$ tree .
.
├── generated.txt
├── generated.txt.1
├── generated.txt.2
├── generated.txt.3
├── generated.txt.4
├── generated.txt.5
├── generated.txt.6
├── generated.txt.7
├── generated.txt.8
└── words.pl
0 directories, 10 files

Where generated.txt.3 *should* contain all 3-letter words. If the input file has `\r\n` instead of `\n`, the counts might be off by one.


46 changes: 46 additions & 0 deletions 2012-02-03/words.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env perl
# words.pl: Find all possible slogan words from a single sentence.
use strict; $|++;

@ARGV >= 2 or die "usage: $0 input_file output_file 'sentence'\n";
my ($infile, $outfile, $sentence) = @ARGV;
$sentence = $sentence || 'how much wood could a woodchuck chuck';

open INPUT, "< $infile" or die $!;
open OUTPUT, "> $outfile" or die $!;

my $stdout = select STDOUT;
$| = 1;
select $stdout;

my %sentence_letters;
my $stmp = $sentence;
$sentence_letters{$&}++ while($stmp =~ s/[a-z]//);

print "Using the sentence '$sentence'\n";
print "Found the following letters:\n";
print "\t$_ - ". $sentence_letters{$_} ."\n" foreach(sort(keys %sentence_letters));
print "Processing $infile for slogan words\n";

my $count = 0;
my @indicators = qw{\ / | .};
LINE: while(<INPUT>) {
my $word = $_;
my $tmp = $word;
next LINE if($word =~ /['\&\d]/);
my %word_letters;
$word_letters{$&}++ while($tmp =~ s/[a-z]//);

foreach(keys %word_letters) {
next LINE if ($word_letters{$_} > $sentence_letters{$_});
}
print OUTPUT $word;

my $word_len = length($word);
open WORD_LEN_OUTPUT, ">> $outfile.$word_len";
print WORD_LEN_OUTPUT $word;

print $indicators[++$count % 4], "\r";
}

print "\nDone.\nView $outfile.* for words\n";
3 changes: 3 additions & 0 deletions 2012-03-23/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[blog post](http://www.ipreferjim.com/2012/03/ubuntu-open-with-wireshark/)

Save as ~/.local/share/applications/wireshark.desktop
13 changes: 13 additions & 0 deletions 2012-03-23/wireshark.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Desktop Entry]
Encoding=UTF-8
Name=Wireshark
Comment=Wireshark packet capturing
Exec=wireshark %u
Terminal=false
Type=Application
Icon=/usr/share/pixmaps/hi48-app-wireshark.png
Categories=Application;Utility;
StartupNotify=true
MimeType=application/octet-stream
NoDisplay=false

12 changes: 12 additions & 0 deletions 2012-04-16/Microsoft.Cpp.Win32.user.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
</Project>

0 comments on commit eb528e8

Please sign in to comment.