Skip to content

Instantly share code, notes, and snippets.

View rohanBagchi's full-sized avatar

Rohan Bagchi rohanBagchi

View GitHub Profile
mutation AddUser {
insert_users(objects: {id: "user-id-1101", name: "Rohan Bagchi", email: "[email protected]"}) {
returning {
id
email
name
}
}
}
function Employee(name, age, emp_id) {
this.name = name;
this.age = age;
this.emp_id = emp_id;
}
function Accountant(name, age, emp_id) {
Employee.call(this, name, age, emp_id);
this.role = "accountant";
}
class Employee {
String name;
int age;
String emp_id;
public Employee(String name, int age, String emp_id) {
this.name = name;
this.age = age;
this.emp_id = emp_id;
}
@rohanBagchi
rohanBagchi / useOutsideClickHandler.ts
Last active March 28, 2019 06:28
Handling outside click with hook
import React, { useEffect } from 'react';
import get from 'lodash/get';
import noop from 'lodash/noop';
interface useOutsideClickHandlerProps {
node: any, // reference to top level node / element in the collapsible component.
onOutsideClick: (data?: any) => void,
onInsideClick?: (data?: any) => void,
}
@rohanBagchi
rohanBagchi / InnerFormField.tsx
Last active March 21, 2019 06:33
For Medium
const getNameFieldValue = (data: any) => data.foo;
const shouldReinitialize = () => !props.shouldReinitialize;
<InnerField
fieldData={innerFieldData}
getFieldValue={getNameFieldValue}
shouldReinitialize={shouldReinitialize}
>
{({ handleChange: innerHandleChange, value }: any) => {
return (
const innerFieldData = {
id: props.selectedItem.id,
...values, // formik's form field values
};
const getFieldUniqueId = (data: any) => data.id;
<InnerField
fieldData={innerFieldData}
getFieldValue={(innerFieldData: any) => innerFieldData['itemDescription']}
import React, { useState, useEffect } from "react";
interface ChildrenPropType {
handleChange: (e: any) => void,
value: string
}
interface PropType {
fieldData: any,
shouldReinitialize: (data: any) => Boolean,
router.get('/download', function(req, res) {
res.set('Content-Disposition', 'attachment; filename=Some Fancy Data.xls')
res.set('Access-Control-Expose-Headers', 'Content-Disposition,X-Suggested-Filename')
res.json(downloadData);
});
<!-- Code for Action: MedLife - Universal Pixel - Test Campaign -->
<!-- Begin Sizmek DSP Conversion Action Tracking Code Version 9 -->
<script type='text/javascript'>
(function() {
var w = window, d = document;
var s = d.createElement('script');
s.setAttribute('async', 'true');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', '//c1.rfihub.net/js/tc.min.js');
var f = d.getElementsByTagName('script')[0];
(() => {
const btn = document.getElementById("calculate_btn");
const res = document.getElementById("result");
btn.addEventListener("click", e => {
res.innerHTML = "Loading...";
const val = doLongCalculation();
const shortenedData = val.slice(0, 50).join(", ") + "...";
res.innerHTML = shortenedData;
});
})();