Skip to content

Instantly share code, notes, and snippets.

View byurhannurula's full-sized avatar
🏠
Working from home

Byurhan Nurula byurhannurula

🏠
Working from home
View GitHub Profile
@byurhannurula
byurhannurula / cloudSettings
Last active July 16, 2019 15:17
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-07-16T15:17:08.352Z","extensionVersion":"v3.4.0"}
@byurhannurula
byurhannurula / auth.js
Created April 27, 2019 13:43
index.js - apollo server / user.js - user resolver / user.graphql - graphql schema of user / auth.js = helper functions
import { User } from './models'
export const isAuthenticated = req => {
if (!req || !req.session || !req.session.userId) {
// user is not logged in
throw new Error('Not authenticated!')
}
}
export const signOut = (req, res) =>
@byurhannurula
byurhannurula / oneliners.js
Created April 28, 2019 14:22 — forked from ademilter/oneliners.js
👑 Awesome one-liners you might find useful while coding.
// By @coderitual
// https://twitter.com/coderitual/status/1112297299307384833
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// Type this in your code to break chrome debugger in that line.
import mongoose, { Schema } from 'mongoose'
const userSchema = new Schema({
name: String,
bio: String,
email: String,
password: String,
googleId: String,
githubId: String,
avatar: String,
/* eslint-disable react/display-name */
/* eslin-disable */
import React, { useState } from 'react'
import { Mutation } from 'react-apollo'
import { adopt } from 'react-adopt'
import {
Container,
Row,
Col,
Card,
@byurhannurula
byurhannurula / image.jsx
Last active July 15, 2019 17:27
Gatsby Image component
import React from 'react'
import Img from 'gatsby-image'
import { graphql, useStaticQuery } from 'gatsby'
const query = graphql`
query {
images: allFile(filter: { extension: { regex: "/jpeg|jpg|png|gif/" } }) {
edges {
node {
extension
@byurhannurula
byurhannurula / keybindingsMac.json
Last active July 18, 2019 12:41
VS Code Settings Gist
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+shift+a",
"command": "workbench.action.toggleActivityBarVisibility"
},
{
"key": "ctrl+shift+s",
"command": "workbench.action.toggleStatusbarVisibility"
}
# name: simply
# Colors
set cyan (set_color cyan)
set yellow (set_color yellow)
set red (set_color red)
set blue (set_color blue)
set green (set_color green)
set orange (set_color ff8300)
set gray (set_color 666666)
@byurhannurula
byurhannurula / Repeat.js
Created October 15, 2019 14:58 — forked from mskoroglu/Repeat.js
react repeat component
/**
* usage:
* <ul>
* <Repeat times="3">
* <li>item</li>
* </Repeat>
* </ul>
* or
* <ul>
* <Repeat
@byurhannurula
byurhannurula / animatedScrollTo.js
Created November 12, 2019 16:07 — forked from joshbeckman/animatedScrollTo.js
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;