Skip to content

Instantly share code, notes, and snippets.

View happygrizzly's full-sized avatar
🐻

Aleksey Filippov happygrizzly

🐻
View GitHub Profile
@happygrizzly
happygrizzly / AccountsController.cs
Last active June 20, 2017 01:46
ValidationSummaryMultipleForms
namespace project
{
// ...
public class AccountsController : Controller {
// ...
[HttpGet, Route("accounts/manage/change-passwords", Name="change-password")]
[Authorize(Roles="Admin")]
@happygrizzly
happygrizzly / MAMP Silex htaccess
Created February 3, 2016 13:56 — forked from crzapata/MAMP Silex htaccess
htaccess definition for silex when using MAMP
<IfModule mod_rewrite.c>
RewriteEngine on
#uncomment next line if silex app root is in a mamp subdirectory
#RewriteBase /your_mamp_htdocs_silex_app_root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ web/index.php [L]
</IfModule>
define your silex routes as follows:
$app->get('/your_mamp_htdocs_silex_app_root/', function() {
@happygrizzly
happygrizzly / JsonMessageFormatter.cs
Created February 11, 2016 08:14 — forked from jchadwick/JsonMessageFormatter.cs
MSMQ Message JSON Formatter
using System;
using System.IO;
using System.Messaging;
using System.Text;
using Newtonsoft.Json;
public class JsonMessageFormatter : IMessageFormatter
{
private static readonly JsonSerializerSettings DefaultSerializerSettings =
new JsonSerializerSettings {
@happygrizzly
happygrizzly / generate.php
Created September 27, 2016 12:32 — forked from jreinke/generate.php
Default password encoding in Silex micro-framework
<?php
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
$encoder = new MessageDigestPasswordEncoder();
echo $encoder->encodePassword('foo', '');
// 5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg==
@happygrizzly
happygrizzly / pagination.html.twig
Created October 5, 2016 13:49 — forked from SimonSimCity/pagination.html.twig
A gist for pagination in Twig, based on the total number of pages, the current page and some URL-settings.
{#
Source: http://dev.dbl-a.com/symfony-2-0/symfony2-and-twig-pagination/
Updated by: Simon Schick <[email protected]>
Parameters:
* currentFilters (array) : associative array that contains the current route-arguments
* currentPage (int) : the current page you are in
* paginationPath (string) : the route name to use for links
* showAlwaysFirstAndLast (bool) : Always show first and last link (just disabled)
* lastPage (int) : represents the total number of existing pages
CREATE TABLE `documents` (
`id` INT NOT NULL AUTO_INCREMENT,
`id_category` INT NOT NULL,
-- `id_department` INT NOT NULL,
`title` VARCHAR(150) NOT NULL,
`comment` MEDIUMTEXT,
`filename` VARCHAR(150),
`ts` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_category`) REFERENCES categories(`id`) ON DELETE NO ACTION
@happygrizzly
happygrizzly / knockout.bootstrap.glyphicon.tree.css
Created April 14, 2017 07:24 — forked from seiyria/knockout.bootstrap.glyphicon.tree.css
A custom, collapsible navigation tree using knockout.js (and knockout.mapping.js), Bootstrap 3, and glyphicons. Example picture: http://puu.sh/5RWjW.png, fiddle here: http://jsfiddle.net/Ar88e/1/
#nav-bar ul {
list-style-type: none;
}
#nav-bar {
padding-left: 0;
}
#nav-bar > ul {
padding-left: 20px;
@happygrizzly
happygrizzly / vhost.conf
Created July 7, 2017 08:43
vhost config
<VirtualHost localhost:YOUR_PORT>
ServerName localhost
Define WebDirPath WEB_ROOT_DIR_PATH
DocumentRoot ${WebDirPath}
Alias /YOUR_PROJECT_NAME ${WebDirPath}
<Directory ${WebDirPath}>
Options -Indexes

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
@happygrizzly
happygrizzly / vuejs-php.md
Created October 19, 2017 14:52
VueJs and PHP

VueJs and PHP

Setup

First test