Skip to content

Instantly share code, notes, and snippets.

View capaj's full-sized avatar
🏠
Always working-be it from home or elsewhere

Jiri Spac capaj

🏠
Always working-be it from home or elsewhere
View GitHub Profile
export default function downscaleImage(opts) {
var img = opts.img;
var type = opts.type;
var quality = opts.quality;
var tmp = new Image();
var tmp2 = new Image();
var canvas, context, cW, cH;
type = type || 'image/jpeg';
@capaj
capaj / store.js
Created June 28, 2015 11:52
localStorage stored store
window.onbeforeunload = function() {
localStorage.setItem('store', JSON.stringify(store));
};
const store = {};
Object.assign(store, JSON.parse(localStorage.getItem('store')));
export default store;
@capaj
capaj / app-config.js
Created May 27, 2015 09:07
useful config for your angular apps
app.config(function($compileProvider) {
if (!location.host.match(/localhost/)) {
$compileProvider.debugInfoEnabled(false);
}
})
@capaj
capaj / gist:f38b2a047a8f42563f81
Created May 26, 2015 17:09
output of socket.io-rpc-client install via jspm
System.config({
"baseURL": "/",
"transpiler": "babel",
"babelOptions": {
"optional": [
"runtime"
]
},
"paths": {
"*": "*.js",
var setCaretPosition = function (elem, caretPos) {
var sel = window.getSelection();
var range = document.createRange();
range.setStart(elem.firstChild, caretPos);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
};
@capaj
capaj / bundle-it.js
Last active August 29, 2015 14:19
jspm bundling for all of config.js
var jspm = new require('jspm');
var builder = jspm.Builder();
var ignorePackages = [
'traceur',
'traceur-runtime',
'babel',
'babel-runtime'
];
var packages = Object.keys(builder.loader.map).filter(function (pckgName){
@capaj
capaj / using npm.commands.search
Created March 17, 2015 18:13
example how to use npm.commands.search to search for packages
@capaj
capaj / karma.conf.js
Created February 3, 2015 10:31
showcasing my karma-jspm conf
module.exports = function(config) {
var browser = 'PhantomJS';
if (process.env.NODE_ENV === 'development') {
browser = 'Chrome'; //chrome is much better, because it shows properly line numbers
}
config.set({
// base path, that will be used to resolve files and exclude
basePath: '../',
@capaj
capaj / index.html
Created January 21, 2015 22:32
non working angular-material inputs
<!DOCTYPE html>
<html>
<head>
<!-- Angulars Material CSS now available via Google CDN; version 0.6 used here -->
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/angular_material/0.6.1/angular-material.min.css">
<!-- Angular Material Dependencies -->
<script src="//cdn.jsdelivr.net/hammerjs/2.0.4/hammer.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.min.js"></script>
@capaj
capaj / index.html
Last active August 29, 2015 14:11
minimal node.js, angular and github auth example
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<base href="/">
<title>app</title>
</head>
<body>
<button ng-click="loginGH()">Login</button>