Skip to content

Instantly share code, notes, and snippets.

View samwx's full-sized avatar
💻
Coding

Samuel Martins samwx

💻
Coding
View GitHub Profile
@samwx
samwx / tslint.json
Created September 25, 2018 20:36
Node typescript lint file
{
"extends": [
"tslint:latest",
"tslint-config-prettier"
],
"rules": {
"no-any": false,
"ordered-imports": false,
"semicolon": [true, "always"],
"member-ordering": [
@samwx
samwx / .travis.yml
Created September 25, 2018 20:24
Travis file for typescript projects with Jest and coveralls
language: node_js
node_js:
- 'node' # use latest stable nodejs version
before_script:
- npm install
- npm run test
- npm run coverage
script:
- npm run build # jest test with coverage flag does coverage too
after_script:
@samwx
samwx / deregistrationRootScope.js
Created August 17, 2018 13:07
Deregistering $rootScope function listeners
class MyController {
constructor($scope, $rootScope) {
/*
Every $rootScope.$on returns a deregistration function that remove listerner and avoid duplications
https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$on
*/
const deregisterDropdownOpenEvent = $rootScope.$on('DropdownOpened', () => console.log('dispatch event'))
/* Deregister function on scope $destroy event (when user leave the page, for example) */
$scope.$on('$destroy', () => deregisterDropdownOpenEvent())
@samwx
samwx / components.js
Created November 19, 2017 17:42
angularjs module distribution
(function(angular){
angular.module('blip.components', [])
.component('component1', {
template: '<span>{{ $ctrl.name }}</span>',
bindings: {
name: '@',
}
})
.component('component2', {
template: '<span>{{ $ctrl.name }} 2</span>',
@samwx
samwx / typescript.json
Last active May 30, 2018 20:12
Userful angular snippets for vscode
{
"Create angular es7 module": {
"prefix": "ng-module",
"body": [
"import * as angular from 'angular';",
"",
"// Types",
"",
"// Controllers",
"",
@samwx
samwx / tslint.json
Created September 29, 2017 18:47
tslint suggestion
{
"rules": {
"class-name": true,
"comment-format": [
true
],
"curly": true,
"eofline": true,
"forin": true,
"indent": [
@samwx
samwx / new_gist_file.less
Created May 24, 2016 13:33
Rulesets for LESS
@placeholder-ruleset: { text-transform: uppercase; };
.placeholder(@color-01, @placeholder-ruleset);
/**/
.placeholder(@color, @ruleset: {}) {
::-webkit-input-placeholder {
color: @color;
@ruleset();
}
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Samuel Martins