Skip to content

Instantly share code, notes, and snippets.

@gmocamilotd
gmocamilotd / jj
Last active September 20, 2017 22:14
(angular)
If you need access to a function from several places, consider putting it in a service as mentioned before
el ejemplo completo:
@gmocamilotd
gmocamilotd / tt
Last active September 28, 2017 03:22
angular, errorfix
## Can't bind to 'ngModel' since it isn't a known property of 'input'
### resuelve
Yes that's it, in the app.module.ts, I just added :
```
import { FormsModule } from '@angular/forms';
[...]
@NgModule({
@gmocamilotd
gmocamilotd / md1
Last active October 4, 2017 03:28
1. take a look at [Chrome Devtools](https://developer.chrome.com/devtools) (given you use Chrome which has very neat devtools build-in).
2. I also often suggest people to do the [free Code School course](http://discover-devtools.codeschool.com/) on Discover Devtools which is nice as well.
3. Open web developer console, go to "Sources" section. Press "CTRL+P". A search box will open where type ".ts" and find your file or directly search your file like "myfile.ts". Open it and you can put breakpoints directly in the code, the same way we put breakpoints in a js file and Voila, you can debug Typescript.
4. In the case of TypeScript, also make sure that you enable sourcemaps. As you probably know TypeScript isn't directly executed by the browser, but rather it is being "compiled" (or as it's called "transpiled") into JavaScript. That said, you probably don't wanna debug the transpiled JS but rather the TypeScript code you wrote. To enable sourcemaps, set the proper flag in your __tsconfig.json__:
```
{
@gmocamilotd
gmocamilotd / as
Last active October 29, 2017 04:53
# http://fontawesome.io/get-started/
Font Awesome CDN is the easiest way to get Font Awesome on your website or app,
all with just a single line of code. No downloading or installing!
## Download & Customize
Want to manage and host Font Awesome assets yourself? You can download, customize,
and use the icons and default styling manually.
Both CSS and CSS Preprocessor (Sass and Less) formats are included.
@gmocamilotd
gmocamilotd / in data base
Last active December 4, 2017 04:54
Ideally there would be a way for Postgres to handle both of these concerns: generate the string ensure its uniqueness source: https://stackoverflow.com/questions/19530736/how-can-i-generate-a-unique-string-per-record-in-a-table-in-postgres
CREATE FUNCTION make_uid() RETURNS text AS $$
DECLARE
new_uid text;
done bool;
BEGIN
done := false;
WHILE NOT done LOOP
new_uid := md5(''||now()::text||random()::text);
done := NOT exists(SELECT 1 FROM my_table WHERE uid=new_uid);
END LOOP;
@gmocamilotd
gmocamilotd / css
Last active December 7, 2017 13:29
#css asume claro que tiene un elemento cuyo ID es 'footer'
#footer {
position: fixed;
bottom: 0;
width: 100%;
}
### [Returning Command](https://www.postgresql.org/docs/9.5/static/dml-returning.html)
### [How to return result of a SELECT inside a function in PostgreSQL?](https://stackoverflow.com/questions/7945932/how-to-return-result-of-a-select-inside-a-function-in-postgresql)
### [varibles del entorno](https://www.postgresql.org/docs/8.3/static/plpgsql-statements.html)
### [PostgreSQL SQL Tricks](https://postgres.cz/wiki/PostgreSQL_SQL_Tricks)
### [System Information Functions](https://www.postgresql.org/docs/8.1/static/functions-info.html)
@gmocamilotd
gmocamilotd / elcss
Last active December 19, 2017 00:55
.left, .right {
float: none;
padding: 20px;
width: 50%;
vertical-align: top;
}
.container {
display: table;
width: 100%;
.row{
margin: 0px;
display: flex ;
align-items: center;
}
.panelinhorizontalcenter{
width:45%;
margin-left: 28%;
text-align: left;
@gmocamilotd
gmocamilotd / WindowRef
Last active January 9, 2018 15:24
angular access window object
import { Injectable } from '@angular/core';
function _window() : any {
// return the global native browser window object
return window;
}
@Injectable()
export class WindowRef {
get nativeWindow() : any {