$url = 'http://some.url/file.txt';
$data = download($url, $headers, $err_msg);
if( !$data ) {
echo $err_msg;
die;
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
concern :ComposedModel do | |
include ActiveModel::Model | |
def valid? | |
objects.all?(&:valid?) && super | |
end | |
def save! | |
raise ActiveRecord::RecordInvalid, self unless valid? | |
transaction { objects.each &:save! } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PouchDB from 'pouchdb-browser' | |
import MemoryAdapterPlugin from 'pouchdb-adapter-memory' | |
PouchDB.plugin(MemoryAdapterPlugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MultiDef | |
def defs *names, &blk | |
names.each { |name| define_method name, blk } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder