Skip to content

Instantly share code, notes, and snippets.

function placeCaretAtEnd(el) {
el.focus();
if (typeof window.getSelection != "undefined"
&& typeof document.createRange != "undefined") {
var range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
var filterTaskInAsset = (function() {
// Private variables
var expandedAsset = {},
assetStore = {},
loadMoreHref = null,
list = null,
currentStatus = null;
// Cache asset's properties
function insertAssetStates(assetId, assetObj) {
@kilgarenone
kilgarenone / keybase.md
Created October 18, 2016 09:25
Verify my identity on github for keybase.io

Keybase proof

I hereby claim:

  • I am kilgarenone on github.
  • I am kilgarenone (https://keybase.io/kilgarenone) on keybase.
  • I have a public key whose fingerprint is 0C7F 36F9 D181 5034 BE9E 3671 C928 0A46 64AF F2EB

To claim this, I am signing this object:

@kilgarenone
kilgarenone / md-select.html
Created May 22, 2017 07:25
<md-select> with key search for specific option
<md-select [formControl]="selectFormControl"
(click)="detectKeys()"
[required]="isRequired"
[disabled]="isDisabled"
[attr.role]="'listbox'"
[attr.aria-labelledby]="placeholder"
placeholder="placeholder">
<md-option #selectBox *ngFor="let option of options"
[class.inFocus]="searchedOptionValue == option.value"
[value]="option.value">{{option.description}}
@kilgarenone
kilgarenone / api.service.ts
Last active October 24, 2017 06:32
Angular2 + RxJS: Call refresh token api to get a new access token and then automatically retry the previous http request with the new access token
export interface RebuildRequest {
type: string;
args: {
path: string;
body?: string;
opt: RequestOptions;
}
};
// a http request method
@kilgarenone
kilgarenone / git.md
Last active May 5, 2018 05:23
Proposal: Git Workflow

Git Workflow

Git workflow diagram

This doc covers the workflow among the developers with respect to development, product release, and hotfixes.

So, we have a repo which has two major branches:

  • master
  • develop
@kilgarenone
kilgarenone / ReactClass.md
Last active June 21, 2018 07:28
Rundown of a React Component Class in Typescript
import * as React from 'react'
import { connect } from 'react-redux'

// props that you pass in from the parent component
interface ExposedProps {
  someExposedProp?: any,
}
/*
 The 'someStateSelector' method could be a 'reselect' type of selector.
@kilgarenone
kilgarenone / redux-form-yup.ts
Last active April 24, 2020 03:07
yup in a redux-form component
import * as React from 'react'
import * as Yup from 'yup'
import { Field, reduxForm } from 'redux-form'
import validator from './validator.ts'
// more imports
class YourClass extends React.Component<Props> {
// stuffs
render() {
@kilgarenone
kilgarenone / axios.ts
Created July 19, 2018 06:53
axios mock file
// src/__mocks__/axios.ts
const mockAxios = jest.genMockFromModule('axios')
// this is the key to fix the axios.create() undefined error!
mockAxios.create = jest.fn(() => mockAxios)
export default mockAxios
@kilgarenone
kilgarenone / radioBtnReact.jsx
Last active October 26, 2018 12:58
Simple and standard radio button with SVG
import * as React from "react";
import { css, cx } from "react-emotion";
const cssRadioButton = css`
font-size: 17px;
.label {
cursor: pointer;
border-radius: 12px;
color: #757575;