Skip to content

Instantly share code, notes, and snippets.

View aramis-it's full-sized avatar

ulziibadrakh aramis-it

  • Mongolia
View GitHub Profile
@aramis-it
aramis-it / yarn3pnp.md
Last active May 4, 2022 01:45
yarn 3 pnp CRA
  • yarn create react-app --template typescript
  • remove nodeLinker from .yarnrc.yml
  • yarn dlx @yarnpkg/sdks vscode
  • yarn plugin import typescript
  • import '@testing-library/jest-dom' in test file
  • "typeRoots": ["typing"] in tsconfig.json
  • remove eslint config in package.json
@aramis-it
aramis-it / expo-take-photo.ts
Created October 19, 2021 04:58
expo take photo
import { StatusBar } from 'expo-status-bar';
import React, { useState, useEffect, useRef } from 'react';
import { Platform, StyleSheet, TouchableOpacity } from 'react-native';
import { Camera } from 'expo-camera';
import { Text, View } from '../components/Themed';
import { FontAwesome5 } from '@expo/vector-icons';
export default function ModalScreen() {
const [hasPermission, setHasPermission] = useState(false);
@aramis-it
aramis-it / CorsMiddleware.php
Created June 12, 2021 00:35
cakephp 4, cors, middleware
<?php
declare(strict_types=1);
namespace App\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
@aramis-it
aramis-it / mongodb.ts
Last active January 6, 2021 03:15
mongodb expressjs
import mongoose from 'mongoose';
mongoose.connect('mongodb://localhost:27017/mongotest', { useNewUrlParser: true });
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
// we're connected!
console.log("MongoDB connected");
});
@aramis-it
aramis-it / settings.json
Created November 22, 2019 03:50
vscode, titlebar color, statusbar color, php brand color
{
"folders": [
{
"path": "formik-ck"
}
],
"settings": {
"workbench.colorCustomizations": {
"statusBar.background": "#787CB5",
"titleBar.activeBackground": "#787CB5"
import React from 'react';
// props -н төрлийг зааж өгж байна
type propsTypes = {
name: string
}
const App = (props: propsTypes) => {
return (
<div>
<h1>Name: {props.name}</h1>
import React, { Component, ChangeEvent } from 'react';
// props -н төрлийг зааж өгж байна
type propsTypes = {
name: string
}
// state -н төрлийг зааж өгч байна
type stateTypes = {
name: string
@aramis-it
aramis-it / promize.js
Created February 17, 2019 08:03
Promise all
Promise.all([get("/v1/languages.json"), get("/v1/profiles.json")]).then(
values => {
}
);
@aramis-it
aramis-it / groupByField.js
Created November 29, 2018 02:28
array group by field
groupBy(xs, key) {
return xs.reduce(function(rv, x) {
(rv[x[key]] = rv[x[key]] || []).push(x);
return rv;
}, {});
}
@aramis-it
aramis-it / object.js
Created November 29, 2018 02:27
Iterate, loop through object properties
Object.keys(obj).forEach(e => console.log(`key=${e} value=${obj[e]}`));