Skip to content

Instantly share code, notes, and snippets.

View ossl.patch
--- ext/openssl/ossl_pkey_ec.c 2010-06-21 04:18:59.000000000 -0500
+++ ext/openssl/ossl_pkey_ec.c 2013-12-10 13:30:18.919963527 -0600
@@ -757,8 +757,10 @@
method = EC_GFp_mont_method();
} else if (id == s_GFp_nist) {
method = EC_GFp_nist_method();
+ #if !defined(OPENSSL_NO_EC2M)
} else if (id == s_GF2m_simple) {
method = EC_GF2m_simple_method();
+ #endif
@eric1234
eric1234 / widgets_controller.rb
Last active Jun 1, 2018
Lettable-based Controller Example
View widgets_controller.rb
class WidgetsController < ApplicationController
let(:widgets) { Widget.all }
let(:widget) { widgets.find_or_initialize_by id: params[:id] }
def new
render :form
end
def edit
render :form
View keybase.md

Keybase proof

I hereby claim:

  • I am eric1234 on github.
  • I am ericanderson (https://keybase.io/ericanderson) on keybase.
  • I have a public key ASAzwRnO3uw3H6ISre5d7qPiagNyP3Txxa85qdoCl4lk1Ao

To claim this, I am signing this object:

@eric1234
eric1234 / README.md
Last active Oct 19, 2016
Simple download function for PHP
View README.md

Usage

$url = 'http://some.url/file.txt';
$data = download($url, $headers, $err_msg);
if( !$data ) {
  echo $err_msg;
  die;
}
@eric1234
eric1234 / widgets_controller.rb
Created Oct 4, 2016
Stock Scaffold Rails Controller
View widgets_controller.rb
class WidgetsController < ApplicationController
before_action :set_widget, only: [:show, :edit, :update, :destroy]
# GET /widgets
def index
@widgets = Widget.all
end
# GET /widgets/1
def show
@eric1234
eric1234 / multidef.rb
Created Oct 4, 2016
Define multiple methods with the same defination
View multidef.rb
module MultiDef
def defs *names, &blk
names.each { |name| define_method name, blk }
end
end
@eric1234
eric1234 / lettable.rb
Last active Nov 27, 2018
Easy Sharing of Data Loading in Rails Controllers
View lettable.rb
module Lettable
def let name, &blk
iv = "@#{name}"
define_method name do
return instance_variable_get iv if instance_variable_defined? iv
instance_variable_set iv, instance_eval(&blk)
end
helper_method name
@eric1234
eric1234 / agents_controller.rb
Last active Mar 21, 2017
Example Real Controller
View agents_controller.rb
class Admin::AgentsController < AdminController
include ListParams
include StatusFilter
helper :filter
let(:agents) { policy_scope authorize Agent.all }
let(:agent) { authorize agents.with_stats.find_or_build params[:id] }
def index
@eric1234
eric1234 / me.json
Created Aug 15, 2016
Me in JSON format
View me.json
{
"name": {
"first": "Eric",
"last": "Anderson"
},
"title": ["Owner", "Programmer"],
"email": "eric@pixelwareinc.com",
"phone": "404-290-8411",
"company": {
"name": "Pixelware, LLC",
@eric1234
eric1234 / README.md
Last active Jul 5, 2016
Experiment in a Localized Extension
View README.md

Sometimes I want to extend a core object to keep things object oriented but I want to limit the scope of my extension. Refinements provide a nice solution to that but for a single method extension I find it a bit bulky. Here is some standard syntax:

class SomeObject

  module Extension
    refine Array do
      def average