Skip to content

Instantly share code, notes, and snippets.

@ondrek
ondrek / 01.md
Created October 2, 2012 07:20
NOTES: Prefixes vs. Folders (#1)

NOTES: Prefixes vs. Folders (#1)

PROBLEM:

  • If we starting create a new project, we try design folder structure
  • But sometimes we have too many kinds of files (like frond-end developers's assets)
  • Like here: https://github.com/h5bp/html5-boilerplate folders CSS, JS, IMG
  • We don't need create folder for 2 or 3 files, it is useless
@ondrek
ondrek / deploy-github-docpad.sh
Created January 12, 2013 20:57
Deploy Docpad to Github via checkout to gh-pages
# Install dependencies (in case of not having all plugins installed)
docpad install
# Build the website locally
docpad generate
# Go to the gh-pages branch
git checkout gh-pages
# Remove all files under version control
@ondrek
ondrek / spaces.md
Last active December 13, 2015 23:59
nice sample standard debugging in css

Nice sample standard debugging in css

This sample (work)

This sample (doesnt work)

Why?

@ondrek
ondrek / fiddle.css
Last active December 14, 2015 08:09 — forked from zalun/fiddle.css
body {
font-family: Helvetica, Verdana
}

DNS and DotCloud

In the following, replace example.net with your domain name. XXX.XXX.XXX.XXX is the IP of the reverse proxy.

DNS entries

Required DNS entries

example.net. 300 IN A XXX.XXX.XXX.XXX

@ondrek
ondrek / gist:5872251
Last active December 19, 2015 00:59
resize all images
function resize(originalImage) {
var img = new Image();
img.src = originalImage.attr('src');
img.id = originalImage.attr('id');
img.onload = function(){
console.log(img);
@ondrek
ondrek / hack.sh
Created August 21, 2013 12:54 — forked from erikh/hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@ondrek
ondrek / removephoto.js
Created September 1, 2013 18:54
remove photo from mongodb and from amazon s3
/* from photo mongo database and s3 */
var removePhoto = function(){
mongoclient.connect(database, function(err, db) {
if (err) throw err;
/* url../remove?98c582c7d329/3b1fa423d917 - album:98c582c7d329 photo:3b1fa423d917 */
var url = require('url').parse(req.url).query;
var album = underscore.words(url, '/')[0];
var photo = underscore.words(url, '/')[1];
@ondrek
ondrek / iteration.js
Last active December 22, 2015 04:58
How to iterate array only to first wanted item and finish
function iterateArrayToFirstResult(arr){
loop: {
for (var i=0; i<arr.length; i++) {
if (arr[i]==42) {
console.log('You just found answer to the ultimate question of Life');
break loop;
}
console.log('Your array havent number 42');
}
}
@ondrek
ondrek / luhn.js
Created October 14, 2013 18:04 — forked from ShirtlessKirk/luhn.js
// Variant of Avraham Plotnitzky's String.prototype method mixed with the "fast" version
// see: https://sites.google.com/site/abapexamples/javascript/luhn-validation
function luhnChk(luhn) {
var len = luhn.length,
mul = 0,
prodArr = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]],
sum = 0;
while (len--) {