Skip to content

Instantly share code, notes, and snippets.

View weilinzung's full-sized avatar

Wei weilinzung

  • Canada
View GitHub Profile
/* Change all src urls loaded from external urls
* to dataUrls stored on the local storage.
*/
var changeAllSrcToDataUrl = function() {
// Get all images on page or element to render
$("img").each(function() {
var image = this;
// If it last image, proceed to canvas rendering
var isLast = this === $("img")[$("img").length - 1] || false;
(function () {
function getCurrentSeason() {
var now = new Date();
var currentYear = now.getFullYear();
if (now < new Date(currentYear, 2, 1)) {
// [Jan 1 ~ Mar 1)
return 'winter';
@shkaper
shkaper / index.js
Created November 21, 2018 12:42
puppeteer screenshot all DOM nodes
const puppeteer = require('puppeteer')
;(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://youtube.com');
// get a list of all elements - same as document.querySelectorAll('*')
const elements = await page.$$('*')
@AndrejsAbrickis
AndrejsAbrickis / .bowerrc
Last active March 20, 2019 00:35
Migrate from bower to webpack
{
"directory": "wwwroot/scripts/bower"
}
@radarseven
radarseven / README.md
Created August 1, 2017 03:57 — forked from amir-rahnama/README.md
A simple Webpack (with Dev Server) + Gulp Configuration + LiveReload + Babel to playground where you can code ES6 without the need for React

A simple Webpack + Gulpfile configuration wihtout any need for React.js that assumes you have the following project structure:

node_modules/ bower_components/ scripts/

Entry script is in scripts/entry.js

You should run gulp && gulp build-dev and you are good to go.

@JMPerez
JMPerez / directions-map.js
Last active September 24, 2019 23:17
HTML5 geoposition + Google Geocoder as a fallback, used to show directions from user's current position to a given destination. See http://jmperezperez.com/google-maps-geolocation-directions-specific-destination/
(function() {
'use strict';
var map, //the google map
directionsService, //service that provides directions to reach our destination
directionsDisplay, //renderer that draws directions on map
destinationName = 'Ventorro del Cano, Madrid'; //our destination. Set yours!
// providers
var html5Provider = function() {
return {
@Toxicable
Toxicable / file-upload.component.ts
Created October 23, 2016 07:18
How to upload files in angular 2
/**
* Created by Fabian on 19/10/2016.
*/
import { Component, ElementRef, Input } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'file-upload',
template: '<input type="file" [attr.multiple]="multiple ? true : null" (change)="upload()" >'
})
export class FileUploadComponent {
@omurphy27
omurphy27 / bootstrap collapse accordion with ACF repeater loop.php
Last active December 3, 2019 14:39
bootstrap collapse accordion with ACF repeater loop.php
<?php if( have_rows('faqs') ): ?>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php $i=1; while ( have_rows('faqs') ) : the_row(); ?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-<?php echo $i; ?>">
<h2 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse-<?php echo $i; ?>" aria-expanded="true" aria-controls="collapseOne">
<?php the_sub_field('question'); ?>
</a>
</h2>
@nicbet
nicbet / _Webpack-Fontawesome-Bootstrap-Phoenix.md
Last active April 28, 2020 05:43
Sass versions of Bootstrap 4 and Fontawesome 5 with Elixir / Phoenix Framework 1.3.x and 1.4.x using Webpack

SASS Versions of

  • Fontawesome 5
  • Bootstrap 4

in Phoenix 1.3 and 1.4 via Webpack

@kohlmannj
kohlmannj / customDevServer.js
Created July 9, 2017 22:43
An example of using BrowserSync, webpack-dev-middleware, and webpack-hot-middleware together in a script that boots up a custom dev server
#! /usr/bin/env node
/* eslint-env node */
// Boot it up with:
// $ node customDevServer.js
// ...or:
// $ chmod +X customDevServer.js
// $ ./customDevServer.js
const webpack = require('webpack');