Skip to content

Instantly share code, notes, and snippets.

View prologic's full-sized avatar
👋
Principal SRE, Founder of Yarn.social and Salty.im

James Mills prologic

👋
Principal SRE, Founder of Yarn.social and Salty.im
View GitHub Profile
#!/usr/bin/env python
class Node(object):
def __init__(self, parent, obj):
self.parent = parent
self.next = None
self.obj = obj
@prologic
prologic / pbot.py
Created May 19, 2014 03:06
Pico IRC Bot using circuits in 24 Lines of Code.
from circuits import Component
from circuits.net.sockets import TCPClient, connect
from circuits.net.protocols.irc import IRC, PRIVMSG, USER, NICK, JOIN, RPL_ENDOFMOTD, ERR_NOMOTD # noqa
class PBot(Component):
def init(self, host, port=6667):
self.target = (host, port)
self += (TCPClient() + IRC())
$ python -i foo.py
10
8
>>> def digitalSum(n):
... if n < 0: sign = -1
... else: sign = 1
... n = abs(n)
... if n < 10: return n
... return sign * (n % 10 + digitalSum(n // 10))
...
class LinkedList:
def __init__(self, value, next=None):
self.value = value
self.next = next
def minmax(ll):
if ll.value is None:
return (None, None)
@prologic
prologic / wmmon output
Created May 23, 2014 07:47
My new Core i7 Desktop running CRUX/Linux
----------------------------------------------------------------------
PCpractico.es Wmon v0.64
Developer: Francisco Martinez
* ------------ GENERAL SYSTEM INFO -------------------------------------
* Platform: Linux-3.12.17-x86_64-Intel-R-_Core-TM-_i7-3770K_CPU_@_3.50GHz-with-glibc2.2.5
* System: Linux
* Release: 3.12.17
* Version: #7 SMP PREEMPT Fri May 9 18:04:48 EST 2014
* CPU ID: Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
* CPU Cores: 8
@prologic
prologic / log
Created May 29, 2014 12:21
Arduino project compile errors
(chickencoup)
prologic@daisy
Thu May 29 22:20:40
~/chickencoup
$ ino build
Searching for Board description file (boards.txt) ... /usr/share/arduino/hardware/arduino/boards.txt
Searching for Arduino lib version file (version.txt) ... /usr/share/arduino/lib/version.txt
Detecting Arduino software version ... 1.0.5 (1.0.5)
Searching for Arduino core library ... /usr/share/arduino/hardware/arduino/cores/arduino
Searching for Arduino standard libraries ... /usr/share/arduino/libraries
@prologic
prologic / log
Created June 2, 2014 00:10
Starting a container -- weird Cmd
$ docker ps -a --no-trunc
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d7ebbee825cecb4ec38e1efc5048c1656ae3be9194fe5fa0e16b5ae876adfecd ccaih/terranova:latest /bin/sh -c '#(nop) ADD file:54aafd124dc964fa814c64696e6a750788e6dc588957be40238380ea6b60a3bb in /etc/supervisor.d/plone.conf' 28 seconds ago Exited (0) 27 seconds ago ecstatic_lovelace
@prologic
prologic / sketch.ino
Created June 9, 2014 12:23
My Arduino Sketch
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <Ethernet.h>
#include <aREST.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
#define ADAFRUIT_CC3000_IRQ 3
@prologic
prologic / build.log
Created June 12, 2014 11:23
Recent build of go 1.2.2 and godoc build failure
+ /usr/ports/contrib/go/work/pkg/usr/bin/go get -u code.google.com/p/go.tools/cmd/godoc
# code.google.com/p/go.tools/go/exact
/tmp/go/src/code.google.com/p/go.tools/go/exact/exact.go:255: new(big.Rat).SetFrac(x.val, int1).Float32 undefined (type *big.Rat has no field or method Float32)
/tmp/go/src/code.google.com/p/go.tools/go/exact/exact.go:255: not enough arguments to return
/tmp/go/src/code.google.com/p/go.tools/go/exact/exact.go:257: x.val.Float32 undefined (type *big.Rat has no field or method Float32)
/tmp/go/src/code.google.com/p/go.tools/go/exact/exact.go:257: not enough arguments to return
=======> ERROR: Building '/usr/ports/contrib/go/go#1.2.2-1.pkg.tar.gz' failed.
prt-get: error while install
-- Packages where install failed
@prologic
prologic / simpleircbot.py
Created June 15, 2014 05:59
Simple IRC BOt
from circuits import Component
from circuits.net.sockets import TCPClient, connect
from circuits.protocols.irc import IRC, PRIVMSG, USER, NICK, JOIN
from circuits.protocols.irc import ERR_NICKNAMEINUSE
from circuits.protocols.irc import RPL_ENDOFMOTD, ERR_NOMOTD
class Bot(Component):