Skip to content

Instantly share code, notes, and snippets.

View AlexanderBrevig's full-sized avatar

Alexander Brevig AlexanderBrevig

View GitHub Profile
{
"path": "C:/Program Files (x86)/clisp-2.48/",
"cmd": ["clisp", "-i $file -x (main())"],
"selector": "source.lisp"
}
/*
(defun main (args)
(print "hello world")
(quit))*/
{
"path": "C:/dev/Python27",
"cmd": ["python", "$file"],
"file_regex": "^[ ]*File \"(…*?)\", line ([0-9]*)",
"selector": "source.python"
}
/*
print "hello world"
*/
@AlexanderBrevig
AlexanderBrevig / gist:c529d3b7e08a3237ec05
Last active August 29, 2015 14:14
nancy before hook with setter
public interface IUserNancyModule { User CurrentUser { get; set; } }
public static class Hooks {
public static Func<NancyContext, Response> SetUserFromRequest(IUserNancyModule module, IAttensiContext db) {
return (ctx) => {
var usr = db.Users.FirstOrDefault(u=>u.EmployeeId == ctx.CurrentUser.UserName);
if (usr!=null) {
module.CurrentUser = usr;
return null; //let request pass
} else {
@AlexanderBrevig
AlexanderBrevig / BME280.js
Created April 10, 2015 10:50
Espruino BME280 module
var C = {
regCalibStart: 0x88,
regChipID: 0xd0,
regReset: 0xe0,
regCalibStart2: 0xe1,
regCtrlHum: 0xf2,
regStatus: 0xf3,
regCtrlMeas: 0xf4,
regConfig: 0xf5,
regMeasurementsStart: 0xf,
@AlexanderBrevig
AlexanderBrevig / HelloCustomBraccio.ino
Last active April 21, 2016 12:14
An example using a new Braccio library
#include <Braccio.h>
#include <Servo.h>
Servo base;
Servo shoulder;
Servo elbow;
Servo wristRotate;
Servo wristVertical;
Servo gripper;
@AlexanderBrevig
AlexanderBrevig / Braccio.h
Last active May 3, 2016 04:42
A new Braccio library
/*
Braccio.h - Library for controlling the Arduino Robotic Arm; Braccio!
Copyright (c) 2016 - Alexander Brevig
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <Braccio.h>
Braccio robot;
void setup() {
robot.useShield();
robot.home();
}
void loop() { //DANCE!
@AlexanderBrevig
AlexanderBrevig / BraccioDance.ino
Created May 26, 2016 09:32
For dancing to a song at a live concert
#include <Servo.h>
#include <Braccio2.h>
Servo base;
Servo shoulder;
Servo elbow;
Servo wrist;
Servo rotate;
Servo gripper;
#pragma once
#include <string>
#include <cmath>
#include <fstream>
#include <iostream>
using namespace std;
class WAVfile
{
@AlexanderBrevig
AlexanderBrevig / LightMIDI.cpp
Last active January 31, 2017 14:50
LightMIDI
#include <iostream> // std::cout
#include <fstream> // std::ifstream
#include <chrono>
#include <thread>
#define MIDI_DEBUG(s) (s);
using namespace std;
//expect total size and current size to be available
class fileinfo {