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 / 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;
@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;
<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 / 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": {
@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 / tree.ts
Created January 22, 2020 09:57
tree
// --------
const singleTree = {
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
// --------
const singleTree = {
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
const createRequestTwo(data): Observable<any>{
return this.http.post(url, data);
}
return requestOne
.pipe(
switchMap(
(requestOneResult) => {return createRequestTwo(requestOneResult)}
)
).subscribe((requestTwoResult) => {...})
getRate() {
this.items$ = this.service.getConversion()
.pipe(
tap((data) => {this.conversionRate = data.rates.USD;}),
switchMap(() => this.createItemsObservable())
)
}
private createItemsObservable(): Observable<Item[]>{
return this.itemsQuery.selectAll()
storeList$: Observable<Map<string,number>>;
stores$: Observable<string[]>;
ngOnInit() {
this.stores$ = this.itemsQuery.selectAll().pipe(map(entities =>
entities.map(entity => entity.store)
// .filter((elem, index, self) => {
// return index === self.indexOf(elem);
// })
));