Skip to content

Instantly share code, notes, and snippets.

@dloman
dloman / xvfb
Last active September 12, 2023 12:32 — forked from jterrace/xvfb
### BEGIN INIT INFO
# Provides: Xvfb
# Required-Start: $local_fs $remote_fs
# Required-Stop:
# X-Start-Before:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Loads X Virtual Frame Buffer
### END INIT INFO
@dloman
dloman / sshpiperadd.bash
Last active August 5, 2022 21:27
sshpiper add
#!/usr/bin/bash
if [ $1="-h" ]; then
echo "USAGE: sshpiperadd.bash \$NAME \$USERNAME \$IP "
exit
fi
if [ "$#" -ne 4 ]; then
echo "USAGE: sshpiperadd.bash \$NAME \$USERNAME \$IP "
exit
@dloman
dloman / xvfb.service
Last active April 22, 2022 23:12
sytemd xvfb
[Unit]
Description=X Virtual Frame Buffer Service
After=network.target
[Service]
ExecStart=/usr/bin/Xvfb :1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
[Install]
WantedBy=multi-user.target
@dloman
dloman / any
Created May 31, 2018 07:10
simple any implementation
#include <iostream>
#include <memory>
#include <typeinfo>
struct bad_any_cast
{
};
class any
{
<!DOCTYPE html>
<meta charset="utf-8" />
<title>WebSocket Test</title>
<script language="javascript" type="text/javascript">
var wsUri = "wss://localhost:8181/";
var output;
function init()
{
@dloman
dloman / SBHXCommunityGuidelines.md
Last active December 7, 2017 00:57
SBHX Community Guidelines

Hi Santa Barbara Hackerspace community and members. We’re now into our sixth year of existence and have grown significantly in that time thanks to you all. As part of that growth we are setting forth some Community Guidelines to help make the space even better. We will be posting this document to sbhackerspace.com/membership. These guidelines are a living document and will be amended and revised as necessary.

TL;DR: Please clean up after yourself, the space does not have a janitor. Everyone can do their small part and help keep the space and equipment safe, clean, and useable. If a member fails to do this bad things will happen (we may throw their stuff away, yell at them, or they could lose their membership).

Trash

There are no janitors at the space sotrash cans are taken out by members who want to help out.. If you see a full trash can and want to help keep the space clean, please help out and empty it in the tan dumpster outside. The tan dumpster and blue recycling bin are the space’s refuse repos

std::mutex Mutex;
std::condition_variable cv;
std::unique_lock<std::mutex> Lock(Mutex);
for (auto i = 0; i < 10; ++i)
{
auto a = cv.wait_for(Lock, std::chrono::milliseconds(10));
if (a == std::cv_status::no_timeout)
{
return 1;
@dloman
dloman / quadrature rotary encoder
Created October 16, 2013 21:47
quadrature encoder -> servo
#include <Servo.h>
Servo MyServo;
void setup()
{
// encoder pin on interrupt 0 (pin 2)
attachInterrupt(0, encoderPinChangeA, CHANGE);
// encoder pin on interrupt 1 (pin 3)
attachInterrupt(1, encoderPinChangeB, CHANGE);
@dloman
dloman / gist:7011907
Created October 16, 2013 17:47
Python script for getting number of new messages on an exchange server
#!/usr/bin/python
##Gets Number of New Emails
##Daniel Loman 10/15/2013
import getpass, imaplib, pickle
########################################################################################
########################################################################################
def GetNumberOfMessages():
Mailbox = imaplib.IMAP4("server.address")
AuthenticationToken = pickle.load(open(AuthFileLocation,'rb'))
Mailbox.authenticate("NTLM", AuthenticationToken)
#include <iostream>
#include <chrono>
using namespace std;
int main()
{
typedef chrono::duration<unsigned long, milli> milliseconds_t;
typedef chrono::duration<unsigned long> seconds_t;
milliseconds_t Milliseconds(11111);