Skip to content

Instantly share code, notes, and snippets.

Avatar
⚔️

fREW Schmidt frioux

⚔️
View GitHub Profile
View Ghetto.pm
module Ghetto;
sub run($cmd) {
# create a random filename to store output in
my $tmp = ".tmp-{(1..100).pick}-ghetto";
# use the real run command, :: means root namespace
::run("$cmd > '$tmp'");
# open the file
View fru2m3u.pl6
#!/home/frew/personal/rakudo/perl6
use Ghetto;
for =$*IN -> $track,$artist,$album,$sep {
my $cmd = qq{dcop amarok collection query "SELECT url FROM tags JOIN artist ON artist.id = artist JOIN album ON album.id = album WHERE artist.name = \\"$artist\\" and album.name = \\"$album\\" and title = \\"$track\\""};
# this insanity is to take the first character off because amaroK adds a
# . to the front of all the file names. There's probably a better way
# to do this.
say Ghetto::run($cmd).split("\n")[0].reverse.chop.reverse;
View m3u2fru.pl6
#!/home/frew/personal/rakudo/perl6
use Ghetto;
for =$*IN -> $line {
unless $line ~~ /^\#/ {
my $file = $line.split('/').pop;
my $cmd = qq{dcop amarok collection query "SELECT title,artist.name,album.name FROM tags JOIN artist ON artist.id = artist JOIN album ON album.id = album WHERE url LIKE \\"%/$file\\""};
my ( $track,$artist,$album ) = Ghetto::run($cmd).split("\n");
@frioux
frioux / gist:1172717
Created Aug 26, 2011
Why even being in #p5p is not worth my time
View gist:1172717
< frew> does anyone think that it would be worthwhile to implement a pure perl implementation of the various POSIX functions that are fallbacks?
< frew> it seems like it would mostly be SMOP and it would really help at least me :-)
< frew> (win32 boo)
<@LeoNerd> Which functions did you have in mind?
< frew> well I just ran into WEXITSTATUS
<@Steve_p> That was done, wasn't it?
< frew> and I had an issue with the date formatting a while ago
<@LeoNerd> strftime?
<+purl> hmmm... strftime is in POSIX.pm or possibly *very* useful for formatting dates or %Y%m%d is what you want
< frew> yessir
@frioux
frioux / gist:3220451
Created Jul 31, 2012
<3 correlated subqueries
View gist:3220451
SELECT [me].[id], [me].[name], [me].[group_id], [me].[user], [me].[version], [me].[is_active], [key_server_side_mia], [button_server_side_mia], [messenger_server_side_
mia], [key_pro_server_side_mia], [key_status], [button_status], [messenger_status], [key_pro_status], [is_group_active], [last_checkin], [macro]
FROM (
SELECT [me].[id], [me].[name], [me].[group_id], [me].[user], [me].[version], [me].[is_active], [key_server_side_mia], [button_server_side_mia], [messenger_server_s
ide_mia], [key_pro_server_side_mia], [key_status], [button_status], [messenger_status], [key_pro_status], [is_group_active], [last_checkin], [macro], ROW_NUMBER() OVE
R (
ORDER BY
SELECT( 1 )
) AS [rno__row__index]
FROM (
@frioux
frioux / gist:4288396
Created Dec 14, 2012
weird bug in union I think
View gist:4288396
.:15:24:31:. <geoff> which, I had an interesting time meshing that union with correlated_resultset,
incidentally
.:15:24:41:. frew I made a thing that will correctly sort on a correlated column when the user asks to
.:15:24:51:. frew oh?
.:15:24:52:. frew why?
.:15:24:53:. <geoff> oooo
.:15:24:58:. <geoff> I just had to do
.:15:25:05:. <geoff> $rs1->with_correlation
.:15:25:10:. <geoff> and $rs2->with_correlation
.:15:25:13:. <geoff> then union
@frioux
frioux / WrapCGI.pm
Last active Jan 14, 2016
replacement Plack::App::WrapCGI (perl only)
View WrapCGI.pm
package Plack::App::WrapCGI;
use strict;
use warnings;
use parent qw(Plack::Component);
use Plack::Util::Accessor qw(script execute _app);
use File::Spec;
use CGI::Emulate::PSGI;
use CGI::Compile;
use Carp;
use POSIX ":sys_wait_h";
@frioux
frioux / gist:7173878
Created Oct 26, 2013
Home dir organization
View gist:7173878
  • code - source code checkouts (maybe split this up based on if it's my project or not?)
  • media/Music - symlink to music drive/partion
  • media/Games and .local/share/Steam - symlink to games drive/partition
  • tmp - working space for extracting tarballs to, etc. ram partition
  • no Downloads! Things get downloaded to either tmp, or Dropbox
  • Dropbox - articles, private code, books, weird drivers, etc (to be organized very similarly to home dir)
  • mnt - servers or media shares I mount regularly
  • bin - my various binaries (most are in code/dotfiles/bin or Dropbox/bin though)
  • .config - non-dotfile configs (vpn config, etc)
  • var/Mail - email
@frioux
frioux / query.sql
Last active Jan 4, 2016
Query tuning (4b7216a)
View query.sql
SELECT [me].[id], [me].[site], [me].[channel], [me].[subject], [me].[message], [me].[date], [me].[description], [me].[context], (
SELECT COUNT( * )
FROM [LogChildren] [children_alias]
JOIN [LogStatus] [statuses]
ON [statuses].[child_id] = [children_alias].[id]
WHERE [statuses].[success] = '0' AND [children_alias].[parent_id] = [me].[id]
), (
SELECT COUNT( * )
FROM [LogChildren] [children_alias]
JOIN [LogStatus] [statuses]
View keybase.md

Keybase proof

I hereby claim:

  • I am frioux on github.
  • I am frew (https://keybase.io/frew) on keybase.
  • I have a public key whose fingerprint is 2896 7E7B F03D B43E 5A43 3430 6EB3 302F 737A 7582

To claim this, I am signing this object: