Skip to content

Instantly share code, notes, and snippets.

[user]
email = psdcoder@gmail.com
name = Pavel Grinchenko
[alias]
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
st = status
@psdcoder
psdcoder / timer
Last active December 15, 2015 15:39
Simple jQuery timer. Usage: $('#timer').timer( 10, //duration of timer function(el){ //callback which will executed when time is up el.text('time is up!'); } )
(function($){
$.fn.timer = function(duration, callback) {
var time = duration,
element = this;
element.text(time--);
var interval = setInterval(function() {
if(time < 0){
clearInterval(interval);
@psdcoder
psdcoder / git-snippets.md
Last active February 27, 2019 09:28
GIT Snippets

Local

Sync local branches with remote

git remote prune origin

Remove merged branches

git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d

Run garbage collector

git gc

@psdcoder
psdcoder / setting-up-xdebug.md
Last active August 29, 2015 13:58
Setting up of Xdebug in PHPStorm
  1. Installing and setting up xdebug: http://www.xdebug.org/wizard.php
  2. Add to php.ini:
    [XDebug]
    zend_extension="path to xdebug.so"
    xdebug.remote_autostart=on
    xdebug.remote_enable=on
    xdebug.remote_handler="dbgp"
    xdebug.remote_host="localhost"
    xdebug.remote_port=9000
    xdebug.remote_mode=req
@psdcoder
psdcoder / node-js-inheritance
Created August 27, 2014 20:37
node js inheritance of classes
var util = require('util');
function BaseClass(data) {
if (!data) {
throw new TypeError('You must pass "data" in constructor');
}
console.log('base constructor');
this.data = data;
}
@psdcoder
psdcoder / angular-popups
Created August 28, 2014 16:14
angular setup for popups (with particular route (state) and on open different state (onEnter callback))
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular-route.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.10/angular-ui-router.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
@psdcoder
psdcoder / angular-transclude-scope.js
Created September 10, 2014 10:31
Bind transcluded dom to directive scope
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
</head>
<body ng-controller="ParentCtrl">
<test-directive>
<p>Some content <br> {{ test }} </p>
</test-directive>
<script>
@psdcoder
psdcoder / ng:config
Created February 20, 2015 12:20
Angular webstorm live templates
(function () {
'use strict';
angular
.module('$MODULE_NAME$')
.config($COMPONENT$Initialization);
function $COMPONENT$Initialization() {
$END$
}
<!DOCTYPE html>
<html>
<head>
<script src="http://static.jsbin.com/js/vendor/traceur.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:600' rel='stylesheet' type='text/css'>
<style id="jsbin-css">
@font-face {
font-family: 'icomoon';