Table of Contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat u.py | |
def f(): | |
with suppress(IntegrityError): | |
print 'moo' | |
$ ./autoimporter u.py | |
from sqlalchemy.exc import IntegrityError | |
from contextlib import suppress | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <entityx/entityx.h> | |
struct TestComponent : entityx::Component<TestComponent> { | |
explicit TestComponent(std::string _name = "test") { | |
name = _name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <cstdlib> | |
#include <vector> | |
#include <set> | |
#include <list> | |
#include <chrono> | |
#include <iostream> | |
using namespace std; | |
using namespace std::chrono; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ByteReader struct { | |
io.Reader | |
} | |
func (b *ByteReader) ReadByte() (byte, error) { | |
var buf [1]byte | |
if _, err := io.ReadFull(b, buf[:]); err != nil { | |
return 0, err | |
} | |
return buf[0], nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"encoding/json" | |
"net/http" | |
"reflect" | |
"github.com/codegangsta/inject" | |
"github.com/go-martini/martini" | |
) | |
const ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CommitOrRollbackOnError commits or rolls back a transaction based on the | |
// value of an error reference. It helps avoid error prone boilerplate | |
// rollback calls. | |
// | |
// Most useful in a defer statement: | |
// | |
// tx, err := db.Begin() | |
// if err != nil { | |
// return err | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile with: c++ -std=c++11 -lentityx -lsfml-graphics t.cc | |
#include "SFML/Graphics.hpp" | |
#include "entityx/entityx.h" | |
using namespace entityx; | |
struct Movement : public Component<Movement> { | |
sf::Vector2f position, direction; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
"strconv" | |
"github.com/alecthomas/kingpin" | |
) |