Skip to content

Instantly share code, notes, and snippets.

@pietmichal
pietmichal / arena_allocator_and_object_pool_example.c
Last active September 17, 2023 21:28
Cross-platfrom Example of Arena Allocator And Object Pool Working With C99 And C++ Compilers.
// Example implementation of simple Arena Allocator and simple Object Pool that works with C99 and C++ compilers.
//
// Check the bottom of the file to see the license.
//
// Enjoy!
#include <stdio.h>
#include <malloc.h>
#include <string.h>
function retryablePromise(retries) {
return new Promise((resolve, reject) => {
reject();
})
.catch(() => {
if (retries > 0) {
return retryablePromise(retries - 1);
} else {
return Promise.reject();
@pietmichal
pietmichal / tabs.component-fragment.ts
Last active January 8, 2017 20:58
Medium tutorial part5
onTabClick(tab: TabComponent) {
this.currentTab = tab;
}
isSelected(tab: TabComponent) {
return this.currentTab.name === tab.name;
}
@pietmichal
pietmichal / tabs.component.css
Last active January 8, 2017 21:02
Medium tutorial part4
span {
float: left;
padding: 5px;
background-color: #D0CCD0;
border-radius: 5px 5px 0 0;
color: #828181;
font-size: 14px;
cursor: pointer;
}
@pietmichal
pietmichal / tabs.component.ts
Last active January 8, 2017 20:05
Medium tutorial part3
@Component({
selector: 'app-tabs',
template: ``,
})
export class TabsComponent implements AfterContentInit {
@ContentChildren(TabComponent) tabList: QueryList<TabComponent>;
currentTab: TabComponent;
ngAfterContentInit() {
@pietmichal
pietmichal / tab.component.ts
Created January 8, 2017 19:31
Medium tutorial part2
@Component({
selector: 'app-tab',
template: '',
})
export class TabComponent {
@Input() name: string;
@Input() templateRef: TemplateRef;
}
@pietmichal
pietmichal / app.component.ts
Last active January 8, 2017 19:31
Medium tutorial part1
@Component({
selector: 'app',
template: `
<app-tabs>
<app-tab name="First" [templateRef]="firstRef"></app-tab>
<app-tab name="Second" [templateRef]="secondRef"></app-tab>
<app-tab name="Third" [templateRef]="thirdRef"></app-tab>
</app-tabs>
<template #firstRef>
@pietmichal
pietmichal / ContentProjection.ts
Last active March 30, 2017 22:03
Angular 2.x - Template Outlet vs Content Projection
@Component({
selector: 'app',
template: `
<h1>Angular's content projection and lifecycle example</h1>
<app-content>
<app-nested-component></app-nested-component>
</app-content>
`,
})
export class App {}