Skip to content

Instantly share code, notes, and snippets.

import hashlib as hasher
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
self.hash = self.hash_block()
<?php
/**
* BuddyPress User Blog - Post Create
*
* @package WordPress
* @subpackage BuddyPress User Blog
*/
$theme = wp_get_theme(); // gets the current theme
$theme_name = $theme->template;
import React, { Component, Fragment } from 'react'
import {
NavLink,
Link,
BrowserRouter as Router,
Route,
Switch,
Redirect,
} from 'react-router-dom'
import FeedPage from './FeedPage'
@jkhaui
jkhaui / metakey.php
Last active November 13, 2018 08:14
add_action( 'graphql_init', function() {
add_filter( 'graphql_user_fields', function( $fields ) {
$fields['userBadges'] = [
'type' => \WPGraphQL\Types::String(),
'description' => __( 'The badges of the user', 'gqlbadges' ),
'resolve' => function( \WP_User $user ) {
// $user = new WP_User($user->ID);
// Or...
<?
php
class SubscriptionType extends \WPGraphQL\Type\WPObjectType {
private static $fields;
public function __construct() {
$config = [
'name' => 'SubscriptionType',
<?php
class SubscriptionType extends \WPGraphQL\Type\WPObjectType {
private static $fields;
public function __construct() {
$config = [
'name' => 'SubscriptionType',
'fields' => self::fields(),
import React, { Component } from 'react' ;
import {
NavLink,
withRouter
} from 'react-router-dom';
import { ApolloProvider } from 'react-apollo';
import ApolloClient from 'apollo-boost';
import { Query } from 'react-apollo';
import { bitesQuery } from './Query';
import Pagination from 'components/Pagination/pagination.js'
$fields['seriesPart'] = [
'type' => \WPGraphQL\Types::int(),
'description' => __( 'The number of the post within its series.' ),
'resolve' => function( \WP_Post $post ) {
$series_number = get_post_meta( $post->ID, '_series_part', true );
return ! empty ( $series_number ) ? $series_mumber : null;
},
];
<?php
namespace Medium;
class Citation {
const SHORTCODE = 'medium-editor';
private $url;
public function __construct()
{
ini_set( 'display_errors', 1 );
import React, { Component } from 'react';
import { Form } from 'semantic-ui-react';
class Filter extends Component {
constructor(props) {
super(props);
this.state = {
searchTerm: ''
}
this.updateSearchTerm = this.updateSearchTerm.bind(this);