Skip to content

Instantly share code, notes, and snippets.

@ruisebastiao
ruisebastiao / Readme.md
Created December 30, 2018 10:38 — forked from brgaulin/Readme.md
ng2-smart-table datepicker

Install

npm install --save ng-pick-datetime

Setup

Add the component in this gist to your project Add to your smart table settings:

@ruisebastiao
ruisebastiao / nginx.conf
Created May 28, 2018 23:38 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs
# Advanced config for NGINX
server_tokens off;
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options nosniff;
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
import {Injectable, provide} from 'angular2/core';
import {Observable} from 'rxjs';
const GEOLOCATION_ERRORS = {
'errors.location.unsupportedBrowser': 'Browser does not support location services',
'errors.location.permissionDenied': 'You have rejected access to your location',
'errors.location.positionUnavailable': 'Unable to determine your location',
'errors.location.timeout': 'Service timeout has been reached'
};
@ruisebastiao
ruisebastiao / MongoDB update all matching.js
Created March 27, 2018 14:32 — forked from sym3tri/MongoDB update all matching.js
How to update a single field in a MongoDB collection for all documents matching a specific criteria
// FROM: http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29
//
// db.collection.update( criteria, objNew, upsert, multi )
// criteria - query which selects the record to update;
// objNew - updated object or $ operators (e.g., $inc) which manipulate the object
// upsert - if this should be an "upsert"; that is, if the record does not exist, insert it
// multi - if all documents matching criteria should be updated
//
// SQL VERSION:
// UPDATE myTable SET dateField = '2011-01-01' WHERE condField = 'condValue'
@ruisebastiao
ruisebastiao / item.cpp
Created March 19, 2018 15:18 — forked from austriancoder/item.cpp
QMetaEnum: Serializing C++ Enums
const QString Item::type() const
{
const QMetaObject &mo = Item::staticMetaObject;
int index = mo.indexOfEnumerator("Type");
QMetaEnum metaEnum = mo.enumerator(index);
return metaEnum.valueToKey(m_type);
}
void Item::setType(const QString &type)
@ruisebastiao
ruisebastiao / example-usage.ts
Created January 15, 2018 10:44 — forked from glenngr/example-usage.ts
Fit contents directive for angular2-google-maps (sebm-google-map)
import { Subject } from 'rxjs/Subject';
import { Store } from '@ngrx/store';
import { Component, OnInit, OnDestroy, AfterViewInit } from '@angular/core';
import { AppState } from '../../../root.reducer';
@Component({
selector: 'my-map-example',
template: `
<sebm-google-map
@ruisebastiao
ruisebastiao / passport.js
Created July 20, 2017 22:02 — forked from manjeshpv/passport.js
Passport.js using MySQL for Authentication with Express
// config/passport.js
// load all the things we need
var LocalStrategy = require('passport-local').Strategy;
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
@ruisebastiao
ruisebastiao / controller.js
Created December 15, 2016 12:04 — forked from BobNisco/controller.js
onLongPress AngularJS Directive - Great for mobile!
// Somewhere in your controllers for this given example
// Example functions
$scope.itemOnLongPress = function(id) {
console.log('Long press');
}
$scope.itemOnTouchEnd = function(id) {
console.log('Touch end');
}
@ruisebastiao
ruisebastiao / BigButton.qml
Created November 14, 2016 06:02 — forked from jemc/BigButton.qml
Big Button example in QML using SVG and native layers
import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
import QtGraphicalEffects 1.0
Item {
height: 200
width: 200
@ruisebastiao
ruisebastiao / nodejs-tcp-example.js
Created March 12, 2016 22:21 — forked from tedmiston/nodejs-tcp-example.js
Node.js tcp client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');