Skip to content

Instantly share code, notes, and snippets.

# See changes of a specific file in history
git log -p
# See a previous version of a file
git show REVISION:path/to/file
@grenoult
grenoult / gist:ac78c7e20de56e51bf077e7f38b3a982
Created June 4, 2018 23:45
Jira: get worklogs of last 7 days. To copy as a bookmark
javascript:(function(){
function formatDate(d) {
return d.getFullYear() + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2);
};
var today = new Date();
var aWeekAgo = new Date(new Date().getTime() - 518400000); /* 6 days ago */
location.href = 'https://elmolearning.atlassian.net/plugins/servlet/ac/is.origo.jira.tempo-plugin/tempo-my-work#!/timesheet/?columns=WORKED_COLUMN&dateDisplayType=days&from='+formatDate(aWeekAgo)+'&groupBy=issue&periodKey&periodType=LAST_DAYS&subPeriodType=MONTH&to='+formatDate(today)+'&viewType=TIMESHEET';
})();
@grenoult
grenoult / toggle-checkbox.js
Created January 10, 2018 04:59
Bootstrap-toggle AngularJS directive
'use strict';
/**
* Bootstrap-toggle Directive
* Forked from from: https://gist.github.com/dave-newson/f6c5e9c2f3bc315e292c
* This version supports ngDisabled directive.
* Unashamedly coped from https://gist.github.com/jjmontesl/54457bf1342edeb218b7 as it is not available anymore.
*/
angular.module('togglecheckbox', [])
.directive('toggleCheckbox', function() {
Providers:
Registred class, function or value for dependency injection.
-- Watch assets files
php app/console assetic:watch
-- Update DB depending on entities
php app/console doctrine:schema:update --dump-sql | grep epms
-- Update Solr indexes
php app/console cron:indexCandidate
-- Clear cache
<?php
/*
Dependecy Injection (PHP):
Dependency Injection is where components are given their dependencies through their constructors, methods, or directly into fields.
Usually dependency is done through the constructor but it can also be done by a setter or a (public) property.
Source: http://fabien.potencier.org/what-is-dependency-injection.html
Example:
*/
class User
{
@grenoult
grenoult / javascript.js
Last active September 1, 2018 01:00
JavaScript and best practices
// Best practices:
/*
1 - Always name anonymous functions.
Good: var clickHandler = function clickHandler() { ... }
Bad: var clickHandler = function() { ... }
Because:
- useful for self-reference
- debuggable stack trace
- self documentating codeYour billing address doesn’t look like it matches up with your current country. Please contact support for assistance or use a payment method registered to your current address.
*/
@grenoult
grenoult / unix.sh
Last active August 23, 2016 23:53
General Unix stuff
# Vim: replace ‘),(‘ by ‘),\n(‘
:%s/),(/),\r(/g
# Archive content without extraction
tar -tf filename.tar.gz
# Find a file by its name
find . -name "profile.html"
# Execute multiple processes
@grenoult
grenoult / my.sql
Last active October 24, 2018 01:29
MySQL & MySQL Dump common queries
// MySQL & MySQL Dump common commands
-- Export specific rows from table
mysqldump -u user -p dbname --tables myTable --where="id < 1000"
-- Dump: one INSERT per row
mysqldump --extended-insert=FALSE
-- Dump: display columns names
mysql dump --complete-insert=TRUE