Skip to content

Instantly share code, notes, and snippets.

View mac2000's full-sized avatar

Alexandr Marchenko mac2000

View GitHub Profile
@mac2000
mac2000 / ExampleForm.php
Created September 2, 2013 07:51
Silex Reusing Forms Example
<?php // src/Acme/Form/Type/ExampleForm.php
namespace Acme\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
class ExampleForm extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('email', 'email', array(
@mac2000
mac2000 / Version1.php
Created September 4, 2013 15:22
Doctrine Migrations Example, without command line console aplication, that could be run from command line and from web browser
<?php # src/Acme/Migrations/Version1.php
namespace Acme\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version1
*
* Notice that file and class names MUST be Version*.php
@mac2000
mac2000 / slugify_speed_tests.php
Created January 15, 2014 10:39
Speed tests for different slugify methods
<?php
class PregReplaceSlugify
{
public $rules = array(
'/º|°/' => 0,
'/¹/' => 1,
'/²/' => 2,
'/³/' => 3,
'/æ|ǽ|ä/' => 'ae',
@mac2000
mac2000 / gist:0a2678826034249aba0d
Created June 28, 2014 08:51
Vagrant 1.6.3 debug log on ghuntley/WindowsServer2012R2Datacenter box under Hyper-V
INFO global: Vagrant version: 1.6.3
INFO global: Ruby version: 2.0.0
INFO global: RubyGems version: 2.0.14
INFO global: VAGRANT_EXECUTABLE="C:\\HashiCorp\\Vagrant\\embedded\\gems\\gems\\vagrant-1.6.3\\bin\\vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="C:\\HashiCorp\\Vagrant\\embedded"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_INTERNAL_BUNDLERIZED="1"
INFO global: VAGRANT_LOG="debug"
INFO global: Plugins:
# Install ttfautohint on Ubuntu 12.04 LTS
# @author: Jean Lescure
# 2014/04/23
# Clone ttfautohint git repo to 'tmp' dir and cd into resulting repo folder
cd /tmp
git clone git://repo.or.cz/ttfautohint.git
cd ttfautohint
# Handle bootstrap's dependency: automake
@mac2000
mac2000 / custom_post_type_with_required_custom_field.php
Last active February 13, 2022 21:51
Wordpress: Custom Post Type with Required, Unique Custom Field Sample Plugin
<?php
/*
Plugin Name: Custom Post Type With Required Custom Field
Plugin URI: http://mac-blog.org.ua/
Description: Sample plugin demonstrating how to add required unique custom field to custom post type
Author: Marchenko Alexandr
Version: 1.0
Author URI: http://mac-blog.org.ua/
*/
@mac2000
mac2000 / ConvertTo-Markdown.ps1
Last active October 4, 2022 00:59 — forked from BenNeise/ConvertTo-Markdown.ps1
Converts a PowerShell object to a Markdown table.
<#
.Synopsis
Converts a PowerShell object to a Markdown table.
.EXAMPLE
$data | ConvertTo-Markdown
.EXAMPLE
ConvertTo-Markdown($data)
#>
Function ConvertTo-Markdown {
[CmdletBinding()]
@mac2000
mac2000 / BoxStarter.txt
Last active August 29, 2015 14:21
BoxStarter sample
# Invoke using following syntax:
# http://boxstarter.org/package/url?[raw link to this gist]
# Boxstarter options
$Boxstarter.PackageName = "powershell4"
$Boxstarter.Version = "1.0.0"
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
@mac2000
mac2000 / Boxstarter.ps1
Last active November 3, 2015 12:59
Boxstarter sample
Set-ExplorerOptions -showFileExtensions
Enable-RemoteDesktop
choco install googlechrome -y
choco install sublimetext3 -y
choco install skype -y
@mac2000
mac2000 / sample.json
Last active December 15, 2015 08:28
Sample movies data
[
{
"Title": "Chappie",
"Year": 2015,
"imdbRating": 6.9,
"Genre": ["Action", "Crime", "Sci-Fi"]
},
{
"Title": "Star Wars: The Force Awakens",
"Year": 2015,