Skip to content

Instantly share code, notes, and snippets.

View ralyodio's full-sized avatar

ralyodio

  • Los Gatos, CA
View GitHub Profile
//middleware
app.use(function(req, res, next){
if ( req.session.user ) {
req.session.logged_in = true;
}
res.locals.message = req.flash();
res.locals.session = req.session;
res.locals.q = req.body;
res.locals.err = false;
next();
#foo {
font-family: sans-serif;
width: 200px;
height: 200px;
background: #fff;
border: 1px solid #999;
border-radius: 5px;
position: relative;
}
@ralyodio
ralyodio / webservice.js
Created May 21, 2015 09:43
Web service for aurelia.
import {inject} from 'aurelia-framework';
import {Config} from '../config';
import {HttpClient} from 'aurelia-http-client';
@inject (Config, HttpClient)
export class WebService {
constructor (config, http) {
this.config = config;
this.http = http;
//this.http = http.configure(x => {
@ralyodio
ralyodio / model.js
Created May 31, 2015 08:10
Thinky model definition
var cfg = require('../../config');
var thinky = require('thinky')(cfg.db);
var type = thinky.type;
var r = thinky.r;
// Create a model - the table is automatically created
var Thing = thinky.createModel("Thing", {
id: type.string(),
title: type.string(),
createdAt: type.date().default(() => {
$ rethinkdb
Recursively removing directory /Users/username/projects/myapp/myapp-web/rethinkdb_data/tmp
Initializing directory /Users/username/projects/myapp/myapp-web/rethinkdb_data
Running rethinkdb 2.0.2 (CLANG 6.1.0 (clang-602.0.53))...
Running on Darwin 14.3.0 x86_64
Loading data from directory /Users/username/projects/myapp/myapp-web/rethinkdb_data
Listening for intracluster connections on port 29015
Listening for client driver connections on port 28015
Listening for administrative HTTP connections on port 8080
Listening on addresses: 127.0.0.1, ::1
@ralyodio
ralyodio / controller.js
Created June 14, 2015 05:17
thinky hasAndBelongsToMany
ctrl.post = function *(next){
var data = this.request.body;
var tagIds = data.tags.map(tag => {
return tag.id;
});
delete data.tags;
var post = new Post(data);
<form submit.delegate="onSubmit()">
<fieldset>
....
</fieldset>
<nav>
<button type="button" click.delegate="onDelete()">Delete</button>
<button>Submit</button>
</nav>
</form>
//usage
app.controller('ChatCtrl', ['socket', function(socket){
socket.on('chat:messages', function(data){
$log.log('chat:messages', data);
$scope.messages = data.messages;
});
}]);
nvm install v10
npm i -g @vue/cli
vue create <project>
#nothing happens
@ralyodio
ralyodio / .about+license.md
Created September 10, 2018 05:33 — forked from anilnairxyz/.about+license.md
Candlestick Chart

A zoomable candlestick chart.

Copyright © 2015, Anil Nair - MIT License