Skip to content

Instantly share code, notes, and snippets.

View mryap's full-sized avatar
💭
Seeking full-time employment

Mr. Yap mryap

💭
Seeking full-time employment
View GitHub Profile
@mryap
mryap / pandas_with_hvplot.ipynb
Created May 8, 2021 10:27
Pandas_with_hvplot.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mryap
mryap / how-to-extract-all-website-links.ipynb
Created May 8, 2021 10:10
Extract All Website Links.ipynb
@mryap
mryap / snippets-importing-libraries.ipynb
Created April 30, 2021 11:10
Snippets: Importing libraries
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Creating a variable in JavaScript is called ​'declaring a variable'​. You can declare a variable in JavaScript by using the keyword 'var'.

For example:

var _gaq;​ // create a variable and name it _gaq

Another example:

var pageTracker;​ // create a variable and name it pageTracker

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mryap
mryap / gist:179abac6aad45059999d7e80ad731479
Created April 12, 2021 11:03
Custom HTML code for Cookies consent
<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
<script>
var cookieName = 'trackingAccepted';
if(typeof Cookies.get(cookieName) !== 'undefined') {
$('.tracking-consent').remove();
}
$('.accept-tracking').on('click', function(){
@mryap
mryap / build-R-package.md
Last active May 6, 2021 07:43
Building and installing an R package

Building and installing an R package

If you’re using Windows, you’ll want to install Rtools.

using devtools

use Hadley Wickham’s devtools package. You can then build and install the package from within R.

Start R within your package directory (so that your package directory is R’s working directory).

Install devtools by typing (within R)

@mryap
mryap / export_data.md
Last active May 6, 2021 07:45
Exporting Data with readr package
# readr comes with 2 useful functions for exporting data
# write_csv() and write_tsv()
# Saving dates and date-times in ISO8601 format so they are easily parsed elsewhere.

write_csv(pu2, "pu2.csv")
@mryap
mryap / sampling_saves_time.ipynb
Created April 5, 2020 14:36
Sampling_Saves_Time.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mryap
mryap / intro.md
Last active May 6, 2021 07:48
Predict Visitor Purchases with a Classification Model with BigQuery ML

Question: Out of the total visitors who visited our website, what % made a purchase?

#standardSQL
WITH visitors AS(
SELECT
COUNT(DISTINCT fullVisitorId) AS total_visitors
FROM `data-to-insights.ecommerce.web_analytics`
),

purchasers AS(