Skip to content

Instantly share code, notes, and snippets.

View happygrizzly's full-sized avatar
🐻

Aleksey Filippov happygrizzly

🐻
View GitHub Profile
@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 <simonsimcity@gmail.com>
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
@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 / 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 / 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 / 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 / meta-tags.md
Created December 24, 2015 06:54 — forked from kevinSuttle/meta-tags.md
List of Usable HTML Meta and Link Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
@happygrizzly
happygrizzly / CoffeeCompiler.cs
Created December 22, 2015 10:03 — forked from Crisfole/CoffeeCompiler.cs
CoffeeScript and Less
using System;
using System.Collections.Generic;
using System.IO;
using MsieJavaScriptEngine;
public class CoffeeScriptCompiler : ContentCompiler {
public CoffeeScriptCompiler() {
Javascript.Engine.RegisterCompiler("CoffeeScript", LoadCoffeeScript, MakeCompiler);
}
namespace your_project_name
{
using System.Threading;
public abstract class PollerServiceBase : System.ServiceProcess.ServiceBase {
protected Thread workerThread = null;
protected AutoResetEvent finishedEvent = new AutoResetEvent(false);
public PollerServiceBase(string serviceName) {
@happygrizzly
happygrizzly / UtilityController.php
Last active September 11, 2015 06:43 — forked from jchaney01/UtilityController.php
Angular.js Uploadify Directive with Image Editor and Laravel Backend
class UtilityController extends BaseController {
public function upload()
{
$file = Input::file('Filedata');
$name = Date("now").'-'.$file->getClientOriginalName();
$uploadSuccess = $file->move(public_path().'/uploads',$name);
if( $uploadSuccess ) {
return Response::json(array(
"status"=>"200",
@happygrizzly
happygrizzly / ng-prism.js
Last active September 11, 2015 06:21 — forked from mikomatic/ng-prism.js
Angularjs directive with prism code highlight
/**
* Usage
*
* <ng-prism class="language-css">
* body {
* color: red;
* }
* </ng-prism>
*
* the files prismjs and prism css must be included in HTML, use class "language-XXX" to specify language