Skip to content

Instantly share code, notes, and snippets.

SELECT "posts".*,
Group_concat(tags.id, "↕") AS keyword_ids,
Group_concat(tags.NAME, "↕") AS keyword_names,
Group_concat(Ifnull(tags.description, "null"), "↕") AS keyword_descriptions,
FROM "posts"
LEFT JOIN "post_tags"
ON "post_tags"."post_id" = "posts"."id"
LEFT JOIN "tags"
ON "post_tags"."keyword_id" = "tags"."id"
WHERE "tags"."name" IN ( 'sometag' )
// Loop over every module, which looks like
// {
// id: 1, reasons: [{ moduleId: 3 }]
// id: 2, reasons: [{ moduleId: 3 }]
// id: 3, reasons: []
// }
// and invert it to
// {
// 3: { dependencies: [ 1, 2 ] }
// }
localA = current_mesh.matrix_world.inverted() * Vector( ( 0, 0, 10 ) )
localB = current_mesh.matrix_world.inverted() * Vector( ( 0, 0, 0 ) )
current_mesh.ray_cast( localA, localB )
@AndrewRayCode
AndrewRayCode / example-bake.py
Created July 6, 2016 19:45
Blender Python script to bake in an ambient occlusion map offline
import bpy
ops = bpy.ops
scene = bpy.context.scene
mesh = bpy.ops.mesh
# Delete default scene objects
ops.object.select_all()
ops.object.select_all()
ops.object.delete()
@AndrewRayCode
AndrewRayCode / computeFaceCentroids.js
Last active December 7, 2020 03:13
Face centroids were removed from Three.js some time ago. These function modify faces **in place** to add a `.centroid` property, which a `Vector3` representing the center of that face. I've added an ES6 version as well for convenience if you're using ES6.
function computeFaceCentroids( geometry ) {
var f, fl, face;
for ( f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
face = geometry.faces[ f ];
face.centroid = new THREE.Vector3( 0, 0, 0 );
if ( face instanceof THREE.Face3 ) {
const react3 = <React3
ref="renderer"
mainCamera="camera"
width={ gameWidth }
height={ gameHeight }
onRendererUpdated={ this._onRenderUpdate }
antialias
>
<module
import React, { Component } from 'react';
import THREE from 'three';
export default class Wall extends Component {
shouldComponentUpdate( nextProps ) {
return ( nextProps.position !== this.props.position ) ||
( nextProps.rotation !== this.props.rotation ) ||
( nextProps.quaternion !== this.props.quaternion ) ||
<script dangerouslySetInnerHTML={{
__html: 'var appData = ' + JSON.stringify( this.props.appData ).replace( /<\/script/g, '<\\/script' ) + ';'
}} />
function _inspect2(input, depth) {
var maxDepth = 4;
var maxKeys = 15;
if (depth === undefined) {
depth = 0;
}
depth += 1;
// Webpack config for development
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var assetsPath = path.resolve(__dirname, '../static/dist');
var host = (process.env.HOST || 'localhost');
var port = parseInt(process.env.PORT) + 1 || 3001;
// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
var WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');