This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local TrailcheckerMixin = {} | |
function TrailcheckerMixin:included( klass ) | |
local oldThink = klaas.Think | |
klass.Think = function(self) | |
oldThink(self) | |
if IsValid(self.trailEnt) then | |
local shouldDraw = hook.Run("PS2_VisualsShouldShow", self:GetOwner()) == false | |
self.trailEnt:SetNoDraw(not shouldDraw) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function retryHttp<T>(retryCount: number, shouldRetry: (error: { code: number }) => boolean) { | |
return (request$: Observable<T>): Observable<T> => request$.retryWhen( | |
errors$ => errors$.flatMap(error => { | |
if (shouldRetry(error)) { | |
return Observable.of(true).delay(1000); | |
} | |
return Observable.throw({ error: 'Error cannot be retried', originalError: error }); | |
}).take(5) | |
.concat(Observable.throw(`Request failed after ${retryCount} retries.`)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/1.2.2/bluebird.js"></script> | |
<script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent { | |
routerLoading$: Observable<boolean>; | |
constructor(private router: Router) { | |
this.routerLoading$ = this.router.events.flatMap(event => { | |
if (event instanceof NavigationStart) { | |
return [true]; | |
} | |
if (event instanceof NavigationEnd || | |
event instanceof NavigationCancel || | |
event instanceof NavigationError) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ITEM.baseClass = "base_hat" | |
ITEM.PrintName = "Jump Pack" | |
ITEM.Description = "Makes you jump higher!" | |
ITEM.Price = { | |
points = 1000, | |
} | |
ITEM.static.validSlots = { | |
"Accessory", | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('beforeunload', | |
function(){ | |
ga('send', 'event', 'Website', 'Unload', {transport: 'beacon', nonInteraction:true}); | |
} | |
); | |
var timeout = 1; | |
var startTime = new Date().getTime(); | |
function startBeacon() { | |
var timeOnSite = (startTime - new Date().getTime()) / 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function GiveRandomItemFromCategory( ply, categoryName ) | |
local factory = Pointshop2.ItemFromCategoryFactory:new() | |
factory.settings = { | |
["ManualSettings.CategoryName"] = categoryName, | |
["BasicSettings.WeightedRandom"] = true | |
} | |
local item = factory:CreateItem( true ) | |
return ply:PS2_EasyAddItem( item.class.className ) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local str = LibK._(Pointshop2.GetRegisteredItems()):chain() | |
:map(function(item) | |
return { className = item.className, name = item:GetPrintName() } | |
end) | |
:sort(function(a, b) | |
if tonumber(a.className) and tonumber(b.className) then | |
return tonumber(a.className) < tonumber(b.className) | |
elseif tonumber(a) and not tonumber(b) then | |
return false | |
else |