Skip to content

Instantly share code, notes, and snippets.

String body = JOptionPane.showInputDialog("Message?");
msg = (body);
System.out.println(msg);
outputStream.println(msg);
//outputStream.flush();
// System.out.println(inputStream.readLine());
!!! Strict
%html{html_attrs}
%head
%title
= h(yield(:title) || "Untitled")
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
= stylesheet_link_tag 'application'
= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js", "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js", "application", :cache => true
/[if IE]
class Ability
include CanCan::Ability
# alias_action :index, :show, :to => :read
# alias_action :new, :to => :create
# alias_action :edit, :to => :update
def initialize(user)
if user.role? :admin
can :manage, :all
# @settings and anything in it could be nil or blank at any time
def get_backlog_issues(exclude_ids=[])
return [[]] unless @settings.present? &&
@settings['panes'].present? &&
@settings['panes']['backlog'].present? &&
@settings['panes']['backlog']['status'].present? &&
@settings['panes']['backlog']['status'].present?
# ...
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(document).ready(function() {
$("#comment_form").submit(function() {
$.post($(this).attr("action"), $(this).serialize(), null, "script");
return false;
})
})
// views/reviews/create.js.erb
$("#new_review").before('<div id="flash_notice"><%= escape_javascript(flash.delete(:notice)) %></div>');
$("#reviews_count").html("<%= pluralize(@review.product.reviews.count, 'Review') %>");
$("#reviews").append("<%= escape_javascript(render(:partial => @review)) %>");
$("#new_review")[0].reset();
@implementation Game
@synthesize st;
- (id)initWithWidth:(float)width height:(float)height {
if (self = [super initWithWidth:width height:height]) {
// this is where the code of your game will start.
// in this sample, we add just a simple quad to see if it works.
st = [[SPSprite alloc] init];
st.rotation = SP_D2R(90);
st.x = 320;
@seivan
seivan / readysetfight.markdown
Created July 3, 2011 10:50 — forked from jeffkreeftmeijer/readysetfight.markdown
Finding something like `if ( ready? && set? ) { fight! };` in Ruby

Right now, the tagline-code-snippet thing on Codebrawl is if ( ready? && set? ) { fight! };. While this looks nice, this is not valid Ruby code.

So, I'm looking for something better. It should be Ruby, and it should look cool. If you have an idea, please fork the Gist and add it to the list below. Thanks! :)

ready? && set? && fight! 
if ( ready? && set? ) then fight! end
( ready? && set? ) ? fight! : nil

ready! #(raise if not ready)

@seivan
seivan / 1 Readme.md
Created December 2, 2012 12:11 — forked from toolmantim/1 Readme.md
Minification with newlines using the Rails 3 asset pipeline

Retaining line numbers with the Rails asset pipeline

By default the Rails 3 asset pipeline uses the Uglifier gem to optimize and minify your Javascript. One of its many optimisations is to remove all whitespace, turning your Javascript into one very long line of code.

Whist removing all the newlines helps to reduce the file size, it has the disadvantage of making your Javascript harder to debug. If you've tried to track down Javascript errors in minified Javascript files you'll know the lack of whitespace does make life harder.

Luckily there is a simple solution: to configure Uglifier to add newlines back into the code after it performs its optimisations. And if you're serving your files correctly gzip'd, the newlines add only a small increase to the final file size.

You can configure Uglifier to add the newlines by setting the following in your Rails 3 config/production.rb file:

@seivan
seivan / invalidate-cf-path.rb
Created December 3, 2012 03:05 — forked from rbm/invalidate-cf-path.rb
Invalidate CloudFront path using fog
#!/usr/bin/env ruby -w
require 'rubygems'
require 'fog'
require 'pp'
AWS_ACCESS_KEY = ENV['AWS_ACCESS_KEY_ID']
AWS_SECRET_KEY = ENV['AWS_SECRET_ACCESS_KEY']
def get_cf_connection()