Skip to content

Instantly share code, notes, and snippets.

View kulakowka's full-sized avatar

Anton Kulakov kulakowka

View GitHub Profile
@kulakowka
kulakowka / truncate.js
Created April 10, 2014 13:41
Jquery Truncate text in div + show more link
/**
* <div class="text">Some text with <b>html</b>... Any length.</div>
*
*/
$('.text').each(function(){
var length = 5;
var details = $(this);
var original_html = details.html();
var original_text = details.text();
var truncated_text = $.trim(original_text).substring(0, length).split(" ").slice(0, -1).join(" ") + " ";
@kulakowka
kulakowka / app.js
Created April 15, 2014 14:22
submit with delay - jquery
var timer;
$('input').on('change keyup', function(){
clearTimeout(timer);
timer = setTimeout(function(){
console.log('submit');
},3000)
})
@kulakowka
kulakowka / git.css
Last active August 29, 2015 14:11 — forked from neilgee/git.css
/* Set up Git Configuration */
git config --global user.email "you@yourdomain.com"
git config --global user.name "Your Name"
git config --global core.editor "vi"
git config --global color.ui true
@kulakowka
kulakowka / bebel-package.md
Created July 29, 2015 12:36
Add Babel as a dependency to your app's package.json file and define a start script

Add Babel as a dependency to your app's package.json file and define a start script:

{
  "dependencies": {
    "babel": "4.7.16"
  },
  "scripts": {
    "start": "./node_modules/.bin/babel-node ./app.js"
  }
}
@kulakowka
kulakowka / .jscsrc
Created August 10, 2015 15:28
default .jscsrc config
{
"preset": "airbnb",
"requireCurlyBraces": null
}
function ObjFactory(initialPrivateVariableForAll) {
var privateVariableForAll = initialPrivateVariableForAll;
return function ObjConstructor(initialPrivateVariableForInstance) {
var privateVariableForInstance = initialPrivateVariableForInstance;
return {
getInitialPrivateVariableForAll: function() {
return initialPrivateVariableForAll;
},
getInitialPrivateVariableForInstance: function() {
@kulakowka
kulakowka / factory.js
Created August 18, 2015 02:02
ObjFactory
class ObjFactory {
constructor(author) {
this.author = author;
}
createCar(model) {
return new Car(this.author, model);
}
createHuman(name) {
/*
import User from './User';
let u1 = new User('anton');
let u2 = new User('vadim');
console.log(u1);
console.log(u2);
console.log(u1.getTitle());
console.log(u2.getTitle());
class Item {
constructor(params) {
this.id = getItemId();
this.params = params;
addItem(this);
}
destroy() {
destroyItem(this.id);
}
@kulakowka
kulakowka / static.js
Last active August 29, 2015 14:27
static methods and params for class
class Item {
constructor() {
this.id = Item.count++;
}
}
Item.count = 0;
Item.getCount = function() {
return this.count;
};