Skip to content

Instantly share code, notes, and snippets.

View raikusy's full-sized avatar
:electron:
Reacting 🌸

Rakibul Hasan raikusy

:electron:
Reacting 🌸
View GitHub Profile
@raikusy
raikusy / Inheritance.java
Last active June 13, 2017 20:16
Inheritance / Sub class + Super class in Java
class Student
{
String Name;
int Roll;
}
class Result extends Student
{
float Mark;
void buildResult(){
Name = "Rakibul Hasan";
@raikusy
raikusy / cOverloading.java
Last active June 13, 2017 20:15
Constructor Overloading / Copy Constructor in Java
class Student
{
String name;
int roll;
Student(String N, int R)
{
name = N;
roll = R;
}
Student(Student s)
@raikusy
raikusy / mOverloading.java
Last active June 13, 2017 20:15
Method Overloading in Java
class Over
{
public void add(int x, int y)
{
int sum = x + y;
System.out.println("Sum of integer numbers: " + sum);
}
public void add(float x, float y)
{
float sum = x + y;
import React from 'react';
import { Field, reduxForm } from 'redux-form';
import { Form, Icon, Button, Message } from 'semantic-ui-react';
import { LabelInputField } from 'react-semantic-redux-form';
import { Redirect } from 'react-router-dom';
import './Login.css';
const LoginForm = props => {
const { handleSubmit, loginData } = props;
if (loginData.loggedIn) {
componentDidMount() {
this.socket = io('http://localhost:3200');
this.socket.on('new_checkin', data => {
console.log('*** New Data Arrived! ***');
if (this.props.history.location.pathname !== '/business/discount') {
// When outside discount page, Discount Menu counter badge will show number of new data.
console.log('Outside Discount Page');
this.props.checkinCounter();
}
if (this.props.history.location.pathname === '/business/discount') {
/*
** These are two actions for user login & logout.
** login action makes a api POST request with email & password in body.
** The reponse contains user id, token & a unique socket channel for current user.
** example => response: { data: { channelName: 'uniqueChannel', id: 1, token: 'JWT-TOKEN' } }
** logout action makes a api GET request with
** user id & token in header.
*/
// See the socket middleware - https://gist.github.com/r4iku/bbe4c036afdffdc1ed73b3cedb8b4d3b
@raikusy
raikusy / socket--redux-middleware.js
Created July 11, 2018 18:12
A simple redux middleware for socket.io
// actions -> https://gist.github.com/r4iku/25bf72f7528ca6f226a578b0236c8ba8
const SOCKET_CONNECT = 'SOCKET_CONNECT';
const SOCKET_CLOSE = 'SOCKET_CLOSE';
export const socketIOMiddleware = socket => ({ dispatch, getState }) => next => action => {
if (action.type === SOCKET_CONNECT) {
// subscribe socket on channelName
// it dispatches an action whenever there
@raikusy
raikusy / callGf-v1.js
Created July 20, 2018 18:51
Call GF using javascript closure!
function callGf() {
var name = 'Jorina';
function calling() {
console.log('Calling ' + name + ' jaan...');
}
calling();
}
callGf();
@raikusy
raikusy / callGf-v2.js
Last active July 20, 2018 19:36
Calling GF using actual closure!
function callGf() {
var name = 'Jorina';
return function() {
console.log('Calling ' + name + ' jaan...');
}
}
var calling = callGf();
calling();
// same as doing: callGf()();
function showCallback(item) {
return function() {
showCalling(item.calling);
showInfo(item.info);
}
};