Skip to content

Instantly share code, notes, and snippets.

@bostjanpisler
bostjanpisler / moment.pipe.ts
Created January 24, 2016 12:59
angular 2 moment pipe
import {Pipe, PipeTransform} from 'angular2/core';
import * as moment from 'moment';
/*
* Time helper using momentjs
* Usage:
* timestamp | moment:'DD.MM.YYYY'
* Defaults to 'L' - locale ie. '01/24/2016'
*/
@bostjanpisler
bostjanpisler / scoreboards.service.ts
Created January 24, 2016 01:53
js sort function
_sortRank(a, b) {
if (a.sumPoints > b.sumPoints) {
return -1;
} else if (a.sumPoints < b.sumPoints) {
return 1;
} else {
return 0;
}
}
@bostjanpisler
bostjanpisler / ionic2-button-loader-and-text
Last active May 3, 2016 14:08
Ionic 2 directive loader which is placed inside button instead of text
// Usage
// Only tested with normal size button, will update if required
<my-loader [loading]="loading" defaultText="LOGIN"></my-loader>
// loader.ts
import { Component, Input } from 'angular2/core';
@Component({
selector: 'my-loader',
template: `
@bostjanpisler
bostjanpisler / user.coffee
Created January 10, 2016 14:57
Sequelize transaction for User -> hasMany -> Organization / Organization -> belongsTo -> User
# Correct way to save related model data with transaction
# A transaction is required if we want validation of related model data
# Sequelize docs don't provide exact instructions for this
await db.sequelize.transaction((t) ->
return db.User.create(data, { transaction: t, fields: ['email', 'password'] }).then((user) ->
return user.createOrganization(data.org, { transaction: t, fields: ['name'] });
)
).nodeify defer err, user
@bostjanpisler
bostjanpisler / Najdi.si Free SMS
Last active December 23, 2015 11:19
Najdi.si Free SMS koda
curl 'http://www.najdi.si/sms/smsController.jsp?sms_action=4&sms_so_ac_1379610636358=FIRST_PART_OF_NUMBER(IE.04)&sms_so_l_1379610636358=SND_PART(123)%20TRD_PART(123)&myContacts=&sms_message_1379610636358=MESSAGE_HERE' -H 'Host: www.najdi.si' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:23.0) Gecko/20100101 Firefox/23.0' -H 'Accept: text/javascript, text/html, application/xml, text/xml, */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'X-Requested-With: XMLHttpRequest' -H 'X-Prototype-Version: 1.6.0.3' -H 'Referer: http://www.najdi.si/index.jsp?sms_show' -H 'Cookie: JSESSIONID=806BA833D63D03994F895F6A1EC500C2; poll=""; MAdUTCID=0c8572cb.IP_HERE.1379610620813; chkcookie=1379610636816; iduseron=USER_NAME; adp_partner=1'