Skip to content

Instantly share code, notes, and snippets.

@juster
juster / testvers.pl
Created February 9, 2011 19:29
Plays with version comparisons of perl's version module and pacman and also tests out normalizations.
#!/usr/bin/env perl
use warnings;
use strict;
use 5.010;
my @CMPMODS = ( 'CPAN::Version' => 'CPN' => sub {
return CPAN::Version->vcmp( @_ );
},
'version' => 'VRM' => sub {
#!/bin/sh
# STDIN - list of newline separated file names
print_dup_files() {
# First find files with exact same file sizes
xargs stat -c '%s %n' | sort -k 1 |
# Swap fields because uniq can only skip fields.
# (uniq -D prints all duplicates)
awk '{ print $2, $1 }' | uniq -f 1 -D |
# Cut out the file size, we are done with it.
diff --git a/clydelib/sync.lua b/clydelib/sync.lua
index 6c23d7c..97adf1f 100644
--- a/clydelib/sync.lua
+++ b/clydelib/sync.lua
@@ -1060,31 +1060,27 @@ local function aur_install(targets)
getalldeps(targets, needs, needsdeps, caninstall, provided)
for i, pkg in ipairs(aurpkgs) do
- if (tblisin(caninstall, pkg) and not tblisin(installedtbl, pkg)) then
- if (tblisin(targets, pkg) and not tflags["alldeps"])
@juster
juster / gist:856124
Created March 5, 2011 04:42
adjuster.pl
#!/usr/bin/env perl
use warnings;
use strict;
my $adjustme = do { local $/; <DATA> }; # slurp!
$adjustme =~ s{
(?&AdBlock)
@juster
juster / aurperlxs.sh
Created June 1, 2011 18:48
Find perl XS modules that need upgrading when new perl 5.14 comes out.
#!/bin/sh
pacman -Qim | perl -lnaF/\\s+:\\s+/ -e 'chomp;
$PKG = ( $F[1] =~ /^perl-/ ? $F[1] : undef ) if $F[0] eq q{Name};
print $PKG if $PKG && $F[0] =~ /^Arch/ && $F[1] ne q{any};
'
#!/usr/bin/perl
use warnings;
use strict;
my $WORDCOUNT = 5;
my $LANGCOUNT = 50;
my @FEATS = ('a'..'d');
# create a random comma separated string of features
@juster
juster / marquee.c
Created August 1, 2011 20:40
while sleep 1 ; do echo -e "Hello\nWorld\n" | ./marquee 5 ; done
#include <string.h>
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
#include <time.h>
#define DEFAULT_WIDTH 20
#define BUFFER_SIZE 128
int
@juster
juster / contrived.io
Created April 15, 2012 20:54
Contrived example of my problem dynamically creating methods
words := list("foo", "bar")
Foo := Object clone do(
words foreach(w setSlot(w, method(w println)))
)
obj := Foo clone
obj foo
obj bar
@juster
juster / vce.tcl
Created July 31, 2012 14:31
VCE Exam Taker
package require Tk
proc initTop {} {
menu .topMenu
menu .topMenu.fileMenu -tearoff 0
.topMenu.fileMenu add command -label Open... -command selectVCEPath
.topMenu add cascade -label File -menu .topMenu.fileMenu
. configure -menu .topMenu
@juster
juster / provides.rkt
Created June 10, 2014 14:40
Scheme code to generate a "provide" list for ArchLinux's perl package.
#lang racket
;; Generate a provides list for the ArchLinux perl package. Scan the appropriate directories
;; under the perl source tree for directories containing distributions, suitable for CPAN.
;; Search the files in the distributions for VERSION strings, which are perl expressions.
;; Filters these version strings through the perl interpreter, then transform the dist.
;; names and versions into package names and versions. This last step is much easier now.
;; The perl source tree has been greatly organized since even 5.18.
(define perl-src-dir "/Users/juster/src/perl-5.20.0")