Skip to content

Instantly share code, notes, and snippets.

@hemp
hemp / scan-multibranch-pipeline-trigger.md
Created January 29, 2020 15:40
Groovy to set the scan interval for Jenkins multibranch pipeline jobs

Scan Multibranch Pipeline Trigger

Enabling this schedule on all multi-branch pipeline build jobs helps with maintaining consistency between the code repository and Jenkins.

There is not a way to set this through a Jenkinsfile nor run this from inside a build job (reference).

The

@nimasdj
nimasdj / MimeTypes.php
Last active April 2, 2023 22:21
List of MimeTypes mapped to file extensions
<?php
// I made this array by joining all the following lists + .php extension which is missing in all of them.
// please contribute to this list to make it as accurate and complete as possible.
// https://gist.github.com/plasticbrain/3887245
// http://pastie.org/5668002
// http://pastebin.com/iuTy6K6d
// total: 1223 extensions as of 16 November 2015
$mime_types = array(
'3dm' => array('x-world/x-3dmf'),
'3dmf' => array('x-world/x-3dmf'),
@eeree
eeree / resetAdminPasswordEzPublish
Created January 21, 2015 14:35
eZ Publish - how to reset admin password
SQL:
==
UPDATE `ezuser_setting` SET `is_enabled` = '1' WHERE `ezuser_setting`.`user_id` =14;
UPDATE `ezuser` SET `password_hash` = 'bab77ccf06f0b1f982e11c60f344c3c2' WHERE `ezuser`.`contentobject_id` =14;
SITE.INI:
==
[UserSettings]
HashType=md5_user
@dfritschy
dfritschy / SearchController.php
Created November 14, 2014 10:15
Full Text Search in eZ Publish 5 using a legacy closure
$searchText = $request->query->get('SearchText');
$sort = array( 'modified' => 'false' );
$contentTypeIdenfiers = array( 31 );
$searchResult = $this->getLegacyKernel()->runCallback(
function () use ( $searchText, $sort, $contentTypeIdenfiers )
{
// eZFunctionHandler::execute is the equivalent for a legacy template fetch function
// The following is the same than fetch( 'content', 'search', hash(...) )
return eZFunctionHandler::execute(
@brookinsconsulting
brookinsconsulting / symfony-legacy-kernel-callback-user-login-example-snippet.php
Last active September 24, 2015 10:08
This snippet of php eZ Publish 5 (Symfony Stack) code uses the legacy kernel api to login to the user you wish to use to perform actions within eZ Publish Legacy as! Default admin user used in this example. Reference: http://share.ez.no/forums/ez-publish-5-platform/interracting-with-legacy-from-symfony-command#comment84674
<?php
protected function execute(InputInterface $input, OutputInterface $output) {
$repository = $this->getContainer()->get('ezpublish.api.repository');
$legacyKernel = $this->getContainer()->get('ezpublish_legacy.kernel');
$userID = 14; // UserID of the Default Admin User
$user = $repository->getUserService()->loadUser( $userID );
$repository->setCurrentUser( $user );
$result = $legacyKernel()->runCallback(
function () use( $userID )
@flovntp
flovntp / LanguageSwitcherController.php
Last active August 29, 2015 14:06
Language switcher
<?php
namespace My\DesignBundle\Controller;
use eZ\Bundle\EzPublishCoreBundle\Controller;
use eZ\Publish\Core\MVC\Symfony\Routing\RouteReference;
class LanguageSwitcherController extends Controller
{
public function languagesAction( RouteReference $routeReference )
{
@cybertoast
cybertoast / gist:6499708
Last active February 9, 2023 00:20
Get a list of all flask routes, and their endpoint's docstrings as a helper resource for API documentation.
@admin_api.route('/help', methods=['GET'])
def routes_info():
"""Print all defined routes and their endpoint docstrings
This also handles flask-router, which uses a centralized scheme
to deal with routes, instead of defining them as a decorator
on the target function.
"""
routes = []
for rule in app.url_map.iter_rules():
@rduplain
rduplain / README.md
Created August 30, 2012 16:07
Flask-Script: demo passing in configuration file.

This demonstrates that you can configure a Flask application through Flask-Script, without having to create a Flask instance or deal with circular dependencies. Note that Flask-Script's Manager accepts a factory function in place of a Flask app object.

Running:

python manage.py runserver

gives "Hello, world!" on http://localhost:5000/, while running:

python manage.py runserver -c development.cfg
@fhats
fhats / flask_routes_in_doc
Created December 11, 2011 03:26
Subclass of Flask to automatically store routes in the view handler's docstrings
class FlaskWithRouteDocs(Flask):
"""A subclass of Flask to allow using :route: and :methods: in docstrings, a la Sphinx."""
def route(self, rule, **options):
def decorator(f):
route_dec = super(FlaskWithRouteDocs, self).route(rule, **options)
methods_str = ','.join(options.get('methods', ['GET']))
if f.__doc__ is not None and ":route:" in f.__doc__:
f.__doc__ = f.__doc__.replace(":route:", rule)
else:
@comfuture
comfuture / manage-daemon
Created November 11, 2010 06:28
init script sample for gunicorn daemonized flask app
#!/bin/bash
gunicorn="/usr/local/bin/gunicorn"
prog="dev.maroo.info"
PROJECT_HOME="/home/maroo/sites/$prog"
pid="/var/lock/$prog"
RETVAL=0
start() {