Skip to content

Instantly share code, notes, and snippets.

View gabouh's full-sized avatar
💭
I may be slow to respond.

Gabriel gabouh

💭
I may be slow to respond.
View GitHub Profile
@gabouh
gabouh / getting-started-&-gotchas.md
Last active June 30, 2016 08:21 — forked from pbojinov/getting-started.md
Getting Started with React Native Android
@gabouh
gabouh / media-queries.css
Created August 4, 2016 23:06 — forked from hemantajax/media-queries.css
Very useful media queries snippets
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
@gabouh
gabouh / .htaccess
Created January 23, 2017 21:40 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@gabouh
gabouh / stop-video.js
Created January 24, 2017 17:53 — forked from cferdinandi/stop-video.js
A simple method to stop YouTube, Vimeo, and HTML5 videos from playing.
/**
* Stop an iframe or HTML5 <video> from playing
* @param {Element} element The element that contains the video
*/
var stopVideo = function ( element ) {
var iframe = element.querySelector( 'iframe');
var video = element.querySelector( 'video' );
if ( iframe ) {
var iframeSrc = iframe.src;
iframe.src = iframeSrc;
@gabouh
gabouh / apn-server.php
Created April 17, 2017 01:03 — forked from samvermette/apn-server.php
Quickly send an Apple Push Notification using PHP
<?php
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsCert = 'apns-dev.pem';
$apnsPort = 2195;
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
@gabouh
gabouh / meta-programming.php
Created May 15, 2017 02:02 — forked from ziadoz/meta-programming.php
Basic Meta Programming with PHP 5.4
<?php
trait MetaClass
{
protected $__classMethods = array();
static protected $__staticMethods = array();
public function __call($name, $args)
{
@gabouh
gabouh / README.md
Created September 6, 2017 03:42 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

@gabouh
gabouh / js-dev-biz-card-back.svg
Created September 28, 2017 05:33 — forked from rsperberg/js-dev-biz-card-back.svg
JavaScript developer’s business card
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gabouh
gabouh / vesta-user-fix-permission.sh
Created October 11, 2017 21:14 — forked from 0x00dec0de/vesta-user-fix-permission.sh
Fix user permissions to vesta control panel
#!/bin/bash
cd /home/
for i in `ls | grep -v 'lost+found'`; do
if id "$i" &>/dev/null ; then
chattr -i /home/$i/conf
chown -R ${i}:${i} $i
chown root:root /home/$i/conf
chown root:root /home/$i/conf/*
chown root:bind /home/$i/conf/dns/* &>/dev/null
chown Debian-exim:mail /home/$i/conf/mail/* &>/dev/null
@gabouh
gabouh / PoorMansCodeEditor.html
Created February 26, 2018 01:17 — forked from deanebarker/PoorMansCodeEditor.html
Poor man's code editor in pure JavaScript.
<!--
This is a textarea that:
(1) Is styled(-ish) like a code editor
(2) Catches tabs and converts them to four (4) spaces
(3) Duplicates leading spaces from the last line
(4) Auto-expands to input
Pure inline HTML and JavaScript. No external dependencies. Has issues pre-IE-8, but should be otherwise okay.