Skip to content

Instantly share code, notes, and snippets.

View reslear's full-sized avatar
🎉

reslear

🎉
View GitHub Profile
@reslear
reslear / SpaceToUnderscore.ts
Created December 24, 2021 07:51
Space To Underscore type infer
View SpaceToUnderscore.ts
const Names = [
'Event Update'
]
type ToUnderscore<V extends string> = V extends `${infer S} ${infer E}`
? `${S}_${ToUnderscore<E>}`
: V
type TNames<N extends string> = { [K in N as Uppercase<ToUnderscore<N>>]: K }
View 📊 Weekly development breakdown
Vue.js 11 hrs 29 mins ███████████▊░░░░░░░░░ 56.5%
TypeScript 6 hrs 10 mins ██████▍░░░░░░░░░░░░░░ 30.4%
Other 1 hr 31 mins █▌░░░░░░░░░░░░░░░░░░░ 7.5%
Markdown 28 mins ▍░░░░░░░░░░░░░░░░░░░░ 2.4%
YAML 18 mins ▎░░░░░░░░░░░░░░░░░░░░ 1.5%
@reslear
reslear / function.php
Last active March 15, 2021 09:52
fixBr for all import wordpress
View function.php
<?php
function fixBr($str, $p = false) {
$str = str_ireplace(array("<br />","<br>","<br/>", "</br>"), PHP_EOL, $str);
$str = trim($str);
$arr = preg_split('/'.PHP_EOL.'/', $str);
@reslear
reslear / vue-force-update-v-on-input.md
Last active January 7, 2021 23:48
vue forceUpdate v-on input in slots
View vue-force-update-v-on-input.md

vue forceUpdate v-on input in slots

typescript

  computed: {
    inputEvents(): any {
      return {
        input: (e: { target: HTMLInputElement }) => {
          const value = e.target.value;
View check union is.ts
// https://www.typescriptlang.org/docs/handbook/advanced-types.html
// https://dev.to/pauloedurezende/the-power-of-union-and-type-guard-in-typescript-1amg
//https://www.freecodecamp.org/news/advanced-typescript-types-cheat-sheet-with-examples/
@reslear
reslear / axios-catch-error.js
Created August 31, 2020 12:07 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
View axios-catch-error.js
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
View class-wp-rest-posts-controller.php
// page: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
// Wrap the data in a response object.
$response = rest_ensure_response( $data );
// here!!!!! 여기 주석처리 중요
// $response->add_links( $this->prepare_links( $post ) );
// here!!!!!