Skip to content

Instantly share code, notes, and snippets.

View nikosd's full-sized avatar

Nikos Dimitrakopoulos nikosd

View GitHub Profile
@nikosd
nikosd / csi-esi.js
Last active August 29, 2015 13:56
Executing SSI/ESI on the client.
/*
* ESI Parser 1.00 - Poor Man's ESI
*
* - or - I'm tired of seeing the wrong thing in my browser while developing.
*
* This code provides a client-side ESI parsing capability. It was created
* to provide an easier way of developing and testing sites that use ESI
* when not behind the cache or other system that provides the ESI parsing.
* It requires jQuery (anything after v1.2 should be fine)
*
@nikosd
nikosd / convert_tables_to_utf8.sql
Created October 21, 2011 07:43
Fixing 'SQL exception: Incorrect string value' on TeamCity with MySQL database
SELECT CONCAT('ALTER TABLE `', t.`TABLE_SCHEMA`, '`.`', t.`TABLE_NAME`, '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') as stmt
FROM `information_schema`.`TABLES` t
WHERE 1
AND t.`TABLE_SCHEMA` = 'teamcity'
ORDER BY 1
@nikosd
nikosd / Questions
Created September 6, 2011 23:24
RubyShift
Day job: Web Developer / Software Engineer
Favorite Ruby project: Rails
Open Source contributions: Minor patches/features in various libraries like ruby-oauth, redmine, radiant, spatial_adapter, jquery-autocomplete, etc
How do you use GitHub: Forking & patching OS projects and hosting toy projects
@nikosd
nikosd / Questions
Created September 6, 2011 23:19
GOTO Amsterdam
Day job: Web Developer / Software Engineer
What is your language of choice: Ruby
Open Source contributions: Minor patches in various libraries like ruby-oauth, redmine, radiant, spatial_adapter, jquery-autocomplete, etc
How do you use GitHub: Forking & patching OS projects and hosting toy projects
@nikosd
nikosd / locale_rails_multipart_mail_patch.rb
Created November 5, 2010 10:56
Monkey patching ActionMailer::Base#create! to support localized implicit multipart mails.
# This is a FUGLY hack to make multipart emails work with localized templates
# in the form of method_el_GR.text.plain.rhtml (or .erb).
#
# NOTE : This is tested against Rails 2.3.8 and is a very good candidate to break in 2.3.9 and up.
ActionMailer::Base.class_eval do
def create!(method_name, *parameters) #:nodoc:
initialize_defaults(method_name)
__send__(method_name, *parameters)
# If an explicit, textual body has not been set, we check assumptions.
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq.Expressions;
// The class derived from DynamicObject.
public class DynamicDictionary : DynamicObject
{
// The inner dictionary.
Dictionary<string, object> dictionary
# override the ssh problem with this:
ssh user@host "/bin/bash -i"
# now fix the issue
rm -rf /dev/ptmx
mknod /dev/ptmx c 5 2
chmod 666 /dev/ptmx
umount /dev/pts
rm -rf /dev/pts
mkdir /dev/pts
class ItemFetcherWorker < BackgrounDRb::MetaWorker
set_worker_name :item_fetcher_worker
def create(args = nil)
end
def set_search(search)
@search = search
end
def fetch_query_and_items
@nikosd
nikosd / pmx_operator.rb
Created January 18, 2009 11:29
Two point partial preservation crossover for PermutationGenotype, also known as Partially Mapped Crossover (PMX).
# Two point partial preservation crossover for PermutationGenotype, also known as Partially Mapped Crossover (PMX).
#
# The PMX proceeds by choosing two cut points at random:
# Parent 1: hkcefd bla igj
# Parent 2: abcdef ghi jkl
#
# The cut-out section defines a series of swapping operations to be performed on the second parent.
# In the example case, we swap b with g, l with h and a with i and end up with the following offspring:
# Offspring: igcdef bla jkh
# Performing similar swapping on the first parent gives the other offspring:
@nikosd
nikosd / database.js
Created January 18, 2009 11:08
Some sample code from my thesis about creating offline web applications (http://nikosd.com/work.html). iris.js is partially the "core" of the app and database.js is a simple object mapping of the database.
var DB = {
init: function(){
dojox.sql("CREATE TABLE IF NOT EXISTS received_messages ("
+ "id INTEGER PRIMARY KEY, "
+ "title TEXT NOT NULL, "
+ "content TEXT, "
+ "sender_name TEXT NOT NULL, "
+ "sender_id TEXT NOT NULL) ");
dojox.sql("CREATE TABLE IF NOT EXISTS local_draft_messages ("