Skip to content

Instantly share code, notes, and snippets.

<%# @post.content = '<script>javascript:alert("Injection huhui")</script>' %>
<div>
<%= @post.content %>
</div>
<%# Would render to: %>
<div>
&lt;script&gt;javascript:alert("Injection huhui")&lt;/script&gt;
</div>
@stestaub
stestaub / ruby_examples.rb
Last active February 23, 2017 09:19
Some insights into the ruby language
# every thing is an object:
20.methods
#=> [:to_s, :inspect, :-@, :+, :-, :*, :/, :div, :%, :modulo, :divmod, :fdiv, :**, :abs, :magnitude, :==, :===, :<=>, :>, :>=, :<, :<=, :~, :&, :|, :^, :[], :<<, :>>, :to_f, :size, :bit_length, :zero?, :odd?, :even?, :succ, :integer?, :upto, :downto, :times, :next, :pred, :chr, :ord, :to_i, :to_int, :floor, :ceil, :truncate, :round, :gcd, :lcm, :gcdlcm, :numerator, :denominator, :to_r, :rationalize, :singleton_method_added, :coerce, :i, :+@, :eql?, :remainder, :real?, :nonzero?, :step, :quo, :to_c, :real, :imaginary, :imag, :abs2, :arg, :angle, :phase, :rectangular, :rect, :polar, :conjugate, :conj, :between?, :psych_to_yaml, :to_yaml, :to_yaml_properties, :find_method, :_ori_method, :ri, :system, :spawn, :howtocall, :vi, :vim, :emacs, :nano, :mate, :mvim, :ed, :methods_for, :method_lookup_path, :only_class_ancestors, :mlp, :nil?, :=~, :!~, :hash, :class, :singleton_class, :clone, :dup, :itself, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen
@stestaub
stestaub / routes-helpers.rb
Last active January 4, 2017 09:47
helper file for routes to check if a rake task like assets:precompile or db:migrate is running
module RoutesHelpers
# Checks if the call is not a migration task or an other rake task that would fail when trying to
# access some database tables.
#
# This can be used in the routes.rb file
#
# require 'routes_helpers'
# include RoutesHelpers
# Rails.application.routes.draw do
@stestaub
stestaub / timeline.css
Created November 2, 2015 13:54
New Css
body {
background-color: #efefef;
padding: 0px;
margin: 0px;
}
div.image-files > ul > li.media-item {
height: 100px;
width: 100px;
border: 3px solid #cfcfcf;
@stestaub
stestaub / schema_format.rake
Created July 31, 2013 01:27
Add this to lib/tasks to all rake tasks working again with schema_format :sql and postgis database adapter
#some hacks to get postgis adapter to work with schema_type sql
require 'rgeo/active_record/task_hacker'
::RGeo::ActiveRecord::TaskHacker.modify('db:structure:dump', nil, 'postgis') do |config_|
set_psql_env(config_)
filename_ = ::File.join(::Rails.root, "db/#{::Rails.env}_structure.sql")
search_path_ = config_["schema_search_path"].to_s.strip
search_path_ = search_path_.split(",").map{ |sp_| sp_.strip }
search_path_.delete('postgis')
@stestaub
stestaub / gist:5525998
Last active December 17, 2015 01:09
Test Async Methods in C#
[Test()]
public void LoadChallengesByFilter ()
{
ManualResetEvent syncEvent = new ManualResetEvent(false);
string[] filter = {"fun"};
RequestResult<IEnumerable<Challenge>> result = null;
testee.GetChallengesByFilterAsync((_result) => {
result = _result;