Skip to content

Instantly share code, notes, and snippets.

View jerkovicl's full-sized avatar

Luka Jerković jerkovicl

View GitHub Profile
@jerkovicl
jerkovicl / JSFUN.md
Created January 23, 2014 13:49 — forked from azat-co/JSFUN.md

JS FUNdamentals

If it's not fun, it's not JavaScript.

Expressiveness

Programming languages like BASIC, Python, C has boring machine-like nature which requires developers to write extra code that's not directly related to the solution itself. Think about line numbers in BASIC or interfaces, classes and patterns in Java.

On the other hand JavaScript inherits the best traits of pure mathematics, LISP, C# which lead to a great deal of expressiveness (and fun!).

Hello there! This is a sample post for gist.io, a super-lightweight writing soapbox for hackers.

Now look up. Further. Above the post title. See that grey text with the gist ID?

Now back to me. That grey text is a link! Open that sucker in a new tab to see the source for this post. Also, I'm on a horse.

This is a major heading

If you peek at it with a web inspector, you'll see that it is a second-level heading. You can use first level headings, but they'll look just like the second level ones, and the gods of the HTML5 outlining algorithm will frown upon you.

@jerkovicl
jerkovicl / Gulpfile.js
Last active August 29, 2015 13:56
Gulpfile to minify and concatenate the JavaScript files
// include gulp
var gulp = require('gulp');
// include plug-ins
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
//var imagemin = require('gulp-imagemin');
@jerkovicl
jerkovicl / index.html
Created February 26, 2014 08:54
paste.js demo
<!doctype html>
<html>
<head>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="paste.js"></script>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<title>paste.js</title>
<link href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.0/normalize.min.css" media="screen" rel="stylesheet" type="text/css" />
</head>
@jerkovicl
jerkovicl / View.html
Created February 28, 2014 08:29
JSON to HTML example
<script type="text/javascript">
$(document).ready(function () {
var sf = $.ServicesFramework(-1);
// Send an AJAX request
$.getJSON(sf.getServiceRoot('eTailer.NewProducts') + "NewProductsAPI/GetNewProducts?CategoryId=2&Top=10",
function (data) {
// On success, 'data' contains a list
$.each(data, function (key, val) {
// Format the text to display.
var pageres = require('pageres');
pageres(['todomvc.com'], ['1366x768', '1600x900'], function () {
console.log('done');
});
//via node.js command
/**
* Track JS error details in Universal Analytics
*/
function trackJavaScriptError(e) {
var errMsg = e.message;
var errSrc = e.filename + ': ' + e.lineno;
ga('send', 'event', 'JavaScript Error', errMsg, errSrc, { 'nonInteraction': 1 });
}
@jerkovicl
jerkovicl / AngularJS_snippets.md
Last active August 29, 2015 14:04
Collection of AngularJS snippets

AngularJS snippets

New feature in AngularJS 1.3.0

  • Strict DI – an option for finding places in your application that will not minify due to use of short-hand DI syntax

ng-app ng-strict-di

Angular code convention example

@jerkovicl
jerkovicl / AjaxRetryRequest.js
Last active August 29, 2015 14:05 — forked from aeurielesn/gist:2511005
Retrying a jQuery.ajax() call
$.ajax({
url: '/echo/error/',
async: true,
// retryCount and retryLimit will let you retry a determined number of times
retryCount: 0,
retryLimit: 10,
// retryTimeout limits the total time retrying (in milliseconds)
retryTimeout: 10000,
// timeout for each request
timeout: 1000,
@jerkovicl
jerkovicl / querySelector.md
Last active August 29, 2015 14:05
querySelector example
  • Syntax
element = document.querySelector(selectors);
  • Example
var select = document.querySelector;
var el = select("#id");
var el2 = select(".myclass");