Skip to content

Instantly share code, notes, and snippets.

View musawirali's full-sized avatar
:octocat:
Building

Musawir Shah musawirali

:octocat:
Building
View GitHub Profile
Verifying my Blockstack ID is secured with the address 1LHMkw9himmh1E3xWoyAUnzzpN4uG3TKtX https://explorer.blockstack.org/address/1LHMkw9himmh1E3xWoyAUnzzpN4uG3TKtX
@musawirali
musawirali / client.go
Created March 22, 2017 19:39
preact-rpc Go client
package main
import (
"fmt"
"net/http"
"github.com/musawirali/preact-rpc/goclient"
)
// HTTP request handler
@musawirali
musawirali / request.js
Created March 22, 2017 19:33
preact-rpc request
const request = {
id: 1, // Some number that uniquely identifies a request
component: 'hello', // The name of the component as registered in Javascript
props: { // The props to pass to the component to be rendered
toWhat: 'World',
},
};
preact-rpc --bundle=./Component.js --port=tmp/server.sock
@musawirali
musawirali / Component.js
Created March 22, 2017 19:20
Registered React component
import React from 'react';
import { registerComponent } from 'preact-rpc';
// A simple React component
class Hello extends React.Component {
render() {
return React.createElement('div', null, `Hello ${this.props.toWhat}`);
}
}
@musawirali
musawirali / Component.js
Last active March 22, 2017 19:12
A simple React component
import React from 'react';
// A simple React component
class Hello extends React.Component {
render() {
return React.createElement('div', null, `Hello ${this.props.toWhat}`);
}
}
@musawirali
musawirali / api_controller.rb
Created November 27, 2016 23:00
Working file
class ApiController < ApplicationController
# Will not be exchanging CSRF token, not doing any API auth either.
skip_before_filter :verify_authenticity_token
def update_name
name = params[:name]
return render json: {error: 'Invalid name'} if name.blank? || name.match(/[a-z0-9]+/i).to_s != name
# TODO: check for valid URL
url = params[:url]

Keybase proof

I hereby claim:

  • I am musawirali on github.
  • I am musawir (https://keybase.io/musawir) on keybase.
  • I have a public key whose fingerprint is 3B14 C1F3 9E72 F7E8 81CC EC4E 586B E11C FC7A 6B05

To claim this, I am signing this object:

= javascript_include_tag "webpack/my_app-bundle"
# ReactOnRails config
ReactOnRails.configure do |config|
# This is a manifest file of all the components that we need to have server-side rendering for
config.server_bundle_js_file = "app/assets/javascripts/webpack/react_server-bundle.js"
end