Skip to content

Instantly share code, notes, and snippets.

View jnbek's full-sized avatar

John D Jones III jnbek

View GitHub Profile
@jnbek
jnbek / hasProperty.js
Created November 14, 2011 17:10 — forked from ryanflorence/hasProperty.js
See if an object has a property
var has = function (obj, property) {
var tree = obj,
split = property.split('.'),
last = split.pop();
while (next = split.shift()) {
tree = tree[next];
if (tree === undefined) return false;
}
@jnbek
jnbek / gist:3218045
Created July 31, 2012 15:58
~/bin/dirty
# I want a tool that tells me what my modified files are, whether I'm in a Subversion or Git project.
# I want to be able to say vim $(dirty)
#!/usr/bin/perl
use warnings;
use strict;
my @lines = qx/svn status 2>&1/;
exit if @lines == 0;
ss23@Crisp /etc/init.d $ cat vixie-cron
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/vixie-cron.rc7,v 1.1 2011/12/31 14:58:21 idl0r Exp $
command=/usr/sbin/cron
pidfile=/var/run/cron.pid
depend() {
@jnbek
jnbek / clojure-match.clj
Created September 13, 2012 16:33 — forked from ckirkendall/clojure-match.clj
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
#! /usr/bin/perl
use strict;
use warnings;
use utf8;
use IO::Socket::INET6;
use LWP::UserAgent;
## Use IO::Socket::INET6 instead of IO::Socket::INET6 in Net::HTTP.
BEGIN {
#!/bin/sh
#
# PROVIDE: plack_app
# REQUIRE: LOGIN
# BEFORE: cron
#
# Add the following lines to /etc/rc.conf to enable the webapp:
# plack_app_enable (bool): Set to "NO" by default.
@jnbek
jnbek / ping_api.rc
Last active December 22, 2016 03:10 — forked from dynax60/ping_api.rc
Example of FreeBSD rc-file for Mojolicious Hypnotoad Server
#!/bin/sh
# PROVIDE: ping_api
# REQUIRE: NETWORKING
# KEYWORD: shutdown
. /etc/rc.subr
name="ping_api"
rcvar=`set_rcvar`
@jnbek
jnbek / getCurrentPosition_canvas.html
Created December 8, 2015 21:21 — forked from strongwave/getCurrentPosition_canvas.html
A Demo Drawing Google Map on Canvas Tag for HTML5
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
jQuery(window).ready(function(){
g_initialize();
jQuery("#findLocationBtn").click(initiate_geolocation);
});
@jnbek
jnbek / nginx.vhost
Created December 18, 2016 23:43 — forked from vedovelli/nginx.vhost
server {
listen 80;
server_name CHANGEME.app;
root /var/www/vhosts/CHANGEME.app/public;
index index.html index.htm index.php;
charset utf-8;
location / {
@jnbek
jnbek / dbus.sh
Created June 1, 2017 14:35 — forked from biboudis/dbus.sh
Playing with dbus.
# qdbus lists all service names of services that are running and you can manipulate at the moment.
qdbus
# control dbus
qdbus org.mpris.MediaPlayer2.clementine /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
qdbus org.mpris.MediaPlayer2.clementine /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
# and use --literal if you need to print the reply in plain text
qdbus --literal org.mpris.MediaPlayer2.clementine /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Playlists.ActivatePlaylist /org/mpris/MediaPlayer2/Playlists/20