Skip to content

Instantly share code, notes, and snippets.

View zhangbg's full-sized avatar

zhangbg zhangbg

View GitHub Profile
@mhudasch
mhudasch / Get-PendingWindowsUpdate.ps1
Last active June 12, 2018 08:27
Find pending windows updates.
Function Get-PendingWindowsUpdate {
[CmdletBinding()]
param(
[Parameter(Position = 0, ValueFromPipeline = $true)]
[string[]]$ComputerName = $env:COMPUTERNAME)
Process {
# Use this scriptblock for both remote and local execution
$unifiedScriptBlock = [scriptblock]{
param([string]$computer)
$ErrorActionPreference = $using:ErrorActionPreference;
@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active April 25, 2024 04:16
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@HereChen
HereChen / convert-image-to-base64.js
Last active March 29, 2022 11:31
convert image to base64
/**
* version1: convert online image
* @param {String} url
* @param {Function} callback
* @param {String} [outputFormat='image/png']
* @author HaNdTriX
* @example
convertImgToBase64('http://goo.gl/AOxHAL', function(base64Img){
console.log('IMAGE:',base64Img);
})
@xjamundx
xjamundx / blog-webpack-2.md
Last active April 21, 2024 16:20
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.

@nikku
nikku / browserify-requirejs-non-hating-comparison.md
Last active March 9, 2016 12:19
browserify-requirejs-non-hating-comparison

RequireJS / Browserify: A non-hating Comparison

This post attempts to compare RequireJS/AMD with Browserify/CommonJS as packaging and modularization approaches for modern web applications.

Look and Feel

A CommonJS/Browserify module

Modules are built according to the CommonJS pattern and work in both NodeJS and the browser. They export their dependencies through the module.exports key.

@oroce
oroce / package.json
Created April 25, 2014 08:42
run eslint only on changed (*.js files) files using pre-commit
{
"scripts": {
"eslint": "LIST=`git diff-index --name-only HEAD | grep .*\\.js | grep -v json`; if [ \"$LIST\" ]; then eslint $LIST; fi"
},
"devDependencies": {
"pre-commit": "0.0.7",
"eslint": "~0.5.1"
},
"pre-commit": [
"eslint"
@esfand
esfand / angular-jqlite.adoc
Last active April 19, 2023 01:32
Angular jqLite

Angular jqLite

jQuery and Angular

Angular doesn’t depend on jQuery. In fact, the Angular source contains an embedded lightweight alternative: jqLite. Still, when Angular detects the presence of a jQuery version in your page, it uses that full jQuery implementation in lieu of jqLite. One direct way in which this manifests itself is with Angular’s element abstraction. For example, in a directive you get access to the element that the directive applies to:

@gustavohenke
gustavohenke / svg2png.js
Created February 18, 2014 15:27
SVG to PNG
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
@chrisjlee
chrisjlee / querySelector.polyfill.js
Created February 12, 2014 17:39
IE document.querySelector() polyfill
if (!document.querySelectorAll) {
document.querySelectorAll = function (selectors) {
var style = document.createElement('style'), elements = [], element;
document.documentElement.firstChild.appendChild(style);
document._qsa = [];
style.styleSheet.cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}';
window.scrollBy(0, 0);
style.parentNode.removeChild(style);
@clintongormley
clintongormley / load_test_data.sh
Last active January 5, 2024 07:32
Run these commands in your shell to setup the test data for Chapter 5
curl -XPUT 'http://localhost:9200/us/user/1?pretty=1' -d '
{
"email" : "john@smith.com",
"name" : "John Smith",
"username" : "@john"
}
'
curl -XPUT 'http://localhost:9200/gb/user/2?pretty=1' -d '
{