Skip to content

Instantly share code, notes, and snippets.

Bartosz Bobin bartoszbobin

Block or report user

Report or block bartoszbobin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bartoszbobin
bartoszbobin / ICalendarParser.ts
Created Apr 10, 2018
Simple ICalendar Parser to JS Objects
View ICalendarParser.ts
/**
* @copyright bartosz.bobin
*/
export class ICalendarParser {
skipNotStandardKeys = true;
parse(text: string) {
const lines = text.replace(/\n /g, '').split(/\n/);
let obj = {vcalendar: undefined};
@bartoszbobin
bartoszbobin / example.js
Last active Jul 5, 2017
Javascript - pobranie pliku z backendu na front FF i przekazanie do pobrania, Chrome, Edge, Safari, IE10+
View example.js
var xhr = new XMLHttpRequest();
xhr.open('POST', 'nasz-url', true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
// należy wymusić 'arraybuffer'
xhr.responseType = 'arraybuffer';
xhr.onload = onLoad;
xhr.send();
function onLoad() {
if (this.status !== 200) {
@bartoszbobin
bartoszbobin / example.js
Created Jul 5, 2017
Javascript - pobranie pliku z backendu na front FF, Chrome, Edge, Safari, IE10+
View example.js
var xhr = new XMLHttpRequest();
xhr.open('POST', 'nasz-url', true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
// należy wymusić 'arraybuffer'
xhr.responseType = 'arraybuffer';
xhr.onload = onLoad;
xhr.send();
function onLoad() {
if (this.status === 200) {
@bartoszbobin
bartoszbobin / router-history.ts
Last active Sep 20, 2016
UI Router History Service
View router-history.ts
import IStateService = angular.ui.IStateService;
import IRootScopeService = angular.IRootScopeService;
import IState = angular.ui.IState;
class RouterHistory
{
private history : IHistoryEntry[] = [];
public add(stateName : string, stateParams : any) : void
{
@bartoszbobin
bartoszbobin / const-enum.ts
Created Sep 19, 2016
TypeScript enum vs const enum
View const-enum.ts
// TypeScript
const enum Beta { X, Y, Z }
const A : Beta = Beta.X;
// JavaScript
var Beta;
(function (Beta) {
Beta[Beta["X"] = 0] = "X";
Beta[Beta["Y"] = 1] = "Y";
View current.ts
'use strict';
// file: route.cfg.ts
class RouteConfig
{
public static $inject = ['$stateProvider'];
public constructor($stateProvider : angular.ui.IStateProvider){
$stateProvider
.state("home", {
@bartoszbobin
bartoszbobin / any.ts
Last active Aug 29, 2015
TypeScript - types
View any.ts
enum Color {
RED, GREEN, BLUE
}
class MyClass {}
var myAny: any;
myAny = 'aaa';
myAny = true;
myAny = 0.00;
myAny = undefined;
@bartoszbobin
bartoszbobin / gist:5f4abad19b298ddbc682
Last active Aug 29, 2015
TypeScript - Hello World
View gist:5f4abad19b298ddbc682
function test(name: string): any {
if ('bart' === name) {
return 1929;
}
return "Hello " + name;
}
alert(test('Bart'));
You can’t perform that action at this time.