Skip to content

Instantly share code, notes, and snippets.

View ralt's full-sized avatar

Florian Margaine ralt

View GitHub Profile
// ListParser::ParseDepends - Parse a dependency element /*{{{*/
// ---------------------------------------------------------------------
/* This parses the dependency elements out of a standard string in place,
bit by bit. */
const char *debListParser::ParseDepends(const char *Start,const char *Stop,
std::string &Package,std::string &Ver,unsigned int &Op)
{ return ParseDepends(Start, Stop, Package, Ver, Op, false, true, false); }
const char *debListParser::ParseDepends(const char *Start,const char *Stop,
std::string &Package,std::string &Ver,unsigned int &Op,
bool const &ParseArchFlags)
#include <config.h>
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/pkgcache.h>
#include <string.h>
#include <string>
#include <gtest/gtest.h>
@ralt
ralt / readme.md
Last active September 7, 2016 18:57
Lossless token change

Some information:

  • fingerprint is 5 bytes, and is at position 0 on device. There's no fingerprint on user file.
  • a token is 128 bytes

  • on device, fseek to position 133 (i.e. after the fingerprint + token). Write the fingerprint + the old token. If power is cut during the writing, or after, the next login will be fine. (successful login if there's a failure = old token at pos 5 on device + old token at pos 0 on user file)

  • once the old token is written, fseek back to position 5 (right after the fingerprint), and write the new token. If power is cut during the writing or after, the next login will fail, look for a fingerprint, if there is, compare with the token after. Since it's the old one, the login will be fine. (successful login if there's a failure = old token at pos 138 on device + old token at position 0 on user file)

/*
The service, run as root, will listen on the /var/run/hermes.sock
socket. The only command it will understand is a four-bytes long
command, being a number mapping an action.
Really, only one action is needed: get me the content of the
connected hermes device. Having 4 bytes is cheap enough, and leaves
other possibilities later on, if needed.
The "get me the content" command needs the value "1". It can return
@ralt
ralt / lxc-lamp.sh
Created August 29, 2015 22:17
LAMP template for lxc
#!/bin/bash
# Fork of lxc-debian
# Highly opinionated. Updates libvirt's default network.
# The --ip argument is the last number of the IP
# The --mac argument is the last number of the MAC
# Detect use under userns (unsupported)
for arg in "$@"; do
[ "$arg" = "--" ] && break
@ralt
ralt / last-screenshot-symlink.sh
Created August 26, 2015 11:55
Always have a symlink to your last screenshot
@ralt
ralt / pastebin.sh
Last active August 31, 2016 12:33
putfile & pastebin
#!/bin/bash
SSH_FOLDER=foo@bar.com:www/
BASE_URL=http://bin.foo.com/
PASTE_FOLDER=~/.pastes/
file=$(mktemp ${PASTE_FOLDER}XXXXXX)
mv $file $file.html
file="$file.html"
chmod 644 ${file}
@ralt
ralt / install.sh
Last active August 29, 2015 14:28
Quicklisp Global Install (aka the road to a real debian package). Replace + with / in filenames.
sudo sbcl --load quicklisp.lisp --eval '(quicklisp-quickstart:install :path #p"/usr/share/quicklisp/quicklisp")'
# Maybe put the /usr/share/quicklisp/ folder straight in the package.
# quicklisp is downloaded in /usr/share/quicklisp/quicklisp so that /usr/share/quicklisp is available
# for other files, such as the helpers for quickloading global systems.
# The quicklisp.lisp file should be in /usr/share/quicklisp/, so that it's reusable
# for local installs. See /usr/bin/ql-local-install
@ralt
ralt / stumpwmrc.lisp
Created August 18, 2015 13:03
stumpwm alert-me-at
(ql:quickload :bordeaux-threads)
(defcommand alert-me-at (alert-hour alert-minute message) ((:number "hour: ") (:number "minute: ") (:string "message: "))
"Alert me at some point in time. Doesn't handle time too early, so the thread will go on forever."
(bordeaux-threads:make-thread
#'(lambda ()
(loop
do (sleep 5)
when (multiple-value-bind (seconds minute hour)
(get-decoded-time)
;;;; -*- Mode: Lisp -*-
(in-package :stumpwm)
(ql:quickload 'swank)
(ql:quickload :alexandria)
(swank-loader:init)
(defcommand swank () ()
(setf stumpwm:*top-level-error-action* :break)
(swank:create-server :port 4004