Skip to content

Instantly share code, notes, and snippets.

@Janekk
Janekk / AuthenticatedPageHOC.js
Created September 25, 2017 11:48
Higher Order Compoennt - AuthenticatedPage
import React from 'react';
import {connect} from 'react-redux';
import _ from 'lodash';
/**
* Higher ordered component for pages requiring authentication.
*/
const AuthenticatedPage = (PageComponent) => {
class AuthenticatedPageHOC extends React.Component {
componentWillReceiveProps(nextProps) {
@Janekk
Janekk / test_create_project.py
Created September 25, 2017 09:23
test_create_project.py
from pathlib import Path
import pytest
import time
from selenium.webdriver.common.keys import Keys
pytestmark = pytest.mark.django_db
@pytest.mark.volatile
class TestCreateProject:
@Janekk
Janekk / node_example_async_await.js
Last active September 25, 2017 11:17
node_example_handling_async
export async function getCardPage(req, res, next) {
try {
const query = parseCardQuery(req.query);
const cardId = req.params.id;
const [card, campaign] = await Promise.all([
CardApi.getCard(cardId),
getCardCampaign(cardId, query.campaignId)
]);
@Janekk
Janekk / jquery-sharify.js
Last active June 15, 2016 19:43
Social share buttons based on Font Awesome (G+, Facebook, Twitter, LinkedIn, Pinterest, SU); jQuery plugin + CSS; demo: http://jsfiddle.net/jkacalak/tko8vevv/
$(function () {
var shareUrl = document.location.origin + document.location.pathname;
var knownButtons = ['google-plus', 'twitter', 'pinterest', 'facebook', 'stumbleupon', 'linkedin'];
/**
* jQuery plugin - create share buttons
*
* @param {Object} [options]
* @param {string[]} [options.buttons] - list of share buttons to be shown
* @param {string} [options.url] - shared URL (by default current)
@Janekk
Janekk / index.html
Last active August 29, 2015 13:59
Drag&Drop using React
<div id="main"/>
<script type="text/jsx">
/** @jsx React.DOM */
var DragItem = React.createClass({
drag: function(ev) {
ev.dataTransfer.setData("draggedItem", JSON.stringify(this.props.item));
},
render: function () {
return (<div draggable="true" onDragStart={this.drag} className="item">{this.props.item.text}</div>);
}