Skip to content

Instantly share code, notes, and snippets.

@sdepold
sdepold / travis.sh
Last active October 29, 2015 20:00
io.js on travis
if [ ! -z "$IOJS" ] && [ "$IOJS" != "false" ]; then
echo "Installing io.js v$IOJS ..."
curl -s https://iojs.org/dist/v$IOJS/iojs-v$IOJS-linux-x64.tar.xz > iojs-v$IOJS-linux-x64.tar.xz
tar xf iojs-v$IOJS-linux-x64.tar.xz
export PATH="$(pwd)/iojs-v$IOJS-linux-x64/bin/:$PATH"
echo "Installation successful"
else
echo "Using node..."
fi
@sdepold
sdepold / app.js
Last active August 29, 2015 14:13
Multi instance setup for sequelize
var dbAdmin = require('./db/admin.js');
var dbNormal = require('./db/normal.js');
var dbSomethingElse = require('./db/something-else.js');
@sdepold
sdepold / virtual-attributes.js
Created October 29, 2013 18:24
virtual attributes with sequelize
var Sequelize = require('sequelize')
, sequelize = new Sequelize('sequelize_test', 'root')
var User = sequelize.define('User', {
username: Sequelize.STRING,
password_hash: Sequelize.STRING
}, {
validate: {
password: function(next) {
if (((this._password || "").trim() !== '') && (this._password === this._password_confirmation)) {
var Sequelize = require('sequelize')
, sequelize = new Sequelize('sequelize_test', 'root')
var Manufacturer = sequelize.define('manufacturer', {
name: Sequelize.STRING
});
var GraphicsCard = sequelize.define("graphics_card", {
model: Sequelize.STRING,
RAM: Sequelize.INTEGER
fn get_path_to(target: & str, opt: Option<&str>) -> Path {
let path: ~str = match target {
"root" => {
os::homedir().unwrap().to_str() + "/.rsvm"
}
"version" => {
get_path_to(~"root", None).to_str() + ~"/v" + opt.unwrap()
}
fn get_rsvm_directory() -> ~str {
os::homedir().get_ref().to_str() + "/.rsvm"
}
@sdepold
sdepold / customeventemitter
Created October 4, 2012 17:38
sequelize => customeventemitter <-> querychainer
var Sequelize = require('sequelize')
new Sequelize.Utils.CustomEventEmitter(function(e) {
e.emit('success', 'asd')
}).run().success(function(data) {
console.log(data)
})
var options = db.define('options',
{
type: s.STRING,
type_id: s.INTEGER,
sort: s.INTEGER,
deleted: s.BOOLEAN,
hidden: s.BOOLEAN,
field1: s.STRING,
field2: s.STRING,
field3: s.STRING,
var chainer = new Sequelize.Utils.QueryChainer()
Artist.find({ where: {name: name} }).success(function(artist) {
if (artist) {
// get all tracks
artist.getTracks().success(function (tracks) {
if (tracks.length > 0) {
tracks.forEach(function(track) {
chainer.add(track.getArtists())
})
@sdepold
sdepold / LICENSE.txt
Created August 15, 2012 05:50 — forked from 140bytes/LICENSE.txt
140byt.es -- addObserverMethods
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Sascha Depold http://depold.com
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE