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 / qs.js
Created November 14, 2018 19:10 — forked from cvan/qs.js
get query-string parameters (alternative to `URLSearchParams`)
var queryParams = window.location.search.substr(1).split('&').reduce(function (q, query) {
var chunks = query.split('=');
var key = chunks[0];
var value = chunks[1];
return (q[key] = value, q);
}, {});
@gormus
gormus / pretty-php-date-ranges.php
Created July 10, 2018 04:59 — forked from jb510/pretty-php-date-ranges.php
Pretty PHP Date Ranges
<?php
/**
* Verbose Beautified Date Range
*
* @access public
* @param mixed $start_date
* @param mixed $end_date
* @return $date_range (beautified date range)
* @license WTFPL
*
@gormus
gormus / LinkModifierService.php
Created April 19, 2018 14:59 — forked from hudri/LinkModifierService.php
Modify _all_ Drupal links
<?php
namespace Drupal\wt_base;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Render\BubbleableMetadata;
/**
* Class DefaultService.
@gormus
gormus / DomainBlackListValidator.php
Created January 14, 2018 20:07
Laravel validation rule to prevent use of email addresses possessing a disposable (blacklisted) domains.
<?php
// Namespace
namespace App\Validators;
// Using directives
use Cache;
use Carbon\Carbon;
// Domain black list validation class
@gormus
gormus / changelog.rb
Created November 16, 2017 05:49 — forked from ttscoff/changelog.rb
Generate release notes from git commit messages
#!/usr/bin/ruby
# A script to automate changelog generation from Git commit messages
#
# For use with a git-flow workflow, it will take changes from the last tagged release
# where commit messages contain NEW, FIXED, and IMPROVED keywords and sort and fromat
# them into a Markdown release note list.
#
# The script takes version information from the macOS command agvtool and bases
# the product name on the first matching Xcode Info.plist found
@gormus
gormus / simple_args_parsing.sh
Created October 21, 2017 04:46 — forked from jehiah/simple_args_parsing.sh
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
<?php
/**
* Implements of hook_drush_command().
*/
function migration_filepath_drush_command() {
$items = array();
$items['migration_filepath'] = array(
'description' => "Move files to subdirectories",
'callback' => 'drush_migration_filepath',
@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 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();