This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const ffi = require('ffi'); | |
const ref = require('ref'); | |
const Struct = require('ref-struct'); | |
const ArrayType = require('ref-array'); | |
const ioctl = ffi.ForeignFunction( | |
ffi.DynamicLibrary().get('ioctl'), | |
'int', ['int', 'int', 'void*'] | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ref = require('ref'); | |
module.exports = BufferType; | |
/** | |
* Fixed length "Buffer" type, for use in Struct type definitions. | |
* | |
* Optionally setting the `encoding` param will force to call | |
* `toString(encoding)` on the buffer returning a String instead. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ref = require('ref'); | |
module.exports = FixedString; | |
/** | |
* Fixed length "String" type, for use in Struct type definitions. | |
* Null-terminates by default. | |
* Throws an Error if there's not enough space available when setting a string. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <node.h> | |
#include <node_buffer.h> | |
#include <nan.h> | |
#include <dlfcn.h> | |
#include <stdio.h> | |
using namespace v8; | |
using namespace node; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var path = require('path'); | |
var devicesRoot = '/sys/bus/w1/devices/'; | |
var slavesFilename = path.resolve(devicesRoot, 'w1_bus_master1/w1_master_slaves'); | |
exports.find = function find (fn) { | |
fs.readFile(slavesFilename, 'ascii', function (err, data) { | |
if (err) return fn(err); | |
var slaves = data.trim().split('\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var Struct = require('ref-struct'); | |
var inherits = require('util').inherits; | |
var EventEmitter = require('events').EventEmitter; | |
// https://www.kernel.org/doc/Documentation/input/event-codes.txt | |
// https://www.kernel.org/doc/Documentation/input/input.txt | |
// /usr/include/linux/input.h | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ref = require('ref'); | |
var Struct = require('ref-struct'); | |
var ffi = require('ffi'); | |
// typedefs | |
var MPI_Datatype = 'int'; | |
var MPI_Comm = 'int'; | |
var MPI_Status = Struct({ | |
count: 'int', | |
MPI_SOURCE: 'int', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
my $file = "logo.png"; | |
my $length = -s $file; | |
print "Content-type: image/png\n"; | |
print "Content-length: $length \n\n"; | |
binmode STDOUT; | |
open (FH,'<', $file) || die "Could not open $file: $!"; | |
my $buffer = ""; | |
while (read(FH, $buffer, 10240)) { | |
print $buffer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cgi = require('cgi'); | |
var http = require('http'); | |
// See: http://git-scm.com/docs/git-http-backend | |
http.createServer( cgi('git', { | |
args: [ 'http-backend' ], | |
env: { | |
'GIT_PROJECT_ROOT': process.env.HOME, | |
'GIT_HTTP_EXPORT_ALL': '1' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
wcwidth.js: JavaScript Portng of Markus Kuhn's wcwidth() Implementation | |
======================================================================= | |
Copyright (C) 2012 by Jun Woong. | |
This package is a JavaScript porting of `wcwidth()` implementation | |
[by Markus Kuhn](http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c). | |
Permission is hereby granted, free of charge, to any person obtaining a copy of |