Skip to content

Instantly share code, notes, and snippets.

View VladoMS's full-sized avatar

Vladislav Stoyanov VladoMS

View GitHub Profile
@chrisjensenuk
chrisjensenuk / JsMinifyCodeSettings.cs
Created October 16, 2012 16:18
Preserve important comments in javascript files when using ASP.NET MVC 4 Bundles
using System;
using System.Web;
using System.Web.Optimization;
using System.Collections;
using Microsoft.Ajax.Utilities;
using System.Collections.Generic;
using System.Text;
//example bundle configuration
public class BundleConfig
@sharshenov
sharshenov / gist:33c0dd55c838ecd5762c
Created November 16, 2015 11:16
Rails middleware for health check endpoint
class HealthCheckResponder
def initialize(app, options = {})
@app = app
end
def call(env)
if env["REQUEST_PATH"] == "/health_check"
return [200, {}, [""]]
else
@scottwb
scottwb / nginx_subdomain.conf
Created January 25, 2011 16:38
Nginx config to route domain and subdomains, except for explicit virtual hosts, to the www subdomain.
http {
# Default virtual host for www.example.com. This will pick up all HTTP
# requests to port 80 that are not for one of the other virtual hosts.
server {
listen 80;
server_name www.example.com;
# ...your server config here...
@mombrea
mombrea / SortSearchExtensions.cs
Created August 4, 2015 18:14
Extension Methods for table sorting and search query
using System.Collections.Specialized;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace My.App
{
public static class Extensions
{
/// <summary>
buttonHTML = """<button type="button" class="attach" data-action="x-attach">Attach Files</button>"""
fileInputHTML = """<input type="file" multiple>"""
$(Trix.config.toolbar.content).find(".button_group.block_tools").append(buttonHTML)
$(document).on "trix-action-invoke", ($event) ->
if $event.originalEvent.actionName is "x-attach"
editorElement = $event.target
editorElement.focus()
@brianhempel
brianhempel / enumerator_to_json.rb
Created February 17, 2015 17:32
Lazily convert an Enumerator or Enumerator::Lazy to a JSON array. Save as config/initializers/enumerator_to_json.rb
# Natively, Enumerators get JSONized like "#<Enumerator::Lazy:0x007f8714807080>", or they explode, either of which is a problem.
# We want them to make an array, and do it lazily so we don't have to keep the items in memory!
class Enumerator
def to_json(state)
state.depth += 1
string = "[\n"
first_item = true
self.each do |item|
<?php
namespace NoxLogic\DemoBundle\Form\Type;
use Doctrine\ORM\EntityManager;
use NoxLogic\DemoBundle\Entity\Province;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
@samsonasik
samsonasik / gist:3988701
Created October 31, 2012 17:57
Send HTML Mail Using ZF2
use Zend\Mail\Message;
use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mime\Message as MimeMessage;
use Zend\Mime\Part as MimePart;
use Zend\Mail\Transport\SmtpOptions;
//////////
$message = new Message();
@jgv
jgv / gist:1502777
Created December 20, 2011 19:03 — forked from trevorturk/gist:34895
Allow "uploads via url" with Rails and Paperclip
#
# See also: http://almosteffortless.com/2008/12/11/easy-upload-via-url-with-paperclip/
#
# Allow "uploads via url" with Rails and Paperclip
#
# http://www.thoughtbot.com/projects/paperclip
# http://github.com/thoughtbot/paperclip/tree/master
# http://groups.google.com/group/paperclip-plugin/browse_thread/thread/456401eb93135095
#
# This example is designed to work with a "Photo" model that has an "Image" attachment
@psykzz
psykzz / downloader.class.php
Created September 9, 2012 21:51
Simple rate limited downloader.
<?php
/* *
* @filename downloader.class.php
* @author PsyKzz
* @version 1.0.0
* @description Simple class to rate limit your downloads, while also providing a custom tickrate to combat timeout issues.
* @url http://www.psykzz.co.uk
*
* @license 'WTFPL ' - "Do What The Fuck You Want To Public License".
* This program is free software. It comes without any warranty, to