Skip to content

Instantly share code, notes, and snippets.

View commonpike's full-sized avatar
🏠
Working from home

pike commonpike

🏠
Working from home
View GitHub Profile
@ve3
ve3 / strftime-to-intldateformatter-converter.php
Last active June 19, 2023 12:33
Convert strftime format to IntlDateFormatter pattern.
<?php
/**
* PHP `strftime()` format to `IntlDateFormatter()` pattern converter.
*
* PHP `strftime()` is deprecated since v 8.1. They recommended to use `IntlDateFormatter()` instead.
* However `IntlDateFormatter()` pattern does not fully supported all format that `strftime()` does.
*
* Run this file to get the result of most close pattern to `strftime()` based on Thai locale.
*
* @license MIT
@jez500
jez500 / d8-views-exp-form-alter.php
Last active October 12, 2023 12:20
Drupal 8 - Hook form alter views exposed form
<?php
/**
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$view_names = array('my_view_name');
$view = $form_state->getStorage('view');
if ($form_id == 'views_exposed_form' && in_array($view['view']->id(), $view_names)) {
// Do some shilzzle.
@GoToLoop
GoToLoop / NoRepeatIdInput.pde
Last active August 6, 2021 20:25
JavasScript's alert(), confirm(), prompt(), isNaN(), isFinite() and some few others as a Java class!
/**
* No Repeat ID Input (v2.1.1)
* by GoToLoop (2015/Sep/15)
*
* Forum.Processing.org/two/discussion/12532/
* windowjs-cross-mode-alert-confirm-prompt-other-js-api-for-java#Item_2
*
* Forum.Processing.org/two/discussion/869/check-array-contents-with-arraylist
*
* Studio.ProcessingTogether.com/sp/pad/export/ro.9$Bjf6i21oXBw
@akovalyov
akovalyov / File.orm.yml
Created May 18, 2015 08:12
Pure file upload with Doctrine entity listener, doctrine events and symfony2 dependency injection
App\Model\File:
type: entity
table: files
entityListeners:
App\Doctrine\EventListener\FileUploadListener:
prePersist: [upload]
preUpdate: [upload]
preRemove: [remove]
id:
id:
@samba
samba / htpasswd-ssl.sh
Created June 13, 2014 16:21
htpasswd replacement with openssl
#!/bin/sh
# Writes an APR1-format password hash to the provided <htpasswd-file> for a provided <username>
# This is useful where an alternative web server (e.g. nginx) supports APR1 but no `htpasswd` is installed.
# The APR1 format provides signifcantly stronger password validation, and is described here:
# http://httpd.apache.org/docs/current/misc/password_encryptions.html
help (){
cat <<EOF
Usage: $0 <htpasswd-file> <username>
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@wizonesolutions
wizonesolutions / README.md
Last active April 10, 2017 15:26
Drupal script to fix field collection items associated with multiple entities due to Content Translation/Node Clone bug.

Explanation

Drupal script to fix field collection items associated with multiple entities due to Content Translation/Node Clone bug.

**NOTE: This update hook gives every field collection item found to be associated with more than one node a new item_id. I haven't experienced any problems with doing this, but if you are doing anything special in your use case with the item_ids or revision_ids of field collection items, you should test thoroughly after running this update.

You should test thoroughly anyway, really.

TAKE A BACKUP.

How to use

@andreyvit
andreyvit / fpdi_with_annots.php
Created March 12, 2012 07:16
FPDI extension to preserve external hyperlinks
<?php
// FPDI extension that preserves hyperlinks when copying PDF pages.
//
// (c) 2012, Andrey Tarantsov <andrey@tarantsov.com>, provided under the MIT license.
//
// Published at: https://gist.github.com/2020422
//
// Note: the free version of FPDI requires unprotected PDFs conforming to spec version 1.4.
// I use qpdf (http://qpdf.sourceforge.net/) to preprocess PDFs before running through this