Skip to content

Instantly share code, notes, and snippets.

Charlie Somerville charliesome

Block or report user

Report or block charliesome

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mstate.hs
import Control.Monad
import Data.Monoid
data MState s a = MState s a
instance Monoid s => Functor (MState s) where
fmap f (MState st x) = MState st (f x)
instance Monoid s => Applicative (MState s) where
pure = return
View update-smart-playlists.rb
require "nokogiri"
require "pry"
doc = Nokogiri::XML(File.read("collection.nml"))
def update_playlist(doc, playlist_name, xpath)
playlist = doc.xpath("/NML/PLAYLISTS//NODE[@TYPE='PLAYLIST'][@NAME='#{playlist_name}']/PLAYLIST").first
playlist.children.remove
View mruby-rce.rb
# This is a proof of concept exploit for a Struct type confusion vulnerability
# in mruby.
#
# This exploit works as of commit 88604e39ac9c25ffdad2e3f03be26516fe866038.
#
# All file and line references in the annotations below are relative to that
# commit.
#
# - Charlie Somerville, 2016-11-13
#
View query.js
function query<T>(selector: string, klass: Class<T>): T {
let element = document.querySelector(selector);
if (!(element instanceof klass)) {
throw new TypeError("expected " + selector + " to select element of type " + (klass : Function).name);
}
return element;
}
View traktor-playlist-maintenance.rb
require "nokogiri"
require "pry"
doc = Nokogiri::XML(File.read("collection.nml"))
def update_playlist(doc, playlist_name, xpath)
playlist = doc.xpath("/NML/PLAYLISTS//NODE[@TYPE='PLAYLIST'][@NAME='#{playlist_name}']/PLAYLIST").first
playlist.children.remove
View sqpi.c
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
struct worker_ctx {
pthread_t thr;
size_t n;
size_t stride;
size_t offset;
View lol.rb
gem "activerecord", "4.2.4"
require "active_record"
ActiveRecord::Base.logger = Logger.new($stdout)
ActiveRecord::Base.establish_connection :adapter => "mysql2", :database => "test"
# ---------------------------------------------------------------------
ActiveRecord::Base.connection.transaction do
View filesearch.rb
#!/opt/rubies/ruby-2.1.2/bin/ruby
require "cgi"
$cgi = CGI.new
puts "Content-Type: text/html"
puts
if q = $cgi.params["q"].first
puts "<pre>"
View gist:532bd15c1195aa7a9ebf
gem "rails", "3.2.21"
require "rails/all"
class MyApp < Rails::Application
end
def path_for(opts)
MyApp.routes.url_helpers.url_for(only_path: true, **opts)
rescue => e
e
View gist:13901d5e92cd4502c2ab
func Reverse<T>(slice []T) {
for i := 0; i < len(slice) / 2; i++ {
j := len(slice) - i - 1
x := slice[j]
slice[j] = slice[i]
slice[i] = x
}
}
You can’t perform that action at this time.