Skip to content

Instantly share code, notes, and snippets.

View janez89's full-sized avatar

Janez janez89

  • Budapest
  • 06:23 (UTC +01:00)
View GitHub Profile
@janez89
janez89 / addEventListener.js
Last active August 29, 2015 14:06
native js addEventListener
// By Janez
function addEventListener(elOrId, event, callback, useCaptrue) {
if (typeof elOrId === 'string') {
var elName = elOrId;
elOrId = document.getElementById(elOrId);
if (!elOrId) {
console.error('"'+ elName +'" ID not found!');
return;
}
}
@janez89
janez89 / repair.sh
Created August 15, 2014 13:58
mongo db crash repair (ubuntu version)
sudo -u mongodb mongod --repair --dbpath /var/lib/mongodb/
sudo service mongod start
@janez89
janez89 / systools.js
Last active August 29, 2015 14:05
NodeJS - formated system tools
/**
* @author Janez89
*/
module.exports = {
// get uptime in day, hour, min, sec format
uptime: function (uptime){
if (typeof uptime === undefined)
uptime = process.uptime();
var time = {};
@janez89
janez89 / favicon.js
Created August 13, 2014 13:50
NodeJS - favicon
var http = require('http');
http.createServer(function (req, res) {
// favicon spam
if (req.url == '/favicon.ico') {
res.writeHead(404);
return res.end();
}
// another response
@janez89
janez89 / auth.js
Created August 13, 2014 13:45
NodeJS basic authentication without framework.
var http = require('http');
http.createServer(function (req, res) {
// get authorization data
var header=req.headers['authorization'] ||'',
token=header.split(/\s+/).pop()||'',
auth=new Buffer(token, 'base64').toString(),
parts=auth.split(/:/),
username=parts[0],
@janez89
janez89 / SampleModel.php
Created August 9, 2014 15:33
Type cast for Laravel Eloquent ORM. Tested on Laravel 4.2 Requires PHP 5.4
class SampleModel extends \Eloquent
{
use TypeCast;
protected $table = 'manufacturer';
protected $fillable = [];
protected $guarded = [
'id',
@janez89
janez89 / css_resources.md
Created June 14, 2014 18:05 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@janez89
janez89 / javascript_resources.md
Created June 14, 2014 18:05 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@janez89
janez89 / 0_reuse_code.js
Created June 14, 2014 18:05
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