Skip to content

Instantly share code, notes, and snippets.

View neroze's full-sized avatar
🎯
Focusing

Jumper neroze

🎯
Focusing
View GitHub Profile
if ( class_exists( 'WPBakeryShortCodesContainer' ) ) {
class WPBakeryShortCode_Team_Wrapper extends WPBakeryShortCodesContainer {
}
}
if ( class_exists( 'WPBakeryShortCode' ) ) {
class WPBakeryShortCode_Team_Mate extends WPBakeryShortCode {
}
}
@neroze
neroze / wp-get_id_by_slug
Created March 14, 2017 08:15 — forked from davidpaulsson/wp-get_id_by_slug
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
@neroze
neroze / wp-get_id_by_slug
Created March 14, 2017 08:15 — forked from davidpaulsson/wp-get_id_by_slug
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
@neroze
neroze / SpecRunner.js
Created June 9, 2017 09:37 — forked from michaelcox/SpecRunner.js
Browser Unit Testing with Backbone Mocha Chai and RequireJS
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'
@neroze
neroze / high-order-functions
Created June 20, 2017 08:14
Javascript High Order Functions
// simple first class function
var fire = (name) => {
console.log(name)
}
// A new high order function which accepts another function as its parameter and
// calls another function with parameter which will be again passed on to high other order function as its parameter
var fireman = (method) => (firingObject) => {
method(firingObject)
const mapStateToProps = (state) => ({ user: state.user });
const User = connect(mapStateToProps)(({ user }) =>
<div className="User" > { user.name } - { user.status } </div>
);
const App = () =>
<div className="App">
<User />
</div>
import React from 'react';
import {
compose,
setDisplayName,
setPropTypes,
withState,
withHandlers,
lifecycle,
mapProps
@neroze
neroze / with-withState-withHandlers
Created June 20, 2017 10:11
with-withState-withHandlers
import React from 'react';
import {
compose,
setDisplayName,
setPropTypes,
withState,
withHandlers
} from 'recompose'
const {Component} = React;
@neroze
neroze / lifecycle-compose-recompose
Last active June 20, 2017 11:39
Loading .. lifecycle compose recompose
import React from 'react';
const { Component } = React;
import { compose, lifecycle, branch, renderComponent, withState } from 'recompose';
function fetchData(){
return new Promise((resolve) => {
setTimeout(() => resolve({
name: 'superman ',
@neroze
neroze / simple-node-server-with-webpack-middleware
Created June 21, 2017 04:29
Simple node server with webpack middleware
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.config');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true
}).listen(5050, 'localhost', (err) => {
if (err) {