Skip to content

Instantly share code, notes, and snippets.

View pocojang's full-sized avatar
🐢

Poco pocojang

🐢
View GitHub Profile

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@mburakerman
mburakerman / package.json
Last active June 12, 2019 14:58
Webpack 4 config.js (Stylus to CSS and Babel) 👌 The Simplest Usage 👌
{
"name": "webpack-stylus",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --open --mode development",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",

리액트 디버깅

리액트 프로젝트를 VSCode 와 Chrome 을 통하여 손쉽게 디버깅 하는 방법을 알아보겠습니다.

설치

Debugger For Chrome VSCode 익스텐션을 설치하세요.

그 다음에는, 프로젝트의 루트경로에 .vscode/launch.json 파일을 만드세요.

@JoaoCnh
JoaoCnh / triforce.js
Created February 14, 2018 15:18
Solving the problem
// Let's reduce the array of arrays into a single one
const songNames = allSongs.reduce((acc, currValue) => {
return acc.concat(currValue);
}, [])
// Let's map it out with the seconds turned into minutes
.map(song => {
return { ...song, duration: Math.floor(song.duration / 60) };
})
// Let's filter the ones under 3 minutes
.filter(song => {
@JoaoCnh
JoaoCnh / flatarray.js
Created February 14, 2018 14:55
Array of Arrays flatten with reduce
const mult = [songs, [{id: 112, name: "Chop Suey", artist: "System of a Down" }]];
var flatMult = mult.reduce(function (acc, currValue) {
return acc.concat(currValue);
}, []);
// ES6
const flatMult = mult.reduce((acc, currValue) => {
return acc.concat(currValue);
}, []);
@JoaoCnh
JoaoCnh / obj.js
Last active October 14, 2018 09:27
Reduce object from array
var obj = songs.reduce(function (acc, currValue) {
var artist = currValue.artist;
var artistCount = acc[artist] ? acc[artist] + 1 : 1;
var newObj = {};
newObj[artist] = artistCount;
return Object.assign(acc, newObj);
}, {});
import axios from 'axios';
import {toCamelCase, toSnakeCase} from '../util';
import qs from 'qs';
// You can intercept requests or responses before they are handled by then or catch.
// https://github.com/axios/axios#interceptors
// Add a response interceptor and camelCase return data (for JS)
axios.interceptors.response.use((response) => {
response.data = toCamelCase(response.data);
anonymous
anonymous / Con.js
Created July 1, 2017 20:29
S70 To-Do List 완성 코드
//Con Class
var Con = (function(){
var Con = function(){}, fn = Con.prototype = new Renderer();
fn._init = function(){ console.clear(); };
fn._render = function() {
var task;
var n = 1;
console.log('진행');
for (var i = 0; i < this._tasks.length; i++){
var Html = function(){};
Html.prototype = new Renderer();
Html.prototype._init = function(){
if(typeof this.completeLi !== 'undefined' && typeof this.progressLi !== 'undefined') {
return;
}
this.progressLi = document.querySelector('#todo .progress li');
this.completeLi = document.querySelector('#todo .complete li');