Skip to content

Instantly share code, notes, and snippets.

View lossendae's full-sized avatar

Stéphane Boulard lossendae

View GitHub Profile
@lossendae
lossendae / config.git
Created June 24, 2016 13:19
Git config global
core.autocrlf=input
...
alias.ll=log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
alias.co=checkout
alias.ci=commit
alias.br=branch
alias.st=status
alias.cop=!git checkout $1 && git pull origin $1
alias.cob=checkout -b $1
alias.fp=!git push origin develop master && git push --tags
@lossendae
lossendae / postgresql-cte.sql
Created April 17, 2015 16:05
POSTGRESQL CTE - With prepared statement, parameter and projection mapping
PREPARE emp_info AS
WITH RECURSIVE
subdept(id, name, parent_id) AS (
SELECT
emp.department_id,
dpt.name,
dpt.department_parent_id
FROM department dpt
@lossendae
lossendae / recursive.sql
Last active August 29, 2015 14:19
Discovering POSGRESQL - CTE
WITH RECURSIVE
subdept AS (
SELECT
d.department_id,
d.department_parent_id,
d.name department_name
FROM department d
JOIN employee e USING (department_id)
WHERE e.employee_id = 13
UNION ALL
@lossendae
lossendae / dummy.php
Last active August 29, 2015 14:06
Symfony 1.x http header for PDF with DOMPDF
<?php
class showDocumentAction extends sfActions
{
/**
* Make sure that no other content will be output
*/
public function preExecute()
{
$this->setLayout(false);
sfConfig::set('sf_web_debug', false);
@lossendae
lossendae / angular-filter-length.js
Created May 26, 2014 18:18
Angular filter in ng-repeat with sum on value length
<!-- If I want to hide done todos -->
<ul class="whatever">
<li data-ng-repeat="todo in todos | filter:{done: false}">
...
</li>
</ul>
<!-- Show done todos -->
<div class="whatever" data-ng-show="(todos | filter:{done: true} ).length > 0">
...
@lossendae
lossendae / route-resolver.js
Created May 25, 2014 08:31
Angular-ui route resolver
'use strict';
define([], function () {
var routeResolver = function (commonsProvider) {
this.$get = function () {
return this;
};
@lossendae
lossendae / interceptor.js
Created January 17, 2014 11:44
AngularJS 1.2.x http Interceptor base
(function (window, angular, undefined) {
'use strict';
var myAppInterceptor = function ($httpProvider) {
var interceptor = ['$q' function ($q) {
return {
return {
// On request success
request: function (config) {
@lossendae
lossendae / timer.js
Created January 16, 2014 11:49
AngularJS timer with pause
var Controller = function($timeout){
var timer = 10000;
$scope.remaining = timer / 1000;
$scope.startTimer = function(){
$scope.timeout = $timeout(function() {
$scope.remaining--;
$scope.remaining > 0 ? $scope.startTimer() : $scope.finished('Finished!');
}, 1000);
};
@lossendae
lossendae / index.html
Last active July 4, 2019 20:22
Dynamic (single level) menu for Angular ui-router
<!DOCTYPE html>
<html ng-app>
<head>
<title>Example</title>
</head>
<body>
<nav class="main-nav" data-main-menu data-root="index"></nav>
<script type="text/javascript" src="angular.js"></script>
@lossendae
lossendae / breacrumb.js
Created January 10, 2014 15:37
Exemple of an AngularJS breadcrumbs directive for use with ui-router
var breadcrumbs = function($state, $stateParams) {
return {
restrict: 'E',
templateUrl: '/path/to/breadcrumbs.html',
replace: true,
compile: function(tElement, tAttrs) {
return function($scope, $elem, $attr) {
$scope.show = function(state){
if(!angular.isDefined(state.data)){
return false;