Skip to content

Instantly share code, notes, and snippets.

@amite
amite / sinatra_jquery_test.rb
Created March 12, 2012 02:28 — forked from mr-rock/sinatra_jquery_test.rb
An example of Sinatra working with Ajaxified JQuery based on some pieces of code published by Rafael George on the Sinatra Google Group.
require 'sinatra'
require 'dm-core'
require 'haml'
DataMapper.setup(:default, 'sqlite3::memory:')
class Message
include DataMapper::Resource
property :id, Serial
@amite
amite / bootstrap-notifications.js
Created April 23, 2012 05:18 — forked from anonymous/bootstrap-notifications.js
Javascript for notifications (alerts) for Twitter Bootstrap
/*
I created the following javascript to use bootstrapt's notifications through Javascript.
If you like it you may consider adding it to bootstrapt. Feel free to modify if necessary.
Be sure you define a div #notification-area, where the notifications are going to be displayed by default.
I use it with jQuery 1.7.1 but it should work with older versions. Is also use jquery.hotkeys.js ( https://github.com/jeresig/jquery.hotkeys ) for block messages hotkeys
*/
(function( $ ){
var pub = {
@amite
amite / gist:2974247
Created June 22, 2012 17:58
Deduping a list of urls using PHP
<?php
// get all urls from the home page that are
$html = file_get_contents('http://www.catwalkyourself.com');
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
@amite
amite / Clients Controller
Created July 30, 2012 18:17
Get request for laravel with backbone not working
class Clients_Controller extends Base_Controller {
public $restful = true;
public function get_index()
{
return Response::eloquent(Client::find(1));
}
}
@amite
amite / rss insert posts wordpress
Created October 31, 2012 03:38
Inserting rss feed items into wordpress at scheduled intervals
/*
| -------------------------------------------------------------------
| Schedule and update fashion news with the news rss feed
| -------------------------------------------------------------------
|
| */
add_action('init', function(){
$timescheduled = wp_next_scheduled('update_feed');
wp_unschedule_event($timescheduled, 'update_feed');
@amite
amite / gist:4139015
Created November 24, 2012 09:29
http.conf
#
# Mac OS X / Mac OS X Server
# The <IfDefine> blocks segregate server-specific directives
# and also directives that only apply when Web Sharing or
# server Web Service (as opposed to other services that need Apache) is on.
# The launchd plist sets appropriate Define parameters.
# Generally, desktop has no vhosts and server does; server has added modules,
# custom virtual hosts are only activated when Web Service is on, and
# default document root and personal web sites at ~username are only
# activated when Web Sharing is on.
@amite
amite / gist:4139020
Created November 24, 2012 09:32
vhosts
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
require 'forwardable'
class User
extend Forwardable
attr_accessor :view_delegate_class, :first_name, :last_name
def_delegators :view_delegate, :full_name
def initialize(first_name, last_name)
@first_name = first_name
@amite
amite / client profile data
Last active December 10, 2015 14:48
c.profile_datum
I have a client class
````
class Client < ActiveRecord::Base
attr_accessible :name, :notetag
has_many :profile_datum
end
````
..and a ProfileDatum class
class GearController < ApplicationController
before_filter :find_gear
private
def find_gear
@gear = Gear.type(params[:type].to_s.singularize).where(:reference => params[:id]).first if params[:id]
end
end