Skip to content

Instantly share code, notes, and snippets.

Valentin Funk Kamshak

Block or report user

Report or block Kamshak

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
@Kamshak
Kamshak / NetlifyServerPushPlugin.js
Last active Jan 22, 2020
Webpack - Generate Netlify HTTP2 Server Push _headers File when using the HtmlWebpackPlugin
View NetlifyServerPushPlugin.js
/**
* Generate a Netlify HTTP2 Server Push configuration.
*
* Options:
* - headersFile {string} path to the _headers file that should be generated (relative to your output dir)
*/
function NetlifyServerPushPlugin(options) {
this.options = options;
}
@Kamshak
Kamshak / README.md
Last active Dec 7, 2019 — forked from peak-load/README.md
Headless A2DP Audio Streaming on Raspbian Stretch
View README.md

About

This gist will show how to setup Raspbian Stretch as a headless Bluetooth A2DP audio sink. This will allow your phone, laptop or other Bluetooth device to play audio wirelessly through a Rasperry Pi.

Motivation

A quick search will turn up a plethora of tutorials on setting up A2DP on the Raspberry Pi. However, I felt this gist was necessary because this solution is:

  • Automatic & Headless - Once setup, the system is entirely automatic. No user iteration is required to pair, connect or start playback. Therefore the Raspberry Pi can be run headless.
  • Simple - This solution has few dependencies, readily available packages and minimal configuration.
  • Up to date - As of December 2017. Written for Raspbian Stretch & Bluez 5.43

Prerequisites

@Kamshak
Kamshak / README.md
Created Dec 7, 2019 — forked from peak-load/README.md
Headless A2DP Audio Streaming on Raspbian Stretch
View README.md

About

This gist will show how to setup Raspbian Stretch as a headless Bluetooth A2DP audio sink. This will allow your phone, laptop or other Bluetooth device to play audio wirelessly through a Rasperry Pi.

Motivation

A quick search will turn up a plethora of tutorials on setting up A2DP on the Raspberry Pi. However, I felt this gist was necessary because this solution is:

  • Automatic & Headless - Once setup, the system is entirely automatic. No user iteration is required to pair, connect or start playback. Therefore the Raspberry Pi can be run headless.
  • Simple - This solution has few dependencies, readily available packages and minimal configuration.
  • Up to date - As of December 2017. Written for Raspbian Stretch & Bluez 5.43

Prerequisites

@Kamshak
Kamshak / README.md
Created Jan 18, 2019
Fixes SVG Gradients for Safari by changing fill URLs to the current pathname. Also fixes xlink:href URLs.
View README.md

Snippet to fix SVG issues in Angular (2+) with Safari, Firefox and Chrome

This listens to Angular route changes and on route change does the following:

  1. Replaces the link in <use xlink:href="#some-id"></use> by a path prefixed version
  2. Replaces the fill property in referenced SVGs by a path prefixed version
  3. Replaces the style in <svg style="fill: url(#gradient)"> with a prefixed version

Adapted from Gist by Leon Derijke

@Kamshak
Kamshak / retry.ts
Created Aug 8, 2019
Retry rate limited request on node using bluebird-retry
View retry.ts
import * as retry from 'bluebird-retry';
function isRateLimitOrTempError(err: Error & { statusCode?: number }) {
return err.statusCode && (
err.statusCode == 429 // Rate Limit
|| err.statusCode == 502 // Temporary error, retry again
);
}
function retryOnRateLimited<T>(request: () => Promise<T>): Promise<T> {
return retry(request, {
@Kamshak
Kamshak / some.component.html
Created Jan 4, 2017
Angular 2 Waypoints using ng2-scrollspy
View some.component.html
<div scrollSpy>
<div [waypoint]="i" *ngFor="let i of [1,2,3,4,5,6,7,8]">
{{ i }}
</div>
</div>
@Kamshak
Kamshak / discriminate.ts
Created Apr 9, 2019
discriminated union discriminate out
View discriminate.ts
export type Discriminate<
Union,
Prop extends keyof Union,
Discriminator extends Union[Prop],
> = Union extends { [T in Prop]: Extract<Union[Prop], Discriminator> } ? Union : never;
export type DiscriminateByType<
Union extends { type: any },
D extends Union['type']
> = Discriminate<Union, 'type', D>;
@Kamshak
Kamshak / action.lua
Created Feb 21, 2018
Prometheus Action for increasing player's pointshop 2 inventory size (slots)
View action.lua
Pointshop2.DB.DoQuery(Format("UPDATE inventories SET numSlots = numSlots + 40 WHERE ownerId = (SELECT id FROM libk_player WHERE player = %s)", Prometheus.Temp.SteamID))
Prometheus.Temp.Ply.fullyLoadedPromise:Then(function() Pointshop2Controller:initializeInventory(Prometheus.Temp.Ply))
View border.html
<html>
<head>
<style>
.rounded-corners-gradient-borders {
width: 300px;
height: 80px;
border: double 2px transparent;
border-radius: 80px;
background-image: linear-gradient(white, white), radial-gradient(circle at top left, #f00,#3020ff);
background-origin: border-box;
@Kamshak
Kamshak / UserModule.ts
Last active Oct 9, 2018
@ngrx/store and @ng-bootstrap/ng-bootstrap NgbModal
View UserModule.ts
@NgModule({...})
export class UserModule {
constructor(
ngbModal: NgbModal,
modalService: ModalService,
store: Store<AppState>
) {
// Disallow closing the login modal if user is accessing a protected route as first page.
// (else they would get an empty page due to the auth guard)
let loginModalOptions = store.select(x => x.user.loginRequired)
You can’t perform that action at this time.