Skip to content

Instantly share code, notes, and snippets.

@IgorMinar
IgorMinar / _purify.md
Last active March 30, 2017 11:55
purify.js with cli and webpack plugin - simple and super-hackish Uglify pre-optimizer

This is a super-hacky tool that processes JavaScript bundless before they are fed to Uglify.

Purify adds @__PURE__ annotation in front of all IIFE's that represent ES classes downleveled by TypeScript.

This annotation then enables Uglify 2.8+ to safely recognize if the class is not used and remove it.

You can use it webpack-plugin or cli.

Angular developers will need the bundle to be also processed by alxhub/ngo before the full effect can be seen.

@IgorMinar
IgorMinar / angular-cli-vendor-sourcemaps.patch
Created March 22, 2017 17:57
Patch @angular/[email protected] to enable vendor source maps
--- common.js.orig 2017-03-22 10:53:54.000000000 -0700
+++ common.js 2017-03-22 10:54:37.000000000 -0700
@@ -69,7 +69,7 @@
},
module: {
rules: [
- { enforce: 'pre', test: /\.js$/, loader: 'source-map-loader', exclude: [nodeModules] },
+ { enforce: 'pre', test: /\.js$/, loader: 'source-map-loader'},
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.html$/, loader: 'raw-loader' },
/**
* ================== angular-ios9-uiwebview.patch.js v1.1.1 ==================
*
* This patch works around iOS9 UIWebView regression that causes infinite digest
* errors in Angular.
*
* The patch can be applied to Angular 1.2.0 1.4.5. Newer versions of Angular
* have the workaround baked in.
*
* To apply this patch load/bundle this file with your application and add a
@IgorMinar
IgorMinar / angular-bc.js
Created April 2, 2012 22:14 — forked from vojtajina/angular-bc.js
Angular: BC module for scope/controller separation
/**
* @license AngularJS
* (c) 2010-2012 AngularJS http://angularjs.org
* License: MIT
*/
/**
* Backward compatibility module for AngularJS
* @author Vojta Jina <[email protected]>
*
/// bootstrap code
var myApp = angular.module('myApp', []);
//// resource def
var pops;
pops = function($resource) {
return $resource('/pops/:id', {}, {
describe('html', function() {
- it('should replace element with template', inject(
+ iit('should replace element with template', inject(
function($compileProvider){
$compileProvider.directive('replace', valueFn({
- html: '<div class="myWidget" new="newAttr"><<CONTENT>></div>',
+ html: '<div class="myWidget" new="newAttr">{{foo}} <<CONTENT>></div>',
compile: function(element, attr){
attr.$set('compile', true);
@IgorMinar
IgorMinar / gist:1474608
Created December 14, 2011 00:22
Misko's antiminification
case 8: /* Comment */
match = COMMENT_DIRECTIVE_REGEXP.exec(node.nodeValue);
- if (match &&
- (directive = getDirective(nName = camelCase(match[1])))) {
- attrs[nName] = trim(match[2]);
- directives.push(directive);
+ if (match) {
+ nName = camelCase(match[1]);
+ directive = getDirective(nName);
+ if (directive) {
@IgorMinar
IgorMinar / angular-ctrl-export-proposal.js
Created December 13, 2011 05:44 — forked from vojtajina/angular-ctrl-export-proposal.js
Angular: Export Ctrl Methods Proposal
function($ctrlProvider) {
$ctrlProvider.provide('FooCtrl', FooCtrl);
var export = $ctrlProvider.export;
function FooCtrl($http, $scope) {
this.scope_ = $scope;
this.http_ = $http;
}
FooCtrl.prototype.publicMethodA = export(function(){
<html>
<head>
<script src="http://code.angularjs.org/angular-0.10.3.js" ng:autobind></script>
<script>
function MyCntrl() {
this.list_of_items = ['this', 'that', 'the other'];
this.foo = {choice:'that'};
}
MyCntrl.prototype = {
loadData: function(){
@IgorMinar
IgorMinar / gist:1030586
Created June 16, 2011 23:49 — forked from pmenglund/gist:1028805
Angular
<html>
<head>
<script src="http://code.angularjs.org/angular-0.9.16.min.js" ng:autobind></script>
<script>
function CalculatorController() {
this.integer = /^\d+$/;
this.fraction = /^\d+\.*\d*$/;
this.difficulty = 877226;
this.hashtime = function() { return Math.round(this.difficulty * Math.pow(2, 32) / (this.hashrate * 1000))/(3600*24) };
this.opex = function() { return this.time*24 * this.electricity * this.power / 1000 };