Skip to content

Instantly share code, notes, and snippets.

View tomas-stefano's full-sized avatar

Tomas D'Stefano tomas-stefano

  • Ministry of Justice
  • London
View GitHub Profile
@tomas-stefano
tomas-stefano / init.sh
Created January 10, 2013 20:34
Init script in a debian package with god
#! /bin/sh
### BEGIN INIT INFO
# Provides: my-app
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: My app package
### END INIT INFO
set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin

java.io.FileNotFoundException: no segments* file found in org.apache.lucene.store.NIOFSDirectory@/Users/tomas_stefano/workspace/codeminer/Palpiteros/solr/data/development/index: files: lucene-921e61b69936e9a77a02910e007e336e-write.lock at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:655) at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:538) at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:306) at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:1577) at org.apache.lucene.index.IndexWriter.(IndexWriter.java:1402) at org.apache.solr.update.SolrIndexWriter.(SolrIndexWriter.java:190) at org.apache.solr.update.UpdateHandler.createMainIndexWriter(UpdateHandler.java:98) at org.apache.solr.update.DirectUpdateHandler2.openWriter(DirectUpdateHandler2.java:173)

$ psql foo

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

Some Dirty solutions

Change this:

 $ postgres -D /usr/local/var/postgres

FATAL: could not create shared memory segment: Invalid argument DETAIL: Failed system call was shmget(key=5432001, size=14499840, 03600). HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter. You can either reduce the request size or reconfigure the kernel with larger SHMMAX. To reduce the request size (currently 14499840 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections. If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the request size or reconfiguring SHMMIN is called for. The PostgreSQL documentation contains more information about shared memory configuration.

@tomas-stefano
tomas-stefano / Gemfile
Created November 1, 2012 01:49
Goliath and Routing
source :rubygems
gem 'goliath', '1.0.0'
gem 'rack', '1.4.1'
@tomas-stefano
tomas-stefano / presenter.rb
Created October 14, 2012 17:28
Presenter
require 'delegate'
require 'active_support/core_ext/object'
class Presenter < SimpleDelegator
# include Rails router methods to the presenter
#
include Rails.application.routes.url_helpers
delegate :render, :image_tag, :link_to, to: :helpers
@tomas-stefano
tomas-stefano / debug_result.txt
Created October 14, 2012 15:17
Why was different? :\
[2] pry(#<#<Class:0x00000129592ef8>>)> ActionController::Base.view_paths
=> #<ActionView::PathSet:0x0000012967bd88
@paths=
[/Users/tomas/workspace/Projetos/r12-team-361/app/views,
/Users/tomas/.rvm/gems/ruby-1.9.2-p320@gangnam_style/gems/kaminari-0.14.1/app/views,
/Users/tomas/.rvm/gems/ruby-1.9.2-p320@gangnam_style/gems/devise-2.1.2/app/views]>
[3] pry(#<#<Class:0x00000129592ef8>>)> ApplicationController.helpers.view_paths
@tomas-stefano
tomas-stefano / feed.rb
Last active October 10, 2015 23:38
Simple.
require 'net/http'
require 'xmlsimple'
module SomeSite
class Feed
attr_accessor :url, :cache_key, :storage, :xml, :http_adapter
# Class responsible to search the uri and save in the store
# The store need to implement the #write and #read method.
#
@tomas-stefano
tomas-stefano / bash_profile.sh
Created August 26, 2012 20:02
My Bash Profile
# Colours
export BLUE="\[\033[0;34m\]"
export NO_COLOR="\[\e[0m\]"
export GRAY="\[\033[1;30m\]"
export GREEN="\[\033[0;32m\]"
export LIGHT_GRAY="\[\033[0;37m\]"
export LIGHT_GREEN="\[\033[1;32m\]"
export LIGHT_RED="\[\033[1;31m\]"
export RED="\[\033[0;31m\]"
export WHITE="\[\033[1;37m\]"
@tomas-stefano
tomas-stefano / reinstall.sh
Created August 7, 2012 21:17
Reinstalling Mysql on Mac via Homebrew
brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
rm ~/Library/LaunchAgents/com.mysql.mysqld.plist
sudo rm -rf /usr/local/var/mysql