Skip to content

Instantly share code, notes, and snippets.

View msarsha's full-sized avatar
🏠
Working from home

Matan Sar-Shalom msarsha

🏠
Working from home
View GitHub Profile
@msarsha
msarsha / tree.ts
Created January 22, 2020 09:57
tree
// --------
const singleTree = {
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
@msarsha
msarsha / hooks.md
Created October 18, 2019 13:34
Setting up git hooks with husky, commitlint and prettier
  1. npm install prettier --save-dev --save-exact

  2. npx mrm lint-staged

  3. npm install --save-dev @commitlint/{cli,config-conventional}

  4. echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js

  5. edit package.json:

  "husky": {
    "hooks": {
<div class="m-2">
<div class="search-container">
<input #searchInput pattern="[A-Za-z]" class="search-input" type="text"
(keyup.enter)="validInput && onSearch(searchInput.value)" placeholder="search city"
(change)="checkValues(searchInput.value)"> <i
class="fas fa-search-location search-icon" (click)="validInput && onSearch(searchInput.value)"></i>
</div>
<ng-container *ngIf="(weatherData$ | async).main as weatherData; else noDataMessage">
<div class="d-flex">
@msarsha
msarsha / component.jsx
Created August 18, 2019 13:52
react component
const userFormReducer = (state, action) => {
switch (action.type) {
case actionTypes.INPUT_CHANGE: {
return {
...state,
[action.name]: action.value
}
}
default:
return state;
@msarsha
msarsha / rtl-nativescript.txt
Last active October 5, 2019 08:45
Force RTL layout for android and ios in NativeScript
android (main.ts):
app.android.addEventListener(app.AndroidApplication.activityCreatedEvent, (event: app.AndroidActivityEventData) => {
event.activity.getWindow().getDecorView().setLayoutDirection(android.view.View.LAYOUT_DIRECTION_RTL);
});
ios (app.component.ts):
UIView.appearance().semanticContentAttribute = 4;
@Injectable()
export class NastyService {
constructor(@Inject(CASE_LOGIC_HANDLER) private caseHandlers: CaseLogicHandler[]) {
}
doNastyOperation(key: any) {
const handler = this.caseHandlers.find(h => h.key === key);
if (!handler) throw new Error(`No case handler provided for key: ${key}`);
handler.doLogic();
}
@Injectable()
export class NastyService {
constructor(@Inject(CASE_LOGIC_HANDLER) private caseHandlers: CaseLogicHandler[]) {
}
doNastyOperation(key: any) {
switch (key) {
case 1:
// logic
case 2:
@msarsha
msarsha / module.ts
Last active February 23, 2018 18:33
@NgModule({
providers: [
{provide: CASE_LOGIC_HANDLER, useClass: CaseOne, multi: true},
{provide: CASE_LOGIC_HANDLER, useClass: CaseTwo, multi: true},
// ...
]
})
export class AppModule {
}
@Injectable()
export class NastyService {
constructor() {
}
doNastyOperation(key: any) {
switch (key) {
case 1:
// logic
case 2:
export class CaseOne implements CaseLogicHandler{
key: any = 1;
doLogic() {
// case logic
}
}
export class CaseTwo implements CaseLogicHandler{
key: any = 2;