Skip to content

Instantly share code, notes, and snippets.

View miquels's full-sized avatar

Miquel van Smoorenburg miquels

  • XS4ALL
  • Amsterdam
View GitHub Profile
@import '../../node_modules/vuetify/src/stylus/settings/_colors'
$color-root := #FFFFFF
$body-bg := $grey.darken-4
$theme := {
primary: $blue.base,
accent: $blue.accent-1,
secondary: #181818,
info: $blue.base,
warning: $amber.base,
error: $red.base,
@miquels
miquels / object-fit-css.md
Last active February 10, 2024 16:06
object-fit equivalents in pure css

object-fit equivalents in pure css

HTML

<div class="container">
  <img src="http://thetvdb.com/banners/fanart/original/78804-61.jpg">
</div>

Object-fit:contain

@miquels
miquels / vuetify-dev-link.md
Created March 14, 2017 10:07
Using the vuetify 'dev' branch in your project
@miquels
miquels / split_str.c
Created April 30, 2018 19:11
Demo voor mies
#include <stdio.h>
#include <string.h>
int str_split(char *in, char *out[2])
{
out[0] = strtok(in, "=");
out[1] = strtok(NULL, "=");
return out[1] == NULL ? -1 : 0;
}
@miquels
miquels / split_str2.c
Created April 30, 2018 21:14
Advanced demo voor mies
#include <stdio.h>
#include <string.h>
#include <malloc.h>
struct key_val {
char *key;
char *value;
};
struct key_val *key_val_split(char *input)
@miquels
miquels / enable_so_peercred_dgram.rs
Created August 2, 2018 20:42
enable SO_PEERCRED in Rust on a UNIX domain socket
extern crate libc;
extern crate tokio_uds;
use std::os::unix::io::AsRawFd;
// this is automatically enabled on stream socket - only for
// datagram sockets do you need to manually enable it.
fn enable_so_passcred(unix_socket: &tokio_uds::UnixListener) {
let fd = unix_socket.as_raw_fd();
let val: libc::c_int = 1;
@miquels
miquels / native-tls-acceptor-from-pem-files.rs
Created August 9, 2018 16:00
native_tls::TlsAcceptor from .key/.crt PEM files instead of .p12 file.
use std::io::{self,Error,ErrorKind};
use std::path::Path;
use openssl::pkey::PKey;
use openssl::x509::X509;
use openssl::pkcs12::Pkcs12;
use openssl::stack::Stack;
use native_tls::{self,Identity};
fn read_pems(key: impl AsRef<Path>, cert: impl AsRef<Path>, password: &str) -> io::Result<Vec<u8>> {
@miquels
miquels / trait_alias_macro.rs
Last active September 19, 2018 22:07
Rust trait alias macro
extern crate futures;
use futures::prelude::*;
use std::io;
macro_rules! trait_alias {
($alias:ident = $($trait_:tt)*) => {
trait $alias: $($trait_)* {}
impl<T: $($trait_)*> $alias for T {}
}
@miquels
miquels / pam.c
Created December 7, 2018 10:22
PAM authentication boilerplate.
/* cc -DTEST -Wall -o pamtest pam.c -lpam */
#include <security/pam_appl.h>
#include <sys/resource.h>
#include <string.h>
#include <stdlib.h>
struct creds {
char *user;
char *password;
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <resolv.h>
#include <netdb.h>