Skip to content

Instantly share code, notes, and snippets.

View mksglu's full-sized avatar

Mert Köseoğlu mksglu

View GitHub Profile
@mksglu
mksglu / folder-structure.ts
Last active March 18, 2023 17:58
Separation of concerns with feature based architecture folder structure- React Native and Expo - Zustand, React Query, Immer, MSW, RTL, Styled Components, React Navigation
- assets
- fonts
- images
- navigations
- PrivateNavigator.ts
- PublicNavigator.ts
- RootNavigator.ts
- components
- Button
- Button.ts
@mksglu
mksglu / vscode-upgrade-command.sh
Created February 6, 2021 03:08
Let's upgrade VSCODE with use Brew command so easly!
brew upgrade --cask visual-studio-code
https://stackoverflow.com/questions/59018071/mock-usedispatch-in-jest-and-test-the-params-with-using-that-dispatch-action-in/61875674#61875674
https://dev.to/fredrikbergqvist/mocking-redux-useselector-hook-2ale
https://redux.js.org/recipes/writing-tests#connected-components
https://ttfb.test.traveloka.com/testing-react-component-using-enzyme-jest-part-4/
https://gist.github.com/krawaller/e5d40217658fa132f3c3904987e467cd
https://dev.to/zaklaughton/the-only-3-steps-you-need-to-mock-an-api-call-in-jest-39mb
https://www.loupetestware.com/post/mocking-api-calls-with-jest
@mksglu
mksglu / perfectsquare.js
Last active November 25, 2020 22:50
Binary Search
/*
1. Initialize left=1 & Right=n
2. Calculate mid = Math.floor((left + right) / 2);
2. If mid*mid = n, then n is Perfect Square
3. Else if mid*mid > n then right = mid - 1
4. Else if mid*mid < n then left = mid + 1
*/
const perfectSquare = (number) => {
@mksglu
mksglu / upgrade-vscode.md
Created July 14, 2020 04:23
Upgrade Visual Studio Code Using Brew For Mac

$ brew cask upgrade visual-studio-code

@mksglu
mksglu / sozcu.disable-popup.js
Created May 31, 2020 10:49
Sözcü'de bazen okumak istediğim bir haber olduğunda ısrarla karşıma çıkan popup'un ağzını yüzünü kıran bir kod parçası.
var p=Array.prototype.slice.call(document.querySelectorAll(".fc-ab-root"));p.forEach(function(o){o.parentNode.removeChild(o)}),document.body.style.overflow="auto";
@mksglu
mksglu / autocomplete-disable.js
Created March 30, 2020 04:05
Chrome Version 80.0.3987.149 (Official Build) (64-bit) `Disable` Form Input Autocomplete and Autofill
<input type="text" readonly="readonly" onfocus="javascript: this.removeAttribute('readonly')">
fetch("https://www.hepsiburada.com/siparislerim/api/orders?skip=0")
.then(response => response.json())
.then(result => {
var maxSkip = result.MaxSkip;
var increase = 10;
if (maxSkip === 0) {
var totalAmount = 0;
for (let index = 0; index < result.Orders.length; index++) {
totalAmount += parseInt(result.Orders[index].TotalAmount.Value);
}
@mksglu
mksglu / hepsiburada.js
Last active October 31, 2022 14:36
hepsiburada.com üzerinden yaptığınız toplam alışveriş tutarını gösterir. https://www.hepsiburada.com adresine girdikten sonra uye girisi yapin ve tarayicinin konsoluna asagidaki kodu yapistirip entere basmaniz yeterli.
fetch("https://www.hepsiburada.com/siparislerim/api/orders?skip=0").then(function(r){return r.json()}).then(function(r){var e=r.MaxSkip;if(0===e){for(var n=0,a=0;a<r.Orders.length;a++)n+=parseInt(r.Orders[a].TotalAmount.Value);console.log("Toplam Hepsiburada.com harcamaniz: ",n.toFixed(2).replace(/\d(?=(\d{3})+\.)/g,"$&,"),"TL")}else{(function(r,e){for(var n=[],a=0;a<r+e;a+=e)n.push(fetch("https://www.hepsiburada.com/siparislerim/api/orders?skip=".concat(a)).then(function(r){return r.json()}).then(function(r){for(var e=0,n=0;n<r.Orders.length;n++)e+=parseInt(r.Orders[n].TotalAmount.Value);return e}));return Promise.all(n)})(e,10).then(function(r){var e=r.reduce(function(r,e){return r+e},0).toFixed(2).replace(/\d(?=(\d{3})+\.)/g,"$&,");console.log("Toplam Hepsiburada.com harcamaniz: ",e,"TL")})}});
process.env.NODE_ENV = "test";
import * as mongoose from "mongoose";
import config from "../../config";
import { ALREADY_MEMBER_EMAIL, INVITE_EMAIL, mockUser } from "../../utils/test.utils";
import userService from "./users.service";
describe("Users Service", () => {
let _mailConfirm: string;
let userToken: any = {};
beforeAll(done => {
mongoose.connect(