Skip to content

Instantly share code, notes, and snippets.

View plicease's full-sized avatar
🗻
Mountain West

Graham✈️✈️ plicease

🗻
Mountain West
View GitHub Profile
@plicease
plicease / gist:2d94f6a876b19fbd47bb
Created April 10, 2015 15:29
struct tm interface
struct tm {
int tm_sec; /* seconds after the minute [0-60] */
int tm_min; /* minutes after the hour [0-59] */
int tm_hour; /* hours since midnight [0-23] */
int tm_mday; /* day of the month [1-31] */
int tm_mon; /* months since January [0-11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday [0-6] */
int tm_yday; /* days since January 1 [0-365] */
int tm_isdst; /* Daylight Savings Time flag */
use FFI::Raw;
my $libm = 'libm.so';
my $fdim = FFI::Raw->new(
$libm, 'fdim',
FFI::Raw::double, # return value
FFI::Raw::double, # arg #1
FFI::Raw::double # arg #2
);
@plicease
plicease / gist:a9d4c421a87847f43761
Last active August 29, 2015 14:18
FFI::Platypus example
use FFI::Platypus;
my $ffi = FFI::Platypus( lib => 'libm.so' );
$ffi->attach( fdim => [ 'double', 'double' ] => 'double' );
say fdim(7.0, 2.0);
use FFI::Platypus;
my $ffi = FFI::Platypus( lang => 'Rust', lib => './libpoints.so' );
$ffi->type( opaque => 'Point');
$ffi->attach( make_point => [ 'i32', 'i32' ] => 'Point' );
$ffi->attach( get_distance => [ 'Point', 'Point'] => 'f64' );
say get_distance(make_point(2,2), make_point(4,4));
@plicease
plicease / gist:785e8fb6e8de52d7406e
Last active August 29, 2015 14:19
match a phone number
my $text = <$fh>;
# regular expression or "regex"
if($text =~ /([0-9]{3}-[0-9]{3}-[0-9]{4})/)
{
say $1;
}
@plicease
plicease / gist:b51c70df4c516a89912d
Last active August 29, 2015 14:22
extract_uv_handle_type.pl
use strict;
use warnings;
use 5.010;
use Convert::Binary::C;
my $c = Convert::Binary::C->new;
$c->Include(qw(
/usr/include
/usr/include/x86_64-linux-gnu/
/usr/include/linux
* {
font-family: Consolas, monospace!important;
}
body {
background: white;
font-size: 11px;
}
.bz_group_visibility_section {
@plicease
plicease / emoji.pl
Created January 11, 2014 19:37 — forked from windytan/emoji.pl
# Oona Räisänen 2013
@emoji = qw( 🌀 🌂 🌅 🌈 🌙 🌞 🌟 🌠 🌰 🌱 🌲 🌳 🌴 🌵 🌷 🌸
🌹 🌺 🌻 🌼 🌽 🌾 🌿 🍀 🍁 🍂 🍃 🍄 🍅 🍆 🍇 🍈
🍉 🍊 🍋 🍌 🍍 🍎 🍏 🍐 🍑 🍒 🍓 🍔 🍕 🍖 🍗 🍘
🍜 🍝 🍞 🍟 🍠 🍡 🍢 🍣 🍤 🍥 🍦 🍧 🍨 🍩 🍪 🍫
🍬 🍭 🍮 🍯 🍰 🍱 🍲 🍳 🍴 🍵 🍶 🍷 🍸 🍹 🍺 🍻
🍼 🎀 🎁 🎂 🎃 🎄 🎅 🎈 🎉 🎊 🎋 🎌 🎍 🎎 🎏 🎒
🎓 🎠 🎡 🎢 🎣 🎤 🎥 🎦 🎧 🎨 🎩 🎪 🎫 🎬 🎭 🎮
🎯 🎰 🎱 🎲 🎳 🎴 🎵 🎷 🎸 🎹 🎺 🎻 🎽 🎾 🎿 🏀
@plicease
plicease / log.txt
Created February 18, 2018 01:02
Unix::Groups::FFI sudo test on os x
sh-3.2# TEST_ORIGINAL_USER=ollisg TEST_RUN_SUDO=1 prove -lvm xt/author/sudo.t
xt/author/sudo.t ..
ok 1 - Set supplementary groups to 20
ok 2 - Retrieved supplementary groups 20
ok 3 - Cleared supplementary groups
not ok 4 - No supplementary groups
# Failed test 'No supplementary groups'
# at xt/author/sudo.t line 26.
# Structures begin differing at:
# $got->[0] = '0'
t\test_alien__xs_ok.t ..
n:/lang/perl/active~1/x86/v524~1.1/site/lib/auto/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible N:\lang\perl\activestate\x86\v5.24.1\lib\CORE/libperl524.a when searching for -lperl524
n:/lang/perl/active~1/x86/v524~1.1/site/lib/auto/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible N:\lang\perl\activestate\x86\v5.24.1\lib\CORE\libperl524.a when searching for -lperl524
n:/lang/perl/active~1/x86/v524~1.1/site/lib/auto/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible N:\lang\perl\activestate\x86\v5.24.1\lib\CORE/libperl524.a when searching for -lperl524
n:/lang/perl/active~1/x86/v524~1.1/site/lib/auto/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lperl524
collect2: ld returned 1 exit status
n:/lang/perl/active~1/x86/v524~1.1/site/lib/auto/mingw/bin