Skip to content

Instantly share code, notes, and snippets.

View mantissa23's full-sized avatar

ma mantissa23

  • 23zzle
View GitHub Profile
@mantissa23
mantissa23 / Win10-64bit-npm.md
Created May 27, 2021 00:10 — forked from jtrefry/Win10-64bit-npm.md
Configuring Windows 10 (64-bit) for npm and node-gyp
  • Install Git for Windows
  • Install Node
  • Install Python 2.7.3
  • Install Microsoft Visual Studio 2015 Community
  • Open the command prompt as Administrator, run the following commands, then close the command prompt (a new prompt is required before the new environment variables will be available)
    • npm install -g npm
      • (Upgrades to npm v3, which no longer nests dependencies indefinitely. No more "maximum path length exceeded" errors due to the 260 character path limit in Windows, or needing to delete node_modules with rimraf.)
    • setx PYTHON C:\Python27\python.exe /m
      • (May need to change path to your custom install directory.)
  • Open a new command prompt and run the following commands. If these install without errors, you have bypasse
В fields.yaml отдельно прописать my_field@update - то есть состояние кнопки при update.
Пример:
my_field:
type: text
...
my_field@update:
type: text
disabled: true
...
Если нужна связь типа "Запись имеет комментарий(ии)", то есть без pivot таблицы,
а просто таблица комментариев имеет доп. столбец с id записи, то:
1. модели Запись прописываем:
public $hasMany = [
'comments' => 'author\myplugin\Models\Comment'
];
2. Контроллеру Записи прописываем:
public $implement = ['Backend\Behaviors\RelationController'] и public $relationConfig = 'config_relation.yaml';
@mantissa23
mantissa23 / SingletonDefaultExportInstance.js
Created December 17, 2020 06:52 — forked from dmnsgn/SingletonDefaultExportInstance.js
ES6 singleton pattern: module default exports an instance
class SingletonDefaultExportInstance {
constructor() {
this._type = 'SingletonDefaultExportInstance';
}
singletonMethod() {
return 'singletonMethod';
}
static staticMethod() {
@mantissa23
mantissa23 / proxy.js
Created March 31, 2020 15:57 — forked from cmawhorter/proxy.js
Node script to forward all http requests to another server and return the response with an access-control-allow-origin header. Follows redirects.
// Simple proxy/forwarding server for when you don't want to have to add CORS during development.
// Usage: node proxy.js
// Open browser and navigate to http://localhost:9100/[url]
// Example: http://localhost:9100/http://www.google.com
// This is *NOT* for anything outside local development. It has zero error handling among other glaring problems.
// This started as code I grabbed from this SO question: http://stackoverflow.com/a/13472952/670023
@mantissa23
mantissa23 / .eslintrc.js
Last active October 8, 2020 19:50 — forked from adrianhall/.eslintrc.js
A sample .eslintrc file
const OFF = 0
const WARN = 1
const ERROR = 2
// Gist fork: https://gist.github.com/mantissa23/53b1de222a798e5ef542f87b5ce0f8ad
module.exports = {
root: true,
env: {
browser: true,
@mantissa23
mantissa23 / symlink.sh
Created March 1, 2020 12:50 — forked from geedew/symlink.sh
A cross platform symlink method in Bash
@mantissa23
mantissa23 / .eslintrc.js
Created November 22, 2019 07:55 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
// APIStoreProps are properties that need to be
// ignored when running APIStore.makeStore()
const APIStoreProps = ['use', 'classes', 'constructor', 'init', 'state']
// getMethods returns methods defined
// in a given class' prototype, except init and constructor
const getMethods = (cls) => {
return Object.getOwnPropertyNames(cls.prototype)
.reduce((obj, prop) => {
@mantissa23
mantissa23 / [OctoberCMS] Vue.js
Created September 7, 2019 21:32 — forked from Titoratus/[OctoberCMS] Vue.js
[OctoberCMS] Vue.js
Устанавливаем October (установщиком или через Composer)
В папке с October устанавливаем пакет vue-cli (npm i -g vue-cli) и создаём vue приложение (vue init webpack my-app),
внутри папки my-app выполняем (npm i) и в итоге npm run dev (консоль и так подскажет)
Внутри my-app - npm i --save-dev axios (для запросов get, post к api)
Axios — это JavaScript-библиотека для выполнения либо HTTP-запросов в Node.js, либо XMLHttpRequests в браузере.
.htaccess (шоб axios мог получать данные):
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"