Skip to content

Instantly share code, notes, and snippets.

class ActiveRecord::Base
def self.table_name_prefix
"appname."
end
end
class TransactionalBase < ActiveRecord::Base
self.abstract_class = true
establish_connection "#{RAILS_ENV}-transactional"
<?php
/**
* Plugin Name: Desk.com Multipass
* Plugin URI: https://github.com/tstachl/wp-desk_multipass
* Description: A WordPress plugin to add a menu option that redirects to your Desk.com Support Site.
* Version: 1.0.0
* Author: Thomas Stachl
* Author URI: https://github.com/tstachl
* License: BSD 3-Clause License
*/
@patakijv
patakijv / gist:2763005
Created May 21, 2012 15:54
exception when saving a note
05-20 12:13:57.011: W/dalvikvm(15731): threadid=1: thread exiting with uncaught exception (group=0x401fe760)
05-20 12:13:57.031: E/TiApplication(15731): (main) [14,43241] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 2.0.1,2012/04/12 16:36,999c68a
05-20 12:13:57.031: E/TiApplication(15731): java.lang.NullPointerException
05-20 12:13:57.031: E/TiApplication(15731):    at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:270)
05-20 12:13:57.031: E/TiApplication(15731):    at android.view.View.measure(View.java:10848)
05-20 12:13:57.031: E/TiApplication(15731):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4353)
05-20 12:13:57.031: E/TiApplication(15731):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:267)
05-20 12:13:57.031: E/TiApplication(15731):    at android.view.View.measure(View.java:10848)
05-20 12:13:57.031: E/TiApplication(15731):    at android.widget.LinearLayout.measureVertical(LinearLayou
@patakijv
patakijv / gist:2719545
Created May 17, 2012 15:10
rails string to boolean migration while preserving existing data
class ChangeIgnoredToBoolean < ActiveRecord::Migration
# we should have been using boolean vs string for a flag instead of a string
def up
# preserve existing data
@saved_ignored_state = Message.all.map(&:ignored)
change_column(:messages, :ignored, :boolean, :default => false)
Message.reset_column_information
Message.all.each_with_index do |message,index|
message.update_attribute(:ignored,@saved_ignored_state[index] == 'true')
end
@patakijv
patakijv / gist:2696781
Created May 14, 2012 20:48
slicehost discussion for iptable
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere 127.0.0.0/8 reject-with icmp-port-unreachable
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:www
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:3222
ACCEPT icmp -- anywhere anywhere icmp echo-request
LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix `iptables denied: '
@patakijv
patakijv / app.js
Created December 27, 2011 23:52
Global Variables Test
var MY_BLUE = "#26A9E0";
var module = require("module");
Ti.API.info("[APP] info is "+JSON.stringify(module.info));