Skip to content

Instantly share code, notes, and snippets.

@zela
zela / gist:531b3fb6ef41a33e68fa2fab42c06bb3
Created April 24, 2017 12:27
`vagrant up` and `vagrant reload` output
λ ~/Projects/Homestead/ master vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Importing base box 'laravel/homestead'...
==> homestead-7: Matching MAC address for NAT networking...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Setting the name of the VM: homestead-7
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
homestead-7: Adapter 1: nat
homestead-7: Adapter 2: hostonly
@zela
zela / dabblet.css
Created August 16, 2012 14:54
Untitled
.zen-grids {
background-color: #ddd;
}
.zen-grids:before, .zen-grids:after {
content: "";
display: table;
}
.zen-grids:after {
clear: both;
}
@zela
zela / dabblet.html
Created July 12, 2012 13:46
Untitled
<textarea maxlength=20>
dsdadad
</textarea>
@zela
zela / dabblet.css
Created June 15, 2012 16:50
Untitled
a {
display: inline-block;
border: 1px dotted;
}
a:active > div,
a:focus > div {
visibility: visible;
}
div {
width: 400px;
@zela
zela / incapsulation.js
Created March 18, 2011 13:12
incapsulation (from Flanagan's book)
function ImmutablRectangle(w, h){
this.getWidth = function(){ weturn w; }
this.getHeight = function(){ weturn h; }
}
ImmutableReactangle.prototype.area = function(){
return this.getWidth() * this.getHeight();
};
@zela
zela / singletons.js
Created March 18, 2011 13:10
singletons
// without closure
function MyClass(){
if (!MyClass.instance) MyClass.instance = this;
else return MyClass.instance;
}
var a = new MyClass,
b = new MyClass;
a === b; // true
// with closure (from essential js patterns book)
@zela
zela / random integer.js
Created March 18, 2011 13:07
random integer
function randomInt(n) {
return Math.round(Math.random() * n);
}
@zela
zela / image detection.js
Created March 18, 2011 12:56
detect if images are allowed in browser
/**
Without waiting in browsers Opera and Webkit:
if pics are allowed
'img.complete' puts on 'true' only after event
'onload', 'onerror' or 'onabort'
if pics are not allowed
instantly 'img.complete' becomes 'true', and 'onload' doesn't occurs
у IE:
if pics are allowed
property 'readyState' [*] changes two times
@zela
zela / common deal with cookies.js
Created March 18, 2011 12:30
common deal with cookies
// From Flanagan's book
// Recieve all document cookies
var allcookies = document.cookie;
// Search desired cookie
var pos = allcookies.indexOf("version=");
// If founded, extract it and use it's value
if (pos != -1) {
var start = pos + 8;
var end = allcookies.indexOf(";". start); // Start of value
if (end == -1) end = allcookies.length; // End of value
@zela
zela / limited error handling.js
Created March 18, 2011 12:26
limited error handling
// from Flanagan book
window.onerror = function (msg, url, line) {
if (onerror.num++ < onerror.max) {
alert("Error: " + msg + "\n" + url + ":" line);
return true;
}
}
onerror.max = 3;
onerror.num = 0;