Skip to content

Instantly share code, notes, and snippets.

mport React from 'react'
const withPusher = WrappedComponent => {
class WithPusher extends React {
subscribeToChannel() {
const channelName = getChannelName();
subscribeToChannel(channelName);
}
<script type="text/javascript"><!--{literal}>
function getVisitor() {
console.log('getVisitorCalled');
var visitorInput = document.getElementById('ID_form79fea66b_guest_register_receipt_visitor');
var visitor = visitorInput && visitorInput.value;
return visitor;
}
function redirectToVisitorPage() {
console.log('redirect called.');
// Imperative way
const getNames = users => {
const activeUsers = users.filter(user => user.isActive);
return activeUsers.map(user => user.userName)
}
// Using pure functions.
import {map, filter, compose} from 'ramda'
const isUserActive = user => user.isActive;
const getUserName = user => user.userName;
const getNames = compose(map(getUserName), filter(isUserActive)
const add => (x, y) => x + y;
class Bar {
printHello() {
console.log('Hello')
}
}
class Foo {
printHello = () => {
console.log('Hello')
}
}
import React from 'react';
const Button = props => (
<div onClick={props.onActive}>
Click Me
</div>
)
export default Button
import React, {Component} from 'react';
import Table from './Table';
import Card from './Card';
class Controller extends Component {
state = {
view: 'list'
}
switchToCardView = () => {
$category = array('0' => 'Cultural', '1' => 'Technical', '2' => 'Sports');
echo $this->Form->input('category', array('type' => 'select', 'options' => $category));
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com