Skip to content

Instantly share code, notes, and snippets.

View matheuscas's full-sized avatar

Matheus Cardoso matheuscas

View GitHub Profile
import { Service1 } from './service1.service';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { Component1Component } from './component1/component1.component';
@NgModule({
import { Service2 } from './service2.service';
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [Service2]
})
export class AppComponent {
import { Service1 } from './service1.service';
import { Injectable } from '@angular/core';
@Injectable()
export class Service2 {
constructor(private service1: Service1) { }
do(){
this.service1.doSomethingFromService1();
import { Injectable } from '@angular/core';
@Injectable()
export class Service1 {
constructor() { }
doSomethingFromService1(){
console.log('service 1 just did something');
}
@matheuscas
matheuscas / pylint-recursive.py
Last active October 10, 2016 18:33 — forked from gregorynicholas/pylint-recursive.py
Module that runs pylint on all python scripts found in a directory tree..
#! /usr/bin/env python
'''
Module that runs pylint on all python scripts found in a directory tree..
'''
import os
import re
import sys
total = 0.0
@matheuscas
matheuscas / views.py
Last active August 7, 2020 14:52 — forked from Diegow3b/views.py
Turning arround m2m_changed bug in admin from Django 1.8
'''
Obs1: m2m_changed never trigger the remove signal (pre_remove, post_remove) when deleted, so this ways you can force he do it
obs2: Since the pre_clear data will be removed anyways to new valuei n post_add add it again and when you fully remove data
the add events wont be trigger, so this solution will simule the exacly action the m2m_changed should do
'''
class OtherModel(model.Models)
pass
class MyModel(model.Models):
m2m_attribute = models.ManyToManyField(OtherModel,related_name='other_model', blank=True)
@matheuscas
matheuscas / settings.json
Last active October 3, 2016 14:56
My vscode workspace settings
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.DS_Store": true,
"**/**.map":true,
"**/**.pyc": true
},
@matheuscas
matheuscas / util.js
Last active August 16, 2016 17:58
Get param from url using its name
function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
@matheuscas
matheuscas / . gitignore
Created July 20, 2016 04:10
ionic-gitignore
node_modules/
platforms/
plugins/
temp/
*.DS_Store
*.log
*.swp
@matheuscas
matheuscas / gist:60597096fdc0257a4260
Last active August 16, 2016 17:58
Cordova Content-Security-Policy for Ionic apps (development mode)
<meta http-equiv="Content-Security-Policy"
content="default-src *;
script-src 'self' 'unsafe-inline' 'unsafe-eval'
localhost:*;
style-src 'self' 'unsafe-inline'
localhost">