Skip to content

Instantly share code, notes, and snippets.

View digicyc's full-sized avatar
🎯
Focusing

AaronA digicyc

🎯
Focusing
View GitHub Profile
@digicyc
digicyc / MQTTSubscribe.sh
Created June 28, 2022 17:09 — forked from David-Lor/MQTTSubscribe.sh
Shell Script to subscribe to MQTT and execute a callback
#!/bin/bash
# This script subscribes to a MQTT topic using mosquitto_sub.
# On each message received, you can execute whatever you want.
while true # Keep an infinite loop to reconnect when connection lost/broker unavailable
do
mosquitto_sub -h "127.0.0.1" -t "test" | while read -r payload
do
# Here is the callback to execute whenever you receive a message:
@digicyc
digicyc / mongod.sh
Created February 25, 2019 23:49 — forked from m-szk/mongod.sh
a bash script for start or stop mongodb.
#!/bin/bash
mongod=/usr/local/mongodb/bin/mongod
mongod_data=/Users/michito/work/mongodb_data
mongod_log=/Users/michito/work/mongodb_log/mongodb.log
prog=mongod.sh
RETVAL=0
stop() {
grep_mongo=`ps aux | grep -v grep | grep "${mongod}"`
@digicyc
digicyc / netspeed.sh
Created February 2, 2017 16:55 — forked from rsvp/netspeed.sh
netspeed.sh : check download speed rate via command line | Linux bash script
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2013-07-11
#
# _______________| netspeed : check download speed via command line.
#
# Usage: netspeed [tokyo, london, usw, use, east, west, URL]
# ^default U.S. west coast.
# [ -speed_KB/sec ]
# ^negation activates the Mbps converter.
#

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@digicyc
digicyc / gist:3440294
Created August 23, 2012 18:56 — forked from tjweir/gist:3437067
reader monad for java.util.Properties example
/* Start by creating a reader for some fake yet conceivable type for executing SQL queries. */
val dbReader: Reader[Properties, JdbcExecutor] =
for {
driver <- read[String]("db.driver")
uri <- read[String]("db.uri")
user <- read[String]("db.username")
password <- read[String]("db.password")
name <- read[String]("db.pool.name")
minCons <- read[Int]("db.pool.minConnections")
@digicyc
digicyc / uri.js
Created April 21, 2012 19:04 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.host; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
@digicyc
digicyc / scope_crazy.py
Created December 30, 2011 08:40
Python Scope
#!/usr/bin/env python
if True:
myval = "True"
else:
myval = "False"
# The Control statements appear to NOT have any strict scope.
print myval # This will infact print "True" o_O
#!/usr/bin/env python
from twilio.rest import TwilioRestClient
account = "xxxxxxxxxxxxxxxx"
token = "xxxxxxxxxxxxxxxxxx"
client = TwilioRestClient(account, token)
pull_num = "+18015555556"
victim = "+18015555555"
import com.mongodb.casbah.Imports._
class CasbahPlay {
private val mongoConn = MongoConnection()
private val coll = mongoConn("mongotalk")("unicorns")
def getWeight(name: String) = {
val unicorn = (coll.findOne(MongoDBObject("name" -> name)).get
// This is returning Option[Int] = Some(450.0)