Skip to content

Instantly share code, notes, and snippets.

View melvyniandrag's full-sized avatar
🌕
A Picture of Jupiter and 4 of its Moons Through Our Telescope.

melvyniandrag

🌕
A Picture of Jupiter and 4 of its Moons Through Our Telescope.
View GitHub Profile
@melvyniandrag
melvyniandrag / mouse.cpp
Created May 16, 2018 20:01
Read /dev/input/mouse0
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char** argv)
{
int fd, bytes;
unsigned char data[3];
const char *pDevice = "/dev/input/mouse0";
@melvyniandrag
melvyniandrag / README.md
Created April 25, 2018 18:29 — forked from bewest/README.md
plea for GIO examples for python + gdbus servers#
@melvyniandrag
melvyniandrag / README.md
Created April 25, 2018 18:29 — forked from bewest/README.md
plea for GIO examples for python + gdbus servers#
@melvyniandrag
melvyniandrag / getVLCVolume.cpp
Created April 19, 2018 20:47
Get Volume of VLC over DBus
/*
g++ thisFile.cpp -I/usr/include/glib-2.0 \
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ \
-lglib-2.0 -lgio-2.0 -lgobject-2.0
*/
#include <iostream>
#include <gio/gio.h>
static GMainLoop* loop = NULL;
@melvyniandrag
melvyniandrag / dbusVLC.cpp
Last active April 18, 2018 22:07
Able to detect signals.
/*
g++ cppdbus.cpp -I/usr/include/glib-2.0 \
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ \
-lglib-2.0 -lgio-2.0 -lgobject-2.0
This small program can pause/play media in vlc. Then, if the
tracklist is modified, the program will exit.
This is the dbus-monitor output corresponding to adding a track to a playlist:
@melvyniandrag
melvyniandrag / cppDbusVlc.cpp
Created April 10, 2018 21:14
use dbus to hit the play button in vlc
/*
g++ cppdbus.cpp -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ -lglib-2.0 -lgio-2.0 -lgobject-2.0
*/
#include <iostream>
#include <gio/gio.h>
int main()
{
GDBusConnection* conn = NULL;
GError* error = NULL;
@melvyniandrag
melvyniandrag / dbusVLC.py
Last active April 2, 2018 18:59
Control vlc over dbus
import dbus
import dbus.mainloop.glib
import time
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus=dbus.SessionBus()
obj = bus.get_object("org.mpris.MediaPlayer2.vlc",
"/org/mpris/MediaPlayer2")
print(dir(obj))
@melvyniandrag
melvyniandrag / client.c
Last active March 29, 2018 15:31
server / client with unix sockets
/*
** client.c -- a stream socket client demo
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
@melvyniandrag
melvyniandrag / main.cpp
Created March 1, 2018 20:07
arrays, pointers, references
#include <iostream>
#include <iomanip>
typedef char myArr[12];
void printInfo( myArr &arr, myArr arr2, myArr* arr3 )
{
std::cout << std::setw(10) << "arr: " << std::setw(20) << arr << std::setw(10) << " arr2: " << std::setw(20) << arr2 << std::setw(10) << " arr3: " << std::setw(20) << arr3 << std::endl;
std::cout << std::setw(10) << "&arr: " << std::setw(20) << &arr << std::setw(10) << " &arr2: " << std::setw(20) << &arr2 << std::setw(10) << " &arr3: " << std::setw(20) << &arr3 << std::endl;
std::cout << std::setw(10) << "arr[0]: " << std::setw(20) << arr[0] << std::setw(10) << " arr2[0]: " << std::setw(20) << arr2[0] << std::setw(10) << " arr3[0]: " << std::setw(20) << arr3[0] << std::endl;
std::cout << std::setw(10) << "&arr[0]: " << std::setw(20) << &arr[0] << std::setw(10) << " &arr2[0]: " << std::setw(20) << &arr2[0] << std::setw(10) << " &arr3[0]: " << std::setw(20) << &arr3[0] << std::endl;
@melvyniandrag
melvyniandrag / main.cpp
Created February 21, 2018 16:00
pass multiple args to a pthread
#include <pthread.h>
#include <iostream>
class A
{
public:
A( int _i, int *_p ) : i( _i ), p( _p ){}
int i;
int *p;
void squareMyPtr()
{