Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

David Rearte dengue8830

🎯
Focusing
View GitHub Profile
@dengue8830
dengue8830 / baseModelWithWhiteList.js
Last active Jan 8, 2017
Whitelist function for the backbone base model. This allows me to select which attributes i want to send to the server or something else
View baseModelWithWhiteList.js
//Define the base model
var BaseModel = Backbone.Model.extend({
toJSON: function(options) {
options = options || {};
var json;
if(!!options.whiteList)
json = _.pick(this.attributes, options.whiteList);
else if(!!options.blackList)
json = _.omit(this.attributes, options.blackList);
else
@dengue8830
dengue8830 / sortByTwoFields.js
Created Jan 8, 2017
Very simple backbone sorted collection by two fields. Simplified version of https://gist.github.com/nordyke/1524046#file-multisortcollection-js-L44
View sortByTwoFields.js
//Original code https://gist.github.com/nordyke/1524046#file-multisortcollection-js-L44
function sortAthletes(athletes){
//points is the first criteria
//we sort athletes by points and make a group for all wich have the same points
var sortedGroups = _(athletes.models).chain().
sortBy(function (model) {
return -model.get('points');
}).
groupBy(function (model) {
return -model.get('points');
@dengue8830
dengue8830 / activity_item_detail
Created Jan 31, 2017
Detail layout with collapsing toolbar from android studio examples
View activity_item_detail
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.amla.pruebaconradiotulsdk.ItemDetailActivity"
tools:ignore="MergeRootFrame">
<android.support.design.widget.AppBarLayout
View ts-node scripts on package.json
"scripts": {
"start": "./node_modules/.bin/ts-node ./server.ts",
"watch": "./node_modules/.bin/nodemon -V -w . --ext \".ts\" --exec \"npm run start\""
}
@dengue8830
dengue8830 / SearchBox.tsx
Last active May 23, 2018
Simple react typeahead component
View SearchBox.tsx
// Works with this typeahead https://github.com/bassjobsen/Bootstrap-3-Typeahead
// but its easy to change to another lib
import * as React from 'react';
const $ = window.$;
export interface SearchParams {
query: string;
callback: (items: any) => void;
@dengue8830
dengue8830 / instalar-java-linux.md
Last active Jul 13, 2018
Para instalar java en distros basadas en linux (desactualizado pero vale)
View instalar-java-linux.md
View templates-react-native.md
View typescript.json
{
"Crea nuevo modelo": {
"prefix": "snpNuevoModelo",
"body": [
"import { Errores } from './errores';",
"",
"export interface I${1:}Attrs {",
" id?: string;",
" ${2:};",
"}",
@dengue8830
dengue8830 / http.ts
Created Dec 9, 2018
Http wrapper allow us changing the implementation and defining our custom http response/request interfaces
View http.ts
import axios, { AxiosInstance, AxiosPromise, AxiosRequestConfig } from 'axios';
import { ErrorExtra } from '../models/errores';
export class HttpError extends ErrorExtra {
status: HttpErrorCode;
constructor(status: HttpErrorCode, mensaje: string = '', extra?: any) {
super(mensaje, extra);
this.status = status;
// Esto quita este constructor del stacktrace pero solo esta disponible en node, no browsers
@dengue8830
dengue8830 / android_app_build.gradle
Last active Dec 9, 2018
react-native-background-geolocation + firebase + react-native-maps
View android_app_build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"