Skip to content

Instantly share code, notes, and snippets.

View l0s's full-sized avatar

Carlos Macasaet l0s

  • San Antonio, TX
View GitHub Profile
@l0s
l0s / handler.rs
Created May 1, 2022 18:16
Simple pluggable request handler mechanism
use rayon::{ThreadPool, ThreadPoolBuilder};
#[derive(Copy, Clone)]
pub struct Request {
request_id: u8,
}
pub struct Response {
response_id: u8,
}
@l0s
l0s / mutex.c
Last active April 29, 2019 01:13
Distributed Queue Processing in C
#include <pthread.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <errno.h>
struct StringNode {
char* string;
@l0s
l0s / mutex_min.c
Last active April 29, 2019 00:47
Simple Mutex example in C
#include <pthread.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
struct WorkerContext {
pthread_mutex_t* lock;
};
void destroy_WorkerContext( struct WorkerContext* context ) {
Verifying that "carlosmacasaet.id" is my Blockstack ID. https://onename.com/carlosmacasaet
@l0s
l0s / output
Last active July 30, 2016 21:31
Attempt at AWS λ in Swift
root@1c6c66df21cf:/tmp# swiftc -o request_handler request_handler.swift
root@1c6c66df21cf:/tmp#
@l0s
l0s / compile.js
Created April 17, 2016 17:02
Compile Solidity from UNIX command line
// Usage:
// node compile.js <filename.sol>
var fs = require( 'fs' );
var solc = require( 'solc' );
var compile = function( error, data )
{
if( error )
{
@l0s
l0s / gen-xkcd-pass
Created October 15, 2015 18:36
XKCD password generator for BSD / Mac OS X
# adapted from: https://pthree.org/2015/09/05/password-generation-in-the-shell/
# which is inspired by: https://xkcd.com/936/
gen-xkcd-pass() {
[ $(echo "$1"|grep -E "[0-9]+") ] && NUM="$1" || NUM=1
DICT=$(LC_CTYPE=C grep -E "^[a-zA-Z]{3,6}$" /usr/share/dict/words)
for I in $(seq 1 "$NUM"); do
WORDS=$(echo "$DICT"|gshuf -n 6|paste -sd ' ' -)
XKCD=$(echo "$WORDS"|sed 's/ //g')
echo "$XKCD ($WORDS)"|awk '{x=$1;$1="";printf "%-36s %s\n", x, $0}'
done | column
@l0s
l0s / Swift 1.x
Created June 18, 2015 03:00
Lazy instantiation of AVAudioRecorder
lazy var recorder:AVAudioRecorder = {
var error:NSError?
println( "-- saving to: \( self.fileName )" )
let retval =
AVAudioRecorder( URL:NSURL( fileURLWithPath:self.fileName ), settings:nil, error:&error )
retval.delegate = self
retval.meteringEnabled = true
assert( error == nil, "Error creating audio recorder: \( error!.localizedDescription )" )
return retval
}()
@l0s
l0s / keybase.md
Created October 24, 2014 20:53
Keybase GitHub Proof

Keybase proof

I hereby claim:

  • I am l0s on github.
  • I am carlosmacasaet (https://keybase.io/carlosmacasaet) on keybase.
  • I have a public key whose fingerprint is 5EEE 4C39 273D 5C28 41D7 F777 3C20 05EC 720E 900A

To claim this, I am signing this object: