Skip to content

Instantly share code, notes, and snippets.

View YonathanMeguira's full-sized avatar
🤩
Happy

Yonathan Meguira YonathanMeguira

🤩
Happy
View GitHub Profile
@YonathanMeguira
YonathanMeguira / gist:7b5198a34ee8dc31a3172758bcbbd6f4
Created April 18, 2017 09:49
swift=> casting dictionary? to struct
struct dataStruct {
var address = String()
var age = Int()
var balance = String()
var company = String()
var email = String()
var gender = String()
var name = String()
var phone = String()
var picture = String()
@YonathanMeguira
YonathanMeguira / Alamofire.swift
Last active April 19, 2017 15:01
AlamoFire casting Dictionary to Struct
//casting result from alamofire API Call to struct
struct dataStruct {
var address = String()
var age = Int()
var balance = String()
var company = String()
var email = String()
var gender = String()
var name = String()
@YonathanMeguira
YonathanMeguira / tableViewAction.swift
Created April 23, 2017 18:08
tableview editing action
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let delete = UITableViewRowAction(style: .destructive, title: "Delete") { (action, indexPath) in
// delete item at indexPath
self.todo.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
}
let share = UITableViewRowAction(style: .default, title: "Share") { (action, indexPath) in
// share item at indexPath
@YonathanMeguira
YonathanMeguira / flexBoxEngine.css
Created May 16, 2017 12:49
FlexBox Engine for angular
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url("styles/font/MaterialIcons-Regular.eot");
/* For IE6-8 */
src: local("styles/font/Material Icons"), local("styles/font/MaterialIcons-Regular"), url("styles/font/MaterialIcons-Regular.woff2") format("woff2"), url("styles/font/MaterialIcons-Regular.woff") format("woff"), url("styles/font/MaterialIcons-Regular.ttf") format("truetype"); }
.material-icons {
font-family: 'Material Icons';
@YonathanMeguira
YonathanMeguira / index.js
Last active July 10, 2017 13:21
NodeJs Scraping
// for the sake of the demonstration we are going to put all the code into one file,
// but I strongly encourage you to make your code as modular as possible
// also, please note that in a normal scenario, this function 'scrapeTheNews()' would be called from the index.js / starting point
// of your node app, because this is an async call, you would hve to wrap the inner part of the func inside a promise so that you
// would be able to retrieve the result in async from index.js
// if you want to see real world scenario with such wrapping please visit : https://github.com/jonathanmeguira/news-scraper
// useful to request/retrieve the page we want to scrape
@YonathanMeguira
YonathanMeguira / dataService.ts
Last active August 6, 2017 23:54
dataService.ts
import {Injectable} from '@angular/core';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
@Injectable()
export class Monsters{
private _monter: SubjectBehavior<string[]>;
constructor(){
import {Component, OnInit} from '@angular/core';
import {Monsters} from './monsters';
@Component({
selector: 'monsters',
templateUrl: './monsters.component.html',
styleUrls: ['./monsters.component.css']
})
export class MonstersComponent implements OnInit {
@YonathanMeguira
YonathanMeguira / allGroups.json
Created August 8, 2017 07:36
All Groups JSON forms, includes Devices, appliances and links
[
{
"id": 1,
"name": "group1",
"desc": "description1",
"devices": [
{
"type": "device1",
"healthy": false,
"appliances": [
@YonathanMeguira
YonathanMeguira / ngFor.ts
Created October 23, 2017 19:35
ngModel and ngFor
export class SomeClass {
public myArray = ['First Item', 'Second Item', 'Third Item'];
}
<div *ngFor="let element of myArray">
<input name="someName" [(ngModel)] = "element">
</div>