Skip to content

Instantly share code, notes, and snippets.

View c0d0g3n's full-sized avatar

Bruno c0d0g3n

View GitHub Profile
@c0d0g3n
c0d0g3n / Terminal output
Last active December 2, 2016 17:21
ghostServer.restart() error
gulp test
[17:45:21] Using gulpfile ~/Bureaublad/dev/crosshair/http/gulpfile.js
[17:45:21] Starting 'test'...
[17:45:21] Finished 'test' after 7.07 ms
Ghost is running in development...
Listening on 127.0.0.1:2368
Url configured as: http://localhost:2368
Ctrl+C to shut down
Ghost is closing connections
Unhandled rejection TypeError: rootApp.listen is not a function
@c0d0g3n
c0d0g3n / docpad.coffee
Last active January 1, 2017 12:57
Alter Marked's markdown rendering behavior in DocPad
@c0d0g3n
c0d0g3n / apache.md
Last active January 5, 2017 18:26
Apache manual install on Windows: Checklist

Based on: https://www.sitepoint.com/how-to-install-apache-on-windows/ (outdated)

Install Apache

Donwload binary and requirements

Unzip the binary anywhere you want apache installed

Note apache is configured to run under c:\name_of_folder_in_zip, if you install apache anywhere else, you should search the config file for c:\name_of_folder_in_zip and replace with your install directory.

Install as a windows process

@c0d0g3n
c0d0g3n / bug.js
Last active April 30, 2017 15:36
Mongoose bug: SchemaType Boolean tries to convert input
mongoose = require("mongoose")
mongoose.connect("mongodb://localhost/bug")
let db = mongoose.connection
db.on('error', (err) => {
return console.error('Connection error:', err)
})
testSchema = mongoose.Schema({
test: {
@c0d0g3n
c0d0g3n / bug.js
Created May 2, 2017 18:20
Bug: Mongoose pre validate sub doc middleware Unhandled Rejection
let mongoose = require('mongoose')
let Promise = require('bluebird')
mongoose.Promise = Promise
mongoose.connect("mongodb://localhost/bug")
let db = mongoose.connection
db.on('error', (err) => {
return console.error('Connection error:', err)
})
@c0d0g3n
c0d0g3n / help.js
Created May 3, 2017 16:28
Explaining how Mongoose setters work
// dependencies
let mongoose = require('mongoose')
let Promise = require('bluebird')
mongoose.Promise = Promise
// connect to local db help
mongoose.connect("mongodb://localhost/help")
let db = mongoose.connection
db.on('error', (err) => {
return console.error('Connection error:', err)
@c0d0g3n
c0d0g3n / findFiles.js
Last active February 15, 2019 09:45
Recursively find files in a directory using Bluebird promises
const Promise = require('bluebird')
const fs = require('fs')
Promise.promisifyAll(fs)
const path = require('path')
// Usage:
// const findFiles = require('path/to/findFiles.js')
// findFiles('dir/to/search/in')
// Arg 'files' is used to propagate data of recursive calls to the initial call
// If you really want to, you can use arg 'files' to manually add some files to the result
// components/ComponentExample.js
import React from 'react'
import {connect} from 'react-redux'
import endpointExample from '../endpoints/endpointExample.js'
@connect((state, props) => {
return {
example: endpointExample(state, props)
}
@c0d0g3n
c0d0g3n / clickStream.js
Created July 20, 2017 19:00
Turn React events into rxjs streams (example: single click, double click...)
// stream of clicks
// onClick should call this.handleClick.bind(this) for it to work
const click$ = Observable
.create((observer) => {
// method puts clicks into stream
this.handleClick = (event) => {
observer.next(event)
}
})
.share() // allow multiple branches
@c0d0g3n
c0d0g3n / MuteClicksComponent.jsx
Created July 29, 2017 13:21
Little HOC that stops event propagation (also prevents default behavior of link/button/... if `strict="true"` is passed)
import React from 'react'
export default class MuteClicksComponent extends React.Component {
handleClick (childClickHandler) {
return (e) => {
e.stopPropagation()
// also prevent child link/button/... from working if neccesary
if (this.props.strict) e.preventDefault()