Skip to content

Instantly share code, notes, and snippets.

View gormus's full-sized avatar
💭
Never be cruel, never be cowardly.

Osman Gormus gormus

💭
Never be cruel, never be cowardly.
View GitHub Profile
@gormus
gormus / sphp.sh
Created April 27, 2017 05:53 — forked from w00fz/sphp.sh
PHP switcher
#!/bin/bash
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# Usage
@gormus
gormus / index.html
Created April 15, 2017 02:26
YouTube Video as a DIV Background // source https://jsbin.com/kaleraw
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>YouTube Video as a DIV Background</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<style id="jsbin-css">
html {
overflow-y: scroll;
@gormus
gormus / index.html
Created April 15, 2017 01:08
YouTube Video as a DIV Background // source https://jsbin.com/kaleraw
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>YouTube Video as a DIV Background</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<style id="jsbin-css">
body{
border:0 none;
@gormus
gormus / index.html
Created April 14, 2017 21:39
Background Video Player // source https://jsbin.com/towufeb
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Background Video Player</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!--[if gte IE 9]>
<style type="text/css">
.gradient {
@gormus
gormus / index.html
Created April 14, 2017 19:56 — forked from seancdavis/index.html
Full-Size, Looping Background Video with YouTube Video
<style>
.bg-video {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
z-index: -1;
}
<?php
class DrupalHubFlagLike extends \RestfulEntityBase {
/**
* {@inheritdoc}
*/
public function publicFieldsInfo() {
$public_fields = parent::publicFieldsInfo();
@gormus
gormus / fuzzy-search.sql
Created December 17, 2016 04:34 — forked from lsauer/fuzzy-search.sql
FullText fuzzy searching in SQL / MySQL
#lo sauer, 2013 - www.lsauer.com
#see: http://www.lsauer.com/2013/05/mysql-fuzzy-searching-fulltext-queries.html
#Note: In MySQL SUBSTRING, the string-index starts at position 1
SELECT * FROM tablename
WHERE SOUNDEX(tablename_field)
LIKE CONCAT('%',SUBSTRING(SOUNDEX('Fuzti serch derm'),2),'%');
@gormus
gormus / MYMODULE.module
Created October 20, 2016 05:40
Improve user experience with Paragraphs on Drupal 8 - Modify the label of paragraph components - source: http://flocondetoile.fr/blog/improve-user-experience-paragraphs-drupal-8
<?php
/**
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form_object = $form_state->getFormObject();
// Paragraphs are only set on ContentEntityForm object.
if (!$form_object instanceof ContentEntityForm) {
@gormus
gormus / drupal_redirect_for_files_dir.conf
Created October 12, 2016 16:47
Redirects your local environment's Drupal install /sites/*/files/* requests to a server that actually has them. This helps avoid having to sync (sometimes, very large) file structures onto your local machine and taking up valuable hard-drive space. Source: http://dropbucket.org/node/337
### Apache Rewrite
<IfModule mod_rewrite.c>
RewriteEngine on
# Force image styles that have local files that exist to be generated.
RewriteCond %{REQUEST_URI} ^/sites/([^\/]*)/files/styles/[^\/]*/public/((.*))$
RewriteCond %{DOCUMENT_ROOT}/sites/%1/files/%2 -f
RewriteRule ^(.*)$ $1 [QSA,L]
# Otherwise, send anything else that's in the files directory to the
# production server.
RewriteCond %{REQUEST_URI} ^/sites/[^\/]*/files/.*$
@gormus
gormus / example.services.yml
Created September 22, 2016 17:54
Drupal 8 - Change the core's default path for `/contact` so that we can use it as an alias.
services:
example.route_subscriber:
class: Drupal\example\Routing\RouteSubscriber
tags:
- { name: event_subscriber }