Skip to content

Instantly share code, notes, and snippets.

@maghul
maghul / discovery.js
Created March 25, 2015 11:47
Discovery using UDP in GJS/Gnome-Shell
// ------
// Broadcasts discovery requests for Logitech Media Server and listens to replies and publish messages
// will send all updates as a hash to the callback.
// The content of the hash is
// IPAD: The address of the server
// NAME: The name of the server
// JSON: The port to connect to for the JSON API
// UUID: The unique identifier of the server instance.
// ------
const GLib = imports.gi.GLib;
@vratiu
vratiu / .bash_aliases
Last active May 29, 2024 12:23
Git shell coloring
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@jedschneider
jedschneider / gh-pages-tips.md
Created June 7, 2012 17:59
github pages tips for jekyll wiki

Working With Github Pages

The FAQ maintained by Github covers most stumbling blocks, some other tips and tricks supplied here.

Gitignore

Add _site to .gitignore. The generated site should not be uploaded to Github since its gets generated by github.

Working With Code Partials

@buzztaiki
buzztaiki / shell_object_sample.js
Last active July 20, 2023 06:13
Using shell object in gjs
#!/usr/bin/gjs
// SPDX-License-Identifier: MIT
// usage: gjs shell_object_sample.js
const { GIRepository, GLib, Gio } = imports.gi;
function findLib(path, prefix) {
const libdir = Gio.File.new_for_path(path);
const files = libdir.enumerate_children('', Gio.FileQueryInfoFlags.NONE, null);
for (; ;) {
@buzztaiki
buzztaiki / gjs-io-sample.js
Created December 16, 2011 20:18
gjs-io-sample.js
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
let [res, out, err, status] = GLib.spawn_command_line_sync('ls -la');
print(out);
let [res, out] = GLib.spawn_command_line_sync('ls -la');
print(out);
let [res, out] = GLib.spawn_sync(null, ['/bin/ls', '-la'], null, 0, null);
@sj26
sj26 / upcdb.py
Created March 16, 2011 06:47
Python 3 command line interface to http://upcdatabase.com
#!/usr/bin/env python3
import os, sys
import xmlrpc.client
rpc_key = '...' # replace with your RPC Key from http://upcdatabase.com/user
server = xmlrpc.client.ServerProxy('http://www.upcdatabase.com/xmlrpc')
lookup_keys = {12: 'upc', 13: 'ean'}
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//