Skip to content

Instantly share code, notes, and snippets.

Oskar Thornblad prewk

Block or report user

Report or block prewk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View component.jsx
import Component from 'react-pure-render/component';
import React, {PropTypes} from 'react';
import {Link} from 'react-router';
export default class Header extends Component {
static propTypes = {
msg: PropTypes.object.isRequired,
pathname: PropTypes.string.isRequired,
viewer: PropTypes.object
@prewk
prewk / taggable.js
Created Jan 12, 2016
Bookshelf.js polymorphic problem
View taggable.js
var bookshelf = require('./bookshelf');
var Post = require('./post');
/*
Schema:
posts:
id: PRIMARY
title: VARCHAR
View gist:e6251a151d8a5917bfd0
,,,,,,,,,,,,,,,.,.....................................................................................................................``````````````````````````````````````````````````````````````````
,,,,,,,,,,,,,,,,,,,.,.,,,.,,...........................................................................................................`````````````````````````````````````````````````````````````````
,,,,,,..,,,,,,,,,,,,,,.,,,.............................................................................................................`````````````````````````````````````````````````````````````````
,,,,,,...,,,,,,,,,,,,,,................................................................................................................`````````````````````````````````````````````````````````````````
.,,,,....,,,,,,.,,,,,,,...............................................................................................................``````````````````````````````````````````````````````````````````
..,......,,,,......
View gist:fbdd5027716660f15c44
#include <SFML/Graphics.hpp>
// Map of sprite vectors, mapped by name
std::map<std::string, std::vector<sf::Sprite>> sprites;
sf::Texture texture;
// Create some sprite frames and map to a name
void defineSprite(const std::string& name, const std::vector<sf::IntRect>& frames) {
std::vector<sf::Sprite> namedFrames(frames.size());
View gist:0c2b879a5a06a9d182dd
// -----------------
// scripts/breeds.json (This is okay, I've used it in another context and its interpreted correctly)
// -----------------
{
"Warrior": {
"sheet": "resources/Fighter-F-01.png",
"stats": {
"health": 100,
"strength": 50,
"intelligence": 10
View gist:ea73c9345e0b72a130f7
class SpriteSheet
{
public:
SpriteSheet();
SpriteSheet(const std::string& filename);
void defineSprite(std::string name, std::vector<sf::IntRect> frames);
const sf::Sprite& getFrame(const std::string& name, int frame);
sf::Texture texture;
View gist:fb97fec7d9b9842b920c
var menuItems = Immutable.List.of(
{ parent_id: 0, id: 1 },
{ parent_id: 1, id: 2 },
{ parent_id: 1, id: 2 }
);
var results1 = menuItems
.filter(function(menuItem) { return menuItem.parent_id === 1; }) // Filter out items with parent_id = 1
.sort(function(childA, childB) { return childA.sort_order - childB.sort_order; }); // Sort them by sort_order
You can’t perform that action at this time.