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 / 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 / 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 / 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

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 / SketchSystems.spec
Last active Sep 28, 2018
Draft Email Flow
View SketchSystems.spec
Draft Email Flow
Clicked CTA
No action for one hour? -> Aborted Creation
Create Draft -> Initial Creation
Draft Created
Publish Trip -> Draft Published
Initial Creation*
Change Trip -> Initial Creation
No action for 1 hour? -> Active
Active
@Kamshak
Kamshak / Add New Button.md
Last active Jun 13, 2018
Pointshop 2 - Add external menu button
View Add New Button.md

Adding a button to the PS2 Inventory section

It's easy to add a button that opens another menu. Here a report menu button was added:

img

Create a new file in garrysmod/lua/autorun/ps2_extrabuttons.lua with the following contents:

AddCSLuaFile()
Pointshop2:AddInventoryButton( "Report Menu", "pointshop2/warning8.png", function( )
  -- Run console command to open the report menu
@Kamshak
Kamshak / README.md
Last active Jun 20, 2018
Serve firebase functions efficiently through express. Doesn't make the PC die as the cloud functions emulator does but is less accurate.
View README.md

Replacement for firebase functions:serve

Serve firebase functions efficiently through express. Doesn't make the PC die as the cloud functions emulator does but is a bit less closer to the real env they run in. Useful for dev.

This uses a simple express server to serve your functions. It's nice for developing as the restarting is much faster and it doesn't use as much of your CPU/Ram as the cloud functions emulator does.

Setup

  1. Make sure your firebase service account is saved to your functions config under the serviceacc key.
@Kamshak
Kamshak / 0Guide.MD
Last active Mar 24, 2018
Making Customizable Weaponry 2.0 Attachments work with Pointshop 2 Tutorial. Full Code: https://github.com/Kamshak/ps2-customizable-weaponry
View 0Guide.MD

Generating Pointshop 2 Items programatically

The goal here is to integrate an external system into Pointshop 2 by using items. Since they are already created we only need to map them to PS2 items. For this example Attachments for Customizable Weaponry 2 are used. CW2 offers a system where players can pick attachments in a menu. Players can only pick attachments that they own.

  1. Players should be able to buy attachments in Pointshop2
  2. Players should be given all attachments they own in Pointshop2 so that CW can pick them up
  3. It should be possible to set the price for the attachments individually
@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))
@Kamshak
Kamshak / cl_myview.lua
Last active Feb 20, 2018
LibK Networking
View cl_myview.lua
MyView = class( "MyView" )
MyView:include( BaseView )
-- Set the controller to use
MyView.static.controller = "MyController"
function MyView:OnMapChanged(map)
hook.Run("ServerMapChanged", map)
-- This is a useful pattern for derma updating:
--[[
function PANEL:Init()
You can’t perform that action at this time.