Skip to content

Instantly share code, notes, and snippets.

View amirfefer's full-sized avatar

Amir Fefer amirfefer

  • Red Hat
  • Tel Aviv
View GitHub Profile
@amirfefer
amirfefer / deploy-apache.yml
Created May 12, 2024 16:59
This playbook deploys hello world html page via Apache server
#!/usr/bin/ansible-playbook
---
- hosts: localhost
connection: local
become: yes
gather_facts: yes
tasks:
- name: Ensure firewalld is installed
@amirfefer
amirfefer / NumericInput.js
Last active June 16, 2020 14:23
NumericInput
const [size, setSize] = useState(0);
const GB_SIZE_IN_BYTE = 1000000000;
const MB_SIZE_IN_BYTE = 1000000;
const Example = () => {
const formaatedSize = useCallback(() => {
switch (true) {
case 0 <= size < GB_SIZE_IN_BYTE:
return { type: 'MB', value: size / MB_SIZE_IN_BYTE };
case size >= GB_SIZE_IN_BYTE:
This file has been truncated, but you can view the full file.
{
"name": "TheForemanDevDeps",
"version": "2.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@babel/code-frame": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz",
"integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==",
@amirfefer
amirfefer / t.md
Last active December 5, 2018 12:37
Expandable component architecture

Hello everyone,

As we all know, plugins need the ability to alter pages on foreman core.
To achieve that, developers mostly use deface, which allows you to change DOM dynamically.

While deface works well with rails views, we should not use it on react components.
It changes the real DOM on server rendering, while a react component relay on the virtual DOM,
which means - changes in the real DOM won't affect the virtual DOM.

@amirfefer
amirfefer / re.md
Last active November 29, 2018 14:36

As part of the Tour component PR, I searched for a persistent mechanism for seen tours
(If a user already observed a tour, it shouldn't be popped out again)
Tour component

At first, I implemented it as a seen list blob within the user table
But, on secondary thought, why not to extend it to a generic user preferences table?
Foreman already has a user's table preferences table, which store user's picked columns, how about generalize it ?

Table preferences attributes

name: string, columns: serilazied

@amirfefer
amirfefer / readme.md
Last active November 29, 2018 19:06
RFC Foreman: Integration tests & E2E testing

RFC - Integration Tests & End to End tests

Present architecture

E2E

Pipeline bats, but not client edge - server edge running on a browser

Integration

foreman uses rails minitest with capybara (phantomJs driver)

While this integration test architecture has some benefits:

  1. uses ruby code
import React from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import PropTypes from 'prop-types';
import Form from '../../../../components/HardwareModel/form';
import API from '../../../../API';
import BreadcrumbsBar from '../../../../components/BreadcrumbBar';
import * as HardwareModelActions from './HardwareModelActions';
class HardwareModelsEdit extends React.Component {
@amirfefer
amirfefer / add_a_react_component.md
Last active May 13, 2018 14:26
How to add a react component to foreman

Folder structre

Create a folder under /webpack/assets/javascripts/react_app/components/ with the following structure (filenames should be upper CamelCase):

webpack/assets/javascripts/react_app/components/<Compoment-name>
├── <Compoment-name>Actions.js
├── Reducer.js
GIT
remote: https://github.com/theforeman/foreman_discovery.git
revision: 2c5cbe1724da5a76e6ab9c9d0cd943e91768c9df
branch: develop
specs:
foreman_discovery (11.0.0)
GEM
remote: https://rubygems.org/
specs:
#include <iostream>
#include <math.h>
using namespace std;
int convertibaseto10(int Num, int ibase)
{
int tmp1 = Num;
int decimal = 0;
int ex = 0;
while ( tmp1 >= 1)