Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Frank Fu frankfuu

🎯
Focusing
  • Sydney
Block or report user

Report or block frankfuu

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
View mongodb.js
/**
* Incrementing listening count
* creating a new listen element if artistID is not present
**/
var artistID, userID;
if (!db.users.findAndModify({
query: { userID: userID, 'listen.artistID': artistID },
update: { $inc: { 'listen.$.count': 1 } },
@frankfuu
frankfuu / Chart.extension.js
Last active Jan 28, 2016
An alternative version of the chart type named Doughnut in Chart.js
View Chart.extension.js
(function () {
// An alternative version of the chart type Doughnut in Chart.js
Chart.types.Doughnut.extend({
name: "DoughnutAlt",
defaults: this.defaultConfig,
draw: function () {
Chart.types.Doughnut.prototype.draw.apply(this, arguments);
this.chart.ctx.fillStyle = 'black';
this.chart.ctx.textBaseline = 'middle';
View vsts-bulk-install.ps1
Param(
[string]$pat,
[string]$url,
[string]$agentPrefix,
[string]$pool,
[string]$sourceDir,
[string]$tgtDirPrefix,
[int]$copies
)
View gist:3f83c2b70cecb10f9ba49cd02fa6d022
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 1/08/2018 1:47:49 AM.
Project "D:\projects\MyTestSolution\MyTestWebApplication\MyTestWebApplication.csproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "obj\Release\".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
@frankfuu
frankfuu / cloudfront-set-useragent-for-crawlers.js
Created Mar 5, 2019
cloudfront-set-useragent-for-crawlers
View cloudfront-set-useragent-for-crawlers.js
'use strict';
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
const headers = request.headers;
const uri = request['uri'];
const botPattern = "Googlebot\\/|Googlebot-Mobile|Googlebot-Image|Googlebot-News|Googlebot-Video|AdsBot-Google([^-]|$)|AdsBot-Google-Mobile|Mediapartners-Google|Mediapartners \\(Googlebot\\)|APIs-Google|bingbot";
var re = new RegExp(botPattern, 'i');
var userAgent = headers['user-agent'][0]['value'];
You can’t perform that action at this time.