Skip to content

Instantly share code, notes, and snippets.

View jverdeyen's full-sized avatar

Joeri Verdeyen jverdeyen

View GitHub Profile
@jverdeyen
jverdeyen / gitlab_reque
Created September 11, 2012 21:36
Gitlab Resque Worker init
#! /bin/bash
# GITLAB
# Maintainer: @joeri
### BEGIN INIT INFO
# Provides: gitlab
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
@jverdeyen
jverdeyen / nginx.conf
Created October 28, 2012 09:11
Deploy Rails on Ubuntu server 12.04 with Nginx, Unicorn, Mongodb, Mongoid
# This file should be placed on the directory of ~/blog/config
upstream unicorn {
server unix:/tmp/unicorn.todo.socket fail_timeout=0;
}
server {
listen 80 default;
#server_name example.com;
root /home/username/blog/public;
@jverdeyen
jverdeyen / gist:3968266
Created October 28, 2012 10:28
Webistano setup: ruby/nginx/mysql/unicorn on Ubuntu 12.04
# install packages
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y build-essential git-core wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev openssh-server git-core python-dev python-pip libyaml-dev sendmail mysql-server mysql-client libmysqlclient-dev
# install ruby from source
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
tar xzfv ruby-1.9.2-p290.tar.gz
cd ruby-1.9.2-p290
./configure
@jverdeyen
jverdeyen / gist:3969832
Created October 28, 2012 20:39
Webistrano Init script
#! /bin/bash
# WEBISTRANO
# Maintainer: @jverdeyen
# App Version: 1.0
### BEGIN INIT INFO
# Provides: webistrano
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
# Required-Stop: $local_fs $remote_fs $network $syslog
CREATE TABLE `cities` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`zip` smallint(4) unsigned NOT NULL,
`name` varchar(100) NOT NULL DEFAULT '',
`name_upper` varchar(100) NOT NULL DEFAULT '',
`province` varchar(200) NOT NULL DEFAULT '',
`country` varchar(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `zip` (`zip`),
KEY `name` (`name`)
server="servername"
user="username"
path="/home/username/"
mount_point="/Volumes/$server"
mkdir -p "$mount_point"
/usr/local/bin/sshfs "$user@$server:$path" "$mount_point" -o "auto_cache,reconnect,negative_vncache,noappledouble,volname=$server,CheckHostIP=no,StrictHostKeyChecking=no"
require 'rubygems'
require 'mechanize'
agent = Mechanize.new
agent.get('https://account.dyn.com/entrance/') do |page|
puts page.title # Output: Create Dyn Account or Login
# Submit the login form
my_page = page.form_with(:action => '/entrance/') do |form|
form.username = "<insert username here>"
@jverdeyen
jverdeyen / gist:5856663
Created June 25, 2013 07:32
Symfony2 Sublime Text 2 project file
{
"folders":
[
{
"path": ".",
"file_exclude_patterns": ["*.php~"],
"folder_exclude_patterns": ["app/cache", "app/logs", "web/css", "web/js", "vendor/", "build/coverage", "build/logs","web/media/cache", "web/assetic"]
}
],
"settings":
#!/bin/bash
#
# PHP 5.4 Deprecated function checker
#
# Version: 0.0.3
#
# Original Author: Michiel Roos <michiel@donationbasedhosting.org>
#
# http://www.php.net/manual/de/migration54.incompatible.php
# http://www.php.net/manual/en/migration54.deprecated.php
@jverdeyen
jverdeyen / gist:6918475
Last active December 25, 2015 04:39
A problem with Symfony2 form collections and multiple file uploads

I'm having a problem with multiple file uploads in a collection form type.

This is the case:

  • Report
    • Attachments
      • Files (UploadedFile)
      • Photos (UploadedFile)

A report object has an Attachment object, the Attachment object has multiple in ArrayCollections (ManyToMany) with UploadedFile object in it.