Skip to content

Instantly share code, notes, and snippets.

View tqwewe's full-sized avatar
🔧

Ari Seyhun tqwewe

🔧
View GitHub Profile
@tqwewe
tqwewe / main.js
Created October 8, 2018 03:48
Compare two objects (deep)
// main.js
import objectDifference from './utils/objectDifference'
const obj1 = {
user: {
info: {
username: 'foo'
}
}
}
@tqwewe
tqwewe / vue-typescript-component.ts
Created December 22, 2018 09:57
Vue Typescript Component with all properties sorted to vue spec
import { Vue, Component, Model, Prop, Watch } from 'vue-property-decorator'
@Component({
delimiters: ['{{', '}}'],
comments: false,
components: null,
directives: null,
filters: null,
inheritAttrs: true,
})
sr_only
not_sr_only
appearance_none
bg*
border*
rounded*
cursor*
block
inline_block
inline
@tqwewe
tqwewe / App.jsx
Created May 6, 2020 07:19
React hooks and context with create-store util
// src/App.jsx
import React from 'react'
import { Provider as CountProvider } from './context/count'
import ShowCount from './components/ShowCount'
const App = () => {
return (
<CountProvider>
<ShowCount />
</CountProvider>
@tqwewe
tqwewe / Git_Cheatsheet.md
Last active July 16, 2020 07:16
Git Cheatsheet

Create new branch

git checkout -b <branch>

Delete local commits

git reset --hard origin/<branch>

Push without overriding others' changes

git push --force-with-lease

Merge changes from another branch

@tqwewe
tqwewe / sales-notifications.js
Created July 19, 2020 15:46
Sales notifications
const MIN_NOTIFICATION_TIME = 5; // 5 Seconds
const MAX_NOTIFICATION_TIME = 10; // 10 Seconds
const TEMPLATE = ({ product, time, location }) =>
`Someone bough a <b>${product}</b> from <b>${location}</b> <b>${time} seconds ago</b>`;
const MIN_TIME_AGO = 15; // Min seconds to show when someone purchased something (eg 'Bob bought this x seconds ago')
const MAX_TIME_AGO = 60; // Max seconds to show when someone purchased something (eg 'Bob bought this x seconds ago')
const SHOW_TIME = 10; // Time to display notification for
const CLASS_NAME = "sales-notification";
const CONTAINER_ID = "sales-notifications";
@tqwewe
tqwewe / dev.js
Last active July 22, 2020 10:48
NodeJS Yarn Run Develop Generic
// This script searches for a package json in current directory, and works it's way up until one is found.
// If no package.json is found, the dev command returned is `develop`.
// If a package.json is found, it reads the scripts section and finds one that matches: 'dev', 'develop', 'start'
// The result returned is `yarn install && yarn run <dev_command>` (with dev_command being the found develop command.
// This can be fed into bash along with an alias defined to create an easy way to run the develop command in projects.
//
// Put this dev.js file in ~/scripts/dev.js
//
// Add this to your .zshrc file (or .bashrc)
// alias dev="node ~/scripts/dev.js | bash"
@tqwewe
tqwewe / gqltimestamptz.rs
Created February 7, 2021 14:10
Rust Postgres Diesel Timestamptz support with async-graphql
use std::io::Write;
use async_graphql::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
use diesel::{
deserialize,
pg::Pg,
serialize::{self, Output},
sql_types::{self, Timestamp, Timestamptz},
types::{FromSql, ToSql},
};
@tqwewe
tqwewe / Cargo.toml
Last active March 20, 2021 08:05
Actix channel issue
[package]
name = "test"
version = "0.1.0"
edition = "2018"
[dependencies]
actix-web = "4.0.0-beta.4"
tokio = { version = "1", features = ["full"] }
@tqwewe
tqwewe / cargo.toml
Last active May 13, 2021 14:25
Hyper slow body reading
[dependencies]
hyper = { version = "0.14", features = ["full"] }
tokio = { version = "1", features = ["full"] }