Skip to content

Instantly share code, notes, and snippets.

@gciampa
gciampa / index.html
Created April 2, 2023 18:22
Tailwind animations with Stimulus
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script type="module">
import { Application, Controller } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js"
import { enter, leave, toggle } from "https://unpkg.com/[email protected]/index.js"
window.Stimulus = Application.start()
@gciampa
gciampa / git-setup.sh
Created November 23, 2011 19:55
Git setup niceties
# via https://gist.github.com/419201#file_gitconfig.bash
# Install (from Matt's gist) these useful Git aliases & configurations with the following command:
# $ bash <(curl -s https://raw.github.com/gist/419201/gitconfig.bash)
git config --global color.ui auto # colorize output (Git 1.5.5 or later)
git config --global color.interactive auto # and from 1.5.4 onwards, this will works:
echo "Set your name & email to be added to your commits."
echo -n "Please enter your name: "
require 'rubygems'
require 'json'
require 'redis'
class RedisComments
def initialize(redis,namespace,sort_proc=nil)
@r = redis
@namespace = namespace
@sort_proc = sort_proc
end
@gciampa
gciampa / index.html
Created February 17, 2011 04:20
jQuery Toggle Menu
<html>
<head>
<style type="text/css">
.nested {
display: none;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
user app;
worker_processes 2;
error_log /home/app/logs/nginx.error.log info;
events {
worker_connections 1024;
}
require 'sequel'
# Database
#
# A helper class to wrap calls to Sequel Database, primarily for getting a database from a YAML config
# file and for migrating.
class Database
@@configuration_file = File.join( File.dirname(__FILE__), "../config/database.yml" )
raise Exception.new("No '#{@@configuration_file}' file was found. ") if @@configuration_file.nil?
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
get '/hello/:name' do |name|
"#{params.inspect}"
end
jQuery.slowEach = function(array, interval, callback) {
if(!array.length) return;
var i = 0;
next();
function next() {
if(callback.call(array[i], i, array[i]) !== false)
if(++i < array.length)
setTimeout(next, interval);
}
##formtastic_datepicker_interface
module Formtastic
module DatePicker
protected
def datepicker_input(method, options = {})
format = options[:format] || ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS[:default] || '%d %b %Y'
string_input(method, datepicker_options(format, object.send(method)).merge(options))
end