Skip to content

Instantly share code, notes, and snippets.

View dnmfarrell's full-sized avatar

David Farrell dnmfarrell

View GitHub Profile
// OpenGL Extension Exclusions - may be modified before building.
//
// Generated for Intel Open Source Technology Center, Mesa DRI Intel(R) HD Graphics 5500 (Broadwell GT2)
// OpenGL v3.0 Mesa 11.1.0 (git-525f3c2), using FreeGLUT v30000
#define NO_GL_VERSION_4_5
#define NO_GL_VERSION_4_4
#define NO_GL_VERSION_4_3
#define NO_GL_VERSION_4_2
#define NO_GL_VERSION_4_1
@dnmfarrell
dnmfarrell / spider.pl
Created January 14, 2019 01:15
Basic Perl spider using Selenium and headless Chrome
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Tiny;
use Getopt::Long 'GetOptions';
use Encode qw(encode decode);
use Parallel::ForkManager;
use PerlIO::gzip;
use Selenium::Remote::Driver;
use Time::HiRes 'sleep';
@dnmfarrell
dnmfarrell / dump-catalyst-routes
Last active January 31, 2024 05:47
Prints all controllers, methods and routes for a given Catalyst app
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use Encode 'decode_utf8';
my $app = shift or usage();
bootstrap_app($app, @ARGV);
my $d = $app->dispatcher;
my $actions = get_actions($d);
@dnmfarrell
dnmfarrell / lox debug.txt
Created July 14, 2020 18:46
lox debug mode example
$ ./lox -d
Welcome to Lox version 0.01
> var a = 7; print (a + 4);
1 1 VAR var
1 5 IDENTIFIER a
1 7 EQUAL =
1 9 NUMBER 7
1 10 SEMICOLON ;
1 12 PRINT print
1 18 LEFT_PAREN (
@dnmfarrell
dnmfarrell / qsort.c
Last active October 22, 2020 02:17
quicksort on a linked list "gcc -o qsort qsort.c"
#include <stdio.h>
#include <stdlib.h>
typedef struct List {
int n;
void *next;
} List;
List* ListNew (int n) {
List *l = malloc(sizeof(List));
@dnmfarrell
dnmfarrell / sierpinski-main.go
Last active January 20, 2022 02:53
Generate Sierpiński's triangle in golang
// Generate Sierpiński's triangle
// 0********************************************************************2
// ****** ****** ****** ****** ****** ******* ****** ******
// ************ ************ ************ ************
// ********* ********* ******** *********
// ***** ****** ****** ******
// ******************** *******************
// **************** ******** ********
// ***** **** ***** ****
// ********** ***********
@dnmfarrell
dnmfarrell / wchar.c
Created January 21, 2022 14:51
Demo to read a wide character with ncurses and print it to the screen
/* wchar.c - read a wide character with ncurses and print it on the screen
* gcc -Wall $(pkg-config --cflags ncursesw) -o wchar wchar.c $(pkg-config --libs ncursesw)
* ./wchar
*/
#include <curses.h>
#include <locale.h>
int main(void)
{
setlocale(LC_ALL, "");
@dnmfarrell
dnmfarrell / pss-demo.pl
Created February 11, 2022 20:19
Use /proc/smaps to show the difference between resident and proportional set size memory
#!/usr/bin/env perl
use strict;
use warnings;
use Linux::Smaps;
sub print_memusage {
my $smaps = Linux::Smaps->new;
printf "% 6s % 9d % 9d KB % 9d KB\n", $_[0], $$, $smaps->rss, $smaps->pss;
}
@dnmfarrell
dnmfarrell / charging.sh
Created March 14, 2022 13:41
Is your laptop battery charging?
#!/bin/sh
grep '^Charging$' /sys/class/power_supply/BAT0/status >/dev/null
@dnmfarrell
dnmfarrell / trycopy.go
Last active May 13, 2022 16:19
trycopy - uses a try monad to copy a file
package try // https://github.com/dnmfarrell/try
import (
"fmt"
"io"
"os"
)
// based on:
// https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md