Skip to content

Instantly share code, notes, and snippets.

package rss
import "encoding/xml"
// NonNamespaceString is a special kind of string. When unmarshal'ed it
// will only unmarshal when there is no namespace.
// For more details, see: https://github.com/golang/go/issues/8535
type NonNamespaceString string
func (s *NonNamespaceString) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
@Matt3o12
Matt3o12 / randomizedColorRenderer.go
Created April 16, 2015 17:01
Termui - Wiki - ColorRenderers Example
type RandomRendererFactory struct {
Max int
Min int
}
func NewRandomRendererFactory(min, max int) RandomRendererFactory {
return RandomRendererFactory{Min: min, Max: max}
}
func (f RandomRendererFactory) TextRenderer(text string) TextRenderer {
package main
import (
"time"
ui "github.com/gizak/termui"
)
func main() {
err := ui.Init()
class User (models.Model):
name = models.CharField(max_length=255)
class Manager (models.Model):
registration = models.PositiveInteger()
name = models.CharField(max_length=255)
class ClientHistory (models.Model):
@Matt3o12
Matt3o12 / createRamdisk.py
Created October 22, 2014 21:17
Simple gist for creating a RAM Disk on Mac OS X (only tested on Yosemite, but it should work on Mavericks, too).
#!/usr/bin/env python3.4
import argparse
import sys
import subprocess
class ErrorToleranteParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write("error: {}\n".format(message))
self.print_help()
Using `unittest.main()`:
python tests.py -b
.F
Stdout:
Should be printed since this test failed.
======================================================================
FAIL: test_print (__main__.TestSequenceFunctions)
----------------------------------------------------------------------
Traceback (most recent call last):
failed=false
total=1000
for i in $(seq ${total}); do
printf "Status: ${i}/${total}\r"
psql --user "Matt3o12" --no-password --host="localhost" --port=5432 --dbname="Matt3o12" -c "" || failed=true
if [ "$failed" = true ]; then
echo "Error after attempt ${i}."
exit 1
fi
failed=false
total=1000
for i in $(seq ${total}); do
printf "Status: ${i}/${total}\r"
psql --user "Matt3o12" --no-password --host="localhost" --port=5432 --dbname="Matt3o12" -c "" || failed=true
if [ "$failed" = true ]; then
echo "Error after attempt ${i}."
exit 1
fi
import timeit;
import psycopg2
def psy():
with psycopg2.connect(user="Matt3o12", password="", host="localhost", port=5432, database="Matt3o12") as conn:
pass
if __name__ == "__main__":
i = 0
try:
import timeit;
import psycopg2
def psy():
with psycopg2.connect(user="Matt3o12", password="", host="localhost", port=5432, database="Matt3o12") as conn:
pass
if __name__ == "__main__":
i = 0
try: