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.
$ python -m SimpleHTTPServer 8000
#!/bin/bash | |
# | |
# ruby_install.sh | |
# A simple Bash script for building up my Ruby development environment on a clean system. | |
# The configuration used is the one that I like. | |
# - Base system Ruby = version 1.9.2 | |
# - Ruby installed from source | |
# - Installation of RVM + Rubies | |
# - Configuration of gemset for local instance of Passenger |
# parses out the current branch you're on. See: http://www.harukizaemon.com/2008/05/deploying-branches-with-capistrano.html | |
current_branch = `git branch`.match(/\* (\S+)\s/m)[1] | |
# use the branch specified as a param, then use the current branch. If all fails use master branch | |
set :branch, ENV['branch'] || current_branch || "master" # you can use the 'branch' parameter on deployment to specify the branch you wish to deploy |
In some cases you need to set the default_url of paper clip base on some condition. e.g. You want to set default image on basis of gender of user. For this purpose this gist can make it possible to use a method as default_url. Just copy paper_clip_default_url_fix.rb to initializers folder, and use default_url as mentioned in model.rb |
# coding: utf-8 | |
require 'sinatra' | |
set server: 'thin', connections: [] | |
get '/' do | |
halt erb(:login) unless params[:user] | |
erb :chat, locals: { user: params[:user].gsub(/\W/, '') } | |
end | |
get '/stream', provides: 'text/event-stream' do |
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.
$ python -m SimpleHTTPServer 8000
-- | |
-- Name: c_posts_voted(); Type: FUNCTION; Schema: public; Owner: - | |
-- | |
CREATE FUNCTION c_posts_voted() RETURNS trigger | |
LANGUAGE plpgsql | |
AS $$ BEGIN | |
UPDATE "posts" SET voted_user_ids = array_append(voted_user_ids, NEW.user_id) WHERE "id" = NEW.post_id; | |
RETURN NEW; | |
END; |
People
:bowtie: |
😄 :smile: |
😆 :laughing: |
---|---|---|
😊 :blush: |
😃 :smiley: |
:relaxed: |
😏 :smirk: |
😍 :heart_eyes: |
😘 :kissing_heart: |
😚 :kissing_closed_eyes: |
😳 :flushed: |
😌 :relieved: |
😆 :satisfied: |
😁 :grin: |
😉 :wink: |
😜 :stuck_out_tongue_winking_eye: |
😝 :stuck_out_tongue_closed_eyes: |
😀 :grinning: |
😗 :kissing: |
😙 :kissing_smiling_eyes: |
😛 :stuck_out_tongue: |
# Routing Concerns is an attempt to DRY up your config/routes.rb. | |
# The basic idea is to define common sub-resources (like comments) | |
# as concerns and include them in other resources/routes. | |
# Here’s the obvious example: | |
concern :commentable do | |
resources :comments | |
end | |
concern :remarkable do |
# encoding: UTF-8 | |
# Place in config/deploy.rb | |
# See: https://gist.github.com/joost/9343156 | |
# Adapted to work with rbenv | |
namespace :rails do | |
desc "Open the rails console on primary app server" | |
task :console do | |
on roles(:app), primary: true do | |
rails_env = fetch(:stage) | |
execute_interactively "#{bundle_cmd} #{current_path}/script/rails console #{rails_env}" |
namespace :deploy do | |
task :upload do | |
files = (ENV["FILES"] || "").split(",").map { |f| Dir[f.strip] }.flatten | |
abort "Please specify at least one file or directory to update (via the FILES environment variable)" if files.empty? | |
on release_roles :all do | |
files.each { |file| upload!(file, File.join(current_path, file)) } | |
end | |
end | |
end |