Skip to content

Instantly share code, notes, and snippets.

--- 03_http_requests-t.org Fri Feb 05 09:00:16 2010
+++ 03_http_requests.t Fri Feb 19 22:03:42 2010
@@ -31,7 +31,12 @@
foreach my $client (@clients) {
my $ua = LWP::UserAgent->new;
- $ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });
+ if ( $^O eq "MSWin32" ) {
+ $ua->cookie_jar({ file => "$ENV{TEMP}/.cookies.txt" });
+ }
--- 03_persistence-t.org Fri Feb 19 21:47:21 2010
+++ 03_persistence.t Fri Feb 19 21:50:49 2010
@@ -13,7 +13,12 @@
foreach my $client qw(one two three) {
my $ua = LWP::UserAgent->new;
- $ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });
+ if ( $^O eq "MSWin32" ) {
+ $ua->cookie_jar({ file => "$ENV{TEMP}/.cookies.txt" });
+ }
@jadeallenx
jadeallenx / unicode-test.pl
Created August 11, 2011 23:01
Perl unicode
#!/usr/bin/env perl
use warnings;
use strict;
use v5.14;
use utf8;
my $number = "௪";
my $letter = "த்";
@jadeallenx
jadeallenx / t.erl
Created February 10, 2012 22:56
Erlang parameter validation
% Post/Query string parameter validation.
%
% Mark Allen, mrallen1@yahoo.com
%
% Specs [{{name, "param_name"}, {required, true}, {type, function}}, ... ]
% Input [{"name", "value}, ...] just you'd get from post or query string parameters
-module(t).
-export([test/0, test1/0, test2/0]).
@jadeallenx
jadeallenx / README.md
Created March 7, 2012 16:53 — forked from nkabardin/README
Erlang xmerl-based simple xml parsing

Purpose

This module takes XML and turns it into a deep proplist. The original code was written by @wackum.

I modified it so it:

  • returns both attributes and the value instead of one or the other
  • doesn't ignore the top level tag
  • handles elements with empty content
@jadeallenx
jadeallenx / gist:3132261
Created July 17, 2012 21:34
learngo slices solutions (#60)
package main
import "tour/pic"
func Pic(dx, dy int) [][]uint8 {
outer := make([][]uint8, dy)
for i := 0; i < dy; i++ {
inner := make([]uint8, dx)
for j := 0; j < dx; j++ {
@jadeallenx
jadeallenx / gist:3132933
Created July 17, 2012 23:37
learngo image solution (#79)
package main
import (
"image"
"tour/pic"
"image/color"
)
type Image struct{
w int
@jadeallenx
jadeallenx / gist:3133785
Created July 18, 2012 02:47
learngo rot13 solution
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@jadeallenx
jadeallenx / myauth.pl
Created July 25, 2012 16:43
Simple persistent Dancer authorization service
use Dancer;
use Dancer::Plugin::Database;
# Using DBD::SQLite database with
# create table authorized_users (
# username text,
# password text
# );
#
# insert into authorized_users (username, password) VALUES ('fred', 'somehash');
@jadeallenx
jadeallenx / README.md
Created August 13, 2012 21:48
Text Summarizer

Prints this:

I want to make it clear that DRM is perfectly ok with Linux!

And since I can imaging signing binaries myself, I don't feel that I can disallow anybody else doing so.

The GPL requires you to give out sources to the kernel, but it doesn't limit what you can do with the kernel. Btw, one thing that is clearly not allowed by the GPL is hiding private keys in the binary. [ Personally, I see it as a virtue - trying to make the world a slightly better place without trying to impose your moral values on other people.