Skip to content

Instantly share code, notes, and snippets.

View milosdakic's full-sized avatar

Milos Dakic milosdakic

View GitHub Profile
@milosdakic
milosdakic / article.blade.php
Created December 8, 2017 05:55
Tailwind - Article
<article class="w-full sm:w-1/2 md:w-1/3 mb-6">
<header>
<h1 class="font-thin mb-2">Article title</h1>
<p class="text-grey mb-4">Written by Walter Bishop on <time datetime="2070-05-25 19:00">25 May 2070</time>. Posted in News</p>
</header>
<section>
<h2 class="font-thin mb-4">The observers are coming. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi.</h2>
<p class="text-grey-darkest">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</section>
</article>
<?php
class AdvancedUser extends User
{
public function type()
{
return 'advanced';
}
}
@milosdakic
milosdakic / README.md
Created September 26, 2017 06:26
React Dynamic Component Renderer (with Feature Flags)

React Dynamic Component Renderer (with Feature Flags)

This is a simple implementation of a React dynamic component renderer. The aim here is to allow progresive rendering of React components onto a static HTML page/site. Usually used to sprinkle React components on top of an existing site.

Usage

The functionality has three main properties that need to be passed to the render method for this to work.

  1. node - this specifies which node the component should be mounted to
  2. component - the component thats being mounted
  3. features (optional) - determine based on features if this component should be mounted
@milosdakic
milosdakic / axios-shared-token.js
Created September 26, 2017 01:25
Shared Token
import Rx from 'rx-lite'
import Axios from '../../utils/axios'
const subject = new Rx.ReplaySubject(1)
export default () => {
Rx.Observable.fromPromise(Axios.get('/api/storefront/cart/gettoken'))
.take(1)
.share()
.subscribe(subject.onNext)
@milosdakic
milosdakic / index.js
Last active August 23, 2017 05:34
React Render Multiple Components using Rx
import render from './utils/render'
const map = [
{
node: '.root',
component: Component,
},
]
render(map).subscribe(console.log('React rendered all components'))
@milosdakic
milosdakic / component.js
Created July 7, 2015 04:44
React ES6 Component Skeleton
import React, { Component, PropTypes } from 'react';
export default class Awesome extends Component {
render() {}
}
@milosdakic
milosdakic / skeleton.js
Created June 4, 2015 07:20
React Component Skeleton
var Component = React.createClass({
displayName: 'ComponentName',
propTypes: {},
getDefaultProps: function() {},
getInitialState: function() {},
componentWillReceiveProps: function(nextProps) {}
componentWillMount: function() {},
@milosdakic
milosdakic / mutliview.js
Created January 19, 2014 03:01
Express.js multi folder views
var path = require('path')
, fs = require('fs')
, utils = require('./utils')
, dirname = path.dirname
, basename = path.basename
, extname = path.extname
, exists = fs.existsSync || path.existsSync
, join = path.join;
module.exports = function(app) {
@milosdakic
milosdakic / gist:6809627
Created October 3, 2013 13:14
sequelize associations issue
module.exports = function(State, Country) {
var data = require('../db/au.json');
// Create states
State.bulkCreate(data).done(function() {
// Find all newly added states where country associations is not set.
State.findAll({ where: { countryId: null }}).done(function(states) {
// Find the country we want to associate this with
Country.find({ where: { name: 'Australia' }}).success(function(australia) {
@milosdakic
milosdakic / sequelize-mixins.js
Created September 5, 2013 08:34
Sequelize model mixins
var User = sequelize.define('User', {
name: Sequelize.STRING
}, {
// define the mixins you want to include
// could be similar to sequelize.import()
mixins: [
'CreatedAt',
...
]
] });