Skip to content

Instantly share code, notes, and snippets.

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
<%= form_tag registration_index_path do %>
<%= fields_for User.new do |u| %>
<%= u.label :phone %>
<%= u.text_field :phone %>
<% end %>
<p>
<%= label_tag :workout %>
<%= check_box_tag :workout %>
</p>
<p>
@danneu
danneu / home
Created February 21, 2012 01:02 — forked from anonymous/home
home
<% @posts.each do |post|%>
<div id="recentpost">
<%= post.name %><br/><br/>
</div>
<% end %>
@danneu
danneu / ios.c
Created August 17, 2012 05:16 — forked from mahemoff/ios.c
iOS example
// Async web fetch with JSON parse
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"url"]]
queue:nil completionHandler:^(NSURLResponse *r, NSData *d, NSError *e) {
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:d
options:0
error:nil];
}];
// Using the camera
@danneu
danneu / passwords_controller.rb
Created October 23, 2012 05:26 — forked from kazpsp/passwords_controller.rb
StrongParameters with Devise
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
@danneu
danneu / gist:4049606
Created November 10, 2012 02:33 — forked from JFickel/gist:4049601
Procfile
# Procfile
web: bundle exec rails server -p $PORT
faye: bundle exec thin -p 8081 -R faye_config.ru start
# config/routes.rb
namespace :api, defaults: {format: "json"} do
namespace :v1 do
resources :wines
end
end
# wines_controller
class WinesController
def index
@danneu
danneu / 0_reuse_code.js
Created November 8, 2015 00:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@danneu
danneu / gulpfile.js
Created November 11, 2015 03:18 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially