Skip to content

Instantly share code, notes, and snippets.

View piotrlewandowski's full-sized avatar

Piotr Lewandowski piotrlewandowski

View GitHub Profile
@piotrlewandowski
piotrlewandowski / 0_reuse_code.js
Created December 26, 2013 18:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
window._eventLog = (function(longTime, important) {
var eventLog = [];
eventLog.getLongEvents = function(time) {
time = time === undefined ? longTime : time;
return this.filter(function(el) {
return el.time > time;
})
}
// Should we filter mousemove?
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
@piotrlewandowski
piotrlewandowski / ie11-only.md
Last active August 29, 2015 14:26 — forked from mgol/ie11-only.md
How to easily not serve JS and/or CSS to IE<11

Here's how to make your site not load CSS and/or JS in IE older than 11:

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=8,9,11">
        <title>Page title</title>
        <!--[if !IE]>-->
 
@piotrlewandowski
piotrlewandowski / index.html
Last active September 21, 2015 18:30 — forked from mszynka/index.html
CSS stylesheet lazyloader
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>LazyLoader</title>
<noscript>
<link href="style.css" rel="stylesheet">
</noscript>
</head>
<body>
@piotrlewandowski
piotrlewandowski / jshintrc
Created October 4, 2015 17:32 — forked from bryanchriswhite/jshintrc
Angular project's .jshintrc file for use with grunt and the jshint plugin.
{
"node" : true,
"browser" : true,
"es5" : true,
"esnext" : true,
"bitwise" : true,
"camelcase": true,
"curly" : true,
"eqeqeq" : true,
"immed" : true,
@piotrlewandowski
piotrlewandowski / gist:cd8b35547f87cf570057
Created October 9, 2015 02:48 — forked from settermjd/gist:8430918
A Zend Form created via annotations, modelling a very simple user record.
<?php
namespace MyApplication\Form;
use Zend\Form\Annotation;
/**
* @Annotation\Name("user")
* @Annotation\Hydrator("Zend\Stdlib\Hydrator\ObjectProperty")
*/
@piotrlewandowski
piotrlewandowski / GenericTableTest.php
Created October 9, 2015 02:48 — forked from settermjd/GenericTableTest.php
A simple Zend Framework model class, used to build a set of unit tests with PHPUnit and Mockery.
<?php
namespace Generic\Model;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql\Select;
class GenericTable
{
protected $tableGateway;
@piotrlewandowski
piotrlewandowski / app.coffee
Created October 9, 2015 04:00 — forked from webgio/app.coffee
Marionette.js module to manage authentication. Needs a server method that checks credentials returning true or false. Started from this blog post code: http://clintberry.com/2012/backbone-js-apps-authentication-tutorial/
App = new Marionette.Application();
App.addRegions {
"headerRegion": "#header"
"topMenuRegion": "#top-menu"
"mainRegion" : "#main"
}
App.on 'initialize:after', ->
Backbone.history.start()
@piotrlewandowski
piotrlewandowski / node-on-ec2-port-80.md
Created November 2, 2015 04:46 — forked from kentbrew/node-on-ec2-port-80.md
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);