Skip to content

Instantly share code, notes, and snippets.

DROP TABLE example;
CREATE TABLE example (
primary_id int PRIMARY KEY IDENTITY,
id int,
name varchar(20),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME,
active int
);
@CloCkWeRX
CloCkWeRX / gist:4552043
Created January 16, 2013 23:34
Have a data set with a 'parent' and 'child' column, storing paths through a tree (see http://fungus.teststation.com/~jon/treehandling/TreeHandling.htm for the modelling). At the moment, there's a stored proc that takes exactly one ID and builds a data set like the below. Trying to neatly re-write this as a view, so that I can simply add in the "…
SELECT
*
FROM data
WHERE id IN(
SELECT @id
UNION
SELECT child_id FROM paths WHERE parent_id = @id
)
var http = require('http')
, os = require('os')
, url = require('url')
// , SSDP = require('../steward/node_modules/node-ssdp')
, netmask = require('../steward/node_modules/netmask')
, xml2json = require('../steward/node_modules/xml2json')
;
'use strict';
var dgram = require('dgram')
var http = require('http')
, os = require('os')
, url = require('url')
, SSDP = require('../steward/node_modules/node-ssdp')
, netmask = require('../steward/node_modules/netmask')
, xml2json = require('../steward/node_modules/xml2json')
;
SSDP.prototype.notify = function(ifname, ipaddr, portno, signature, vars) {/* jshint unused: false */
@CloCkWeRX
CloCkWeRX / Apple-logo-300x300.png
Last active January 3, 2016 01:49
thingsystem - front page
Apple-logo-300x300.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@CloCkWeRX
CloCkWeRX / current destroy photo
Last active November 30, 2016 02:17
Managing sets of relationships with an Operation
PhotosController
def destroy
@photo = Photo.find(params[:id])
@photo.destroy
end
Planting
before_destroy do |planting|
photolist = planting.photos.to_a # save a temp copy of the photo list
planting.photos.clear # clear relationship b/w planting and photo