Skip to content

Instantly share code, notes, and snippets.

View chalasr's full-sized avatar

Robin Chalas chalasr

View GitHub Profile
@chalasr
chalasr / angularjs-interceptor.js
Created January 4, 2016 12:15 — forked from gnomeontherun/angularjs-interceptor.js
Intercept XHR/Ajax requests with AngularJS http interceptors. This allows you to globally intercept and modify requests and responses. You don't need to declare all of the methods, just the ones you need. Some example uses would be logging errors, adding extra headers, or triggering 'loading' screens. This intercepts ALL requests/responses, so y…
// Intercepting HTTP calls with AngularJS.
angular.module('MyApp', [])
.config(function ($provide, $httpProvider) {
// Intercept http calls.
$provide.factory('MyHttpInterceptor', function ($q) {
return {
// On request success
request: function (config) {
// console.log(config); // Contains the data about the request before it is sent.
@chalasr
chalasr / commit-msg
Last active July 18, 2018 18:04
Beautify git commit message by capitalize message's first letter + prepend issue ID from ref.
#!/bin/bash
# original message
base=$(cat $1)
# ticket patterns
patterns=(ticket- issue- bug-)
# current branch name excluding namespace
current_branch=$(git symbolic-ref --short HEAD | cut -d/ -f2-)
# capitalize message's first char
message=`echo ${base:0:1} | tr '[a-z]' '[A-Z]'`${base:1}
@chalasr
chalasr / ClearIconsCacheOSX.md
Last active December 28, 2015 21:49
Clear icons cache on OSX

$ sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
$ sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} \;
$ sudo rm -rf /Library/Caches/com.apple.iconservices.store

@chalasr
chalasr / jekyll_gist_tag.rb
Last active April 8, 2021 10:45 — forked from imathis/gist_tag.rb
Embed gists in markdown files of a jekyll application by creating a custom Liquid tag
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
@chalasr
chalasr / node-apache-vhost
Last active December 23, 2015 16:51
Working vhost for get content of yourdomain.fr:3000 by browsing yourdomain.fr
<VirtualHost *:80>
ServerName yourdomain.fr
ServerAlias www.yourdomain.fr
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://yourdomain.fr:3000/
@chalasr
chalasr / SecurityController.php
Last active December 14, 2017 09:33
Generate a token manually in controller - LexikJWTAuthenticationBundle
<?php
namespace App\UserBundle\Controller;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
/**
@chalasr
chalasr / security.yml
Created December 11, 2015 17:14
Lexik\JWTAuthenticationBundle configuration
security:
providers:
in_memory:
memory: ~
fos_userbundle:
id: fos_user.user_manager
encoders:
FOS\UserBundle\Model\UserInterface: sha512
@chalasr
chalasr / sportroops.conf
Last active December 9, 2015 20:01
Apache2 VHOST example for sportroops local environment (dev)
<VirtualHost *:80>
ServerName sportroops.dev
ServerAlias api.sportroops.dev
DocumentRoot /var/www/html/sutunam/sportroops/web/
<Directory "/var/www/html/sutunam/sportroops/web">
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
@chalasr
chalasr / Capfile
Last active September 23, 2018 15:58
Deploy using capistrano/symfony tasks
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/composer'
require 'capistrano/symfony'
@chalasr
chalasr / README.md
Created October 13, 2015 15:27
Configure Apple keyboard on Ubuntu 14.04