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
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 }
TypeScript 5 hrs 50 mins █████████▍░░░░░░░░░░░ 45.0%
JSON 2 hrs 8 mins ███▍░░░░░░░░░░░░░░░░░ 16.5%
Bash 1 hr 38 mins ██▋░░░░░░░░░░░░░░░░░░ 12.7%
YAML 1 hr 21 mins ██▏░░░░░░░░░░░░░░░░░░ 10.4%
Markdown 48 mins █▎░░░░░░░░░░░░░░░░░░░ 6.3%
@reslear
reslear / function.php
Last active March 15, 2021 09:52
fixBr for all import wordpress
<?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

vue forceUpdate v-on input in slots

typescript

  computed: {
    inputEvents(): any {
      return {
        input: (e: { target: HTMLInputElement }) => {
          const value = e.target.value;
// 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
/*
* 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 😨
// 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!!!!!