Skip to content

Instantly share code, notes, and snippets.

@nihaux
nihaux / gist:c02d61f6572d6531b60c
Created September 10, 2014 18:18
server.js for mean.js app with socket.io - problem
'use strict';
/**
* Module dependencies.
*/
var init = require('./config/init')(),
config = require('./config/config'),
mongoose = require('mongoose');
/**
* Main application entry file.
@nihaux
nihaux / gist:05041ff4a33f0f5c7508
Created September 10, 2014 18:22
mean.js layout to test socket.io
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{{title}}</title>
<!-- General META -->
<meta charset="utf-8">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@nihaux
nihaux / question
Last active August 29, 2015 14:13
mongoose schemas
'use strict';
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
_ = require('lodash'),
async = require('async');
ThemeDoc.collection.find({_id: mongoose.Types.ObjectId(themeId)}, {}, {'limit': 1}).toArray(function (err, themes) {
//console.log(themes);
if (themes.length == 1) {
QuestionDoc.collection.find({'theme': mongoose.Types.ObjectId(themeId)}, {}, {'limit': 3}).toArray(function(err, questions) {
//console.log(questions);
if(questions.length == 3) {
@nihaux
nihaux / router5immutableReducer.js
Last active September 12, 2016 14:38
router5immutableReducer.js
import { actionTypes } from 'redux-router5';
import { Record } from 'immutable';
// eslint-disable-next-line new-cap
const State = Record({
route: null,
previousRoute: null,
transitionRoute: null,
transitionError: null,
});
@nihaux
nihaux / store-enhancer.js
Created September 18, 2016 14:29
redux-little-router quick&dirty patch immutable js
return function (createStore) {
return function (reducer, initialState, enhancer) {
var enhancedReducer = function enhancedReducer(state, action) {
//immutable
var vanillaState = state.delete('router');
var newState = reducer(vanillaState, action);
// Support redux-loop
import React from 'react';
class EmbedIframe extends React.Component {
resizeIframe = () => {
const height = Math.max(this.props.minHeight, this.iframe.contentWindow.document.body.offsetHeight);
this.iframe.height = `${height}px`;
}
componentDidMount = () => {
import React, { Component } from 'react';
import Editor, { createEditorStateWithText, PluginProvider } from 'draft-js-plugins-editor'; // eslint-disable-line import/no-unresolved
import createInlineToolbarPlugin from 'draft-js-inline-toolbar-plugin'; // eslint-disable-line import/no-unresolved
import editorStyles from './editorStyles.css';
const inlineToolbarPlugin = createInlineToolbarPlugin();
const { InlineToolbar } = inlineToolbarPlugin;
const plugins = [inlineToolbarPlugin];
const text = 'In this editor a toolbar shows up once you select part of the text …';
util.py[DEBUG]: Failed running /var/lib/cloud/instance/scripts/part-001 [1]#012Traceback (most recent call last):#012 File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 711, in runparts#012 subp(prefix + [exe_path], capture=False)#012 File " /usr/lib/python3/dist-packages/cloudinit/util.py", line 1684, in subp#012 cmd=args)#012cloudinit.util.ProcessExecutionError: Unexpected error while running command.#012Command: ['/var/lib/cloud/instance/scripts/part-001']#012Exit code: 1#012Reason: -#012Stdout: ''#012Stderr: ''
2155 Feb 7 11:59:27 ip-172-23-128-217 [CLOUDINIT] cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2156 Feb 7 11:59:27 ip-172-23-128-217 [CLOUDINIT] handlers.py[DEBUG]: finish: modules-final/config-scripts-user: FAIL: running config-scripts-user with frequency once-per-instance
2157 Feb 7 11:59:27 ip-172-23-128-217 [CLOUDINIT] util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user
import { call, put, takeEvery } from 'redux-saga/effects'
// every time a FETCH_USER_INFO action is dipatched, the function fechtUserInfo will be called
function* watchFetchUserInfo() {
yield takeEvery(FETCH_USER_INFO, fetchUserInfo);
}
function* fetchUserInfo (action) {
try {
// tell redux-saga => call this functions and once done put them in pictureResponse, infoResponse