Skip to content

Instantly share code, notes, and snippets.

View ahmed-bhs's full-sized avatar
👽

Ahmed EBEN HASSINE 脳の流れ ahmed-bhs

👽
View GitHub Profile
@ahmed-bhs
ahmed-bhs / AppKernel.php
Created November 5, 2017 21:41 — forked from kbond/AppKernel.php
JWT Authentication With Symfony Guard. POST username/password to /login to receive token, /api* requests require a valid token
<?php
// app/AppKernel.php
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
public function registerBundles()
{
@ahmed-bhs
ahmed-bhs / gist:6a4ad11acc2dc9d0679f818181364192
Created March 25, 2018 17:05 — forked from tlrobinson/gist:1073865
Autocomplete Makefile targets. Add this to your shell config file.
complete -W "\`grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' Makefile | sed 's/[^a-zA-Z0-9_-]*$//'\`" make
@ahmed-bhs
ahmed-bhs / transaction.php
Created April 13, 2018 21:09 — forked from KaduNovoK/transaction.php
Transactions in Symfony 2 and Doctrine 2
<?php
// Code sample to use Transactions
// Get the Entity Manager
$em = $this->getDoctrine()->getEntityManager();
// Suspend the auto-commit
$em->getConnection()->beginTransaction();
@ahmed-bhs
ahmed-bhs / zsh.md
Last active April 23, 2018 21:29 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu
@ahmed-bhs
ahmed-bhs / LikeQueryHelpers.php
Created April 28, 2018 08:40 — forked from johnkary/LikeQueryHelpers.php
Proper DQL escaping for LIKE queries with Doctrine 2.
<?php
namespace Foo;
/**
* Methods for safe LIKE querying.
*/
trait LikeQueryHelpers
{
/**
@ahmed-bhs
ahmed-bhs / Stop tracking directory in Git repo
Created April 29, 2018 12:08 — forked from mandiwise/Stop tracking directory in Git repo
A command to stop tracking and entire directory in a Git repo
// Reference: http://stackoverflow.com/questions/936249/stop-tracking-and-ignore-changes-to-a-file-in-git
$ git rm --cached -r <dir>
def generate_RSA(bits=2048):
'''
Generate an RSA keypair with an exponent of 65537 in PEM format
param: bits The key length in bits
Return private key and public key
'''
from Crypto.PublicKey import RSA
new_key = RSA.generate(bits, e=65537)
public_key = new_key.publickey().exportKey("PEM")
private_key = new_key.exportKey("PEM")
@ahmed-bhs
ahmed-bhs / .travis.yml
Created November 1, 2018 12:57 — forked from n0ni0/.travis.yml
Travis-CI file for PHP/Symfony 3
# Project language
language: php
# Allows use container-based infrastructure
sudo: false
# Start mysql service
services:
- mysql
@ahmed-bhs
ahmed-bhs / auto-deploying.md
Created November 1, 2018 17:32 — forked from nickbclifford/auto-deploying.md
How to automatically deploy code to a server using Travis CI

Auto-Deploying via Travis CI

Because Travis CI can automatically execute scripts after successfully (or unsuccessfully!) executing tests, it is an obvious choice for a deployment tool. In order to deploy to a Git repository on a remote server, the process generally is as follows:

  • Set up SSH keys
  • Add the server's copy of the repository as a Git remote
  • Push to the remote
  • SSH into the server and execute any installation/compilation/miscellaneous commands

Before even touching .travis.yml...

Users

@ahmed-bhs
ahmed-bhs / auto-deploy.md
Created November 1, 2018 17:33 — forked from domenic/0-github-actions.md
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with Travis

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

Create a compile script

You want a script that does a local compile to e.g. an out/ directory. Let's call this compile.sh for our purposes, but for your project it might be npm build or gulp make-docs or anything similar.

The out/ directory should contain everything you want deployed to gh-pages. That almost always includes an index.html.