Skip to content

Instantly share code, notes, and snippets.

View DaleSeo's full-sized avatar
😈
Radical Candor

Dale Seo DaleSeo

😈
Radical Candor
View GitHub Profile
@DaleSeo
DaleSeo / index.js
Created April 28, 2019 21:02
GraphQL Apollo Server
const { ApolloServer, gql } = require('apollo-server');
const typeDefs = gql`
type Query {
ping: String
}
`;
const resolvers = {
Query: {
@DaleSeo
DaleSeo / fetchAuthorName_async_await.js
Last active July 16, 2021 13:19
JS Async Async/Await
async function fetchAuthorName(postId) {
const postResponse = await fetch(`https://jsonplaceholder.typicode.com/posts/${postId}`);
const post = await postResponse.json();
const userId = post.userId;
const userResponse = await fetch(`https://jsonplaceholder.typicode.com/users/${userId}`)
const user = await userResponse.json();
return user.name;
}
fetchAuthorName(1).then(name => console.log("name:", name));
@DaleSeo
DaleSeo / 1_findUser.js
Created December 13, 2018 00:34
JS Async Promise
findUser(1)
.then(function(user) {
console.log("user:", user);
});
function findUser(id) {
return new Promise(function (resolve) {
setTimeout(function() {
console.log("waited 0.1 sec.");
const user = {
@DaleSeo
DaleSeo / asyncFindUser.js
Created December 7, 2018 19:49
JS Async Callback
function findUser(id) {
let user;
setTimeout(function() {
console.log("waited 0.1 sec.");
user = {
id: id,
name: "User" + id,
email: id + "@test.com"
};
}, 100);
@DaleSeo
DaleSeo / unique-substrings-in-wraparound-string.py
Created December 7, 2016 05:28
unique-substrings-in-wraparound-string
class Solution(object):
def findSubstringInWraproundString(self, p):
dic = {}
for i, v in enumerate(p):
if i > 0 and ((ord(p[i]) - ord(p[i - 1])) % 26) == 1:
subs += 1
else:
subs = 1
dic[v] = max(subs, dic.get(v, 0))
return sum(dic.values())
// 배열의 원소에 개별 접근하기
var fruit1 = fruits[0];
var fruit2 = fruits[1];
var fruit3 = fruits[2];
var fruit3 = fruits[3]; // undefined
@DaleSeo
DaleSeo / company_investment.py
Created October 19, 2016 02:54
기업투자
"""
https://www.acmicpc.net/problem/2662
"""
def maximize(total, cnt, table):
dp = [[0] * (cnt + 1) for _ in range(total + 1)]
investments = [[0] * (cnt + 1) for _ in range(total + 1)]
for company in range(1, cnt + 1):
@DaleSeo
DaleSeo / Test
Created September 28, 2016 07:34
test