Skip to content

Instantly share code, notes, and snippets.

# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 2109
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
@electronicbites
electronicbites / default
Last active December 17, 2015 06:28
ngixn conf for prosper202
server {
#server_name example.com www.example.com;
# Make site accessible from http://localhost/
server_name _;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
root /vagrant/prosper202;
index index.php;
@electronicbites
electronicbites / grub
Last active December 17, 2015 06:09
grub config on ubuntu with xen on a local vagrant box
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT="Xen 4.1-amd64"
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.11'
gem 'activeadmin'
gem 'activerecord-postgres-hstore'
gem 'acts_as_list'
gem 'airbrake'
gem 'apn_sender', require: 'apn'
@electronicbites
electronicbites / feeditem.json
Created December 3, 2012 18:05
json result for feeditem
{
"feed_items" = (
{
avatar = "<null>";
"created_at" = 1354554275;
"event_type" = "task_completed";
feedable = {
object = {
big = "http://rylyty-production.s3.amazonaws.com/app/public/assets/tasks/76/50/original?1354554272";
comment = jgdfhj;
class PushNotifier
def send_notification_to_user_limited(user, message)
if (user.last_apn_send_date.nil? || Time.now - 12.hours > user.last_apn_send_date)
send_notification_to_user(user, message)
user.last_apn_send_date = Time.now
user.save
end
end
require './spec/support/factories.rb'
user = FactoryGirl.create(:user)
game = FactoryGirl.create(:photo_game)
task = game.tasks.last
task.timeout_secs = 20
task.save
app.post '/api/v1/login', login: user.username, password: 'secret'
app.post "/api/v1/games/#{game.id}/buy.json"
@electronicbites
electronicbites / application_helper.rb
Created October 29, 2012 10:16
yield_for content block either set or blank
def yield_for name, default = ""
output = content_for(name)
output.blank? ? default : output
end
@electronicbites
electronicbites / game_controller_spec.rb
Created September 28, 2012 12:03
sample for specs for gamecontroller
it 'should contain a collection of games' do
game1 = FactoryGirl.create(:game, titel: 'foo1')
game2 = FactoryGirl.create(:game, titel: 'foo2')
get :index
json = ActiveSupport::JSON.decode(response.body)
json[:game].size == 2
end
it 'should contain the title of the game' do
game = FactoryGirl.create(:game, titel: 'foo1')
@electronicbites
electronicbites / gist:3750861
Created September 19, 2012 17:13
sample code for testing spatial indexes with mongoid
class Geo
include Mongoid::Document
BERLIN_LOCATION = [52.51171, 13.44325]
index({ 'location' => '2d' })
field :location, type: Array #0: latitude, 1: longitude
scope :nearby, ->(location, distance) { where('location' => {'$within' =>
{ '$center' => [location, distance], '$uniqueDocs' => true }})}
scope :berlin, -> {nearby(BERLIN_LOCATION, 2)}