Skip to content

Instantly share code, notes, and snippets.

View mariselli's full-sized avatar
👨‍💻
...

Mattia Mariselli mariselli

👨‍💻
...
  • knauf.com
  • Munich
  • 01:21 (UTC +02:00)
  • X @mariselli
View GitHub Profile
/*
RESPONSIVE MIXINS based on bootstrap breakponts
*/
@mixin mobile() {
@media (max-width: $screen-xs-max) {
@content;
}
}
@mixin notMobile() {
@mariselli
mariselli / folder-structure.md
Last active March 14, 2016 22:45
Generate font with icons with Gulp

In this example folders shoulb be in this way

  gulpfile.js
  font-template.scss
  icons/
      ico-user.svg
      ico-save.svg
      ...
  fonts/
 myfont.eot
@mariselli
mariselli / font-template.scss
Created March 10, 2016 09:52
Generate font with icons with Gulp
@font-face {
font-family: "<%= fontName %>";
src: url('<%= fontPath %><%= fontName %>.eot');
src: url('<%= fontPath %><%= fontName %>.eot?#iefix') format('eot'),
url('<%= fontPath %><%= fontName %>.woff') format('woff'),
url('<%= fontPath %><%= fontName %>.ttf') format('truetype'),
url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg');
font-weight: normal;
font-style: normal;
}

Check history

Check history of line of specific file

git log -L 58,64:gulpfile.js

Here it show the story of line from 58 to 64

Check who modified the lines 58,59,..68

@mariselli
mariselli / git-alis.md
Last active February 10, 2016 15:06
My git configuration

Remeber, to show all configurations type git config --list

My Git Alias

Show what file is changed in commit

git config --global alias.dc 'diff-tree --no-commit-id --name-only -r'

How to use: git dc 9b16a12

Import dump from file by command line

psql -h localhost -U postgtres < dump_01_18_2016.sql

Git Essentials

Set your details

git config --global user.name "John Doe"
git config --global user.email "john@example.com"

Use --global to set the configuration for all projects. If git config is used without --global and run inside a project directory, the settings are set for the specific project.

@mariselli
mariselli / bira-custom.zsh-theme
Created February 1, 2016 21:59
Customization bira theme for terminal
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
else
if which rbenv &> /dev/null; then
@mariselli
mariselli / README.md
Created December 20, 2015 14:38 — forked from dbu/README.md
Symfony2: Role Hierarchy check independent of firewall

We needed to decide whether a user loaded from FOSUserBundle is granted a specific role. Because of the role hierarchy, this is not as simple as doing in_array($role, $user->getRoles()). The user model only knows about its roles, not about what other roles those roles grant it.

The only thing that handles this situation that i found is the SecurityContext::isGranted method. But the problem of that is that its a check about the role of the "current" user. We needed this information in a command that generates a file and needs to know which user has permission for a specific role.

The RoleHierarchy service can not do decisions but only explode roles into all roles granted through the tree. The RoleHiararchyVoter is part of the security manager. Both are private service and thus not intended to be reused in application code.

The simplest we could come up with is this code, which we use like this:

$roleHierarchy = $this->getContainer()->get('acme_demo.security.role_hierarchy_checker');
@mariselli
mariselli / routing.yml
Created August 25, 2015 13:35
Symfony2 RESTFull API : Session and Access Token together
acme_api:
type: rest
prefix: /
resource: "@AcmeBundle/Resources/config/routing_api.yml"