This file contains hidden or 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
<?php | |
$handle = opendir('_cache/'); | |
while (false !== ($entry = readdir($handle))) { | |
if (strlen($entry) > 2){ | |
$a = explode(".", $entry); | |
$a = explode("_", $a[0]); | |
$tstamp = intval($a[1]); | |
$t = time(); | |
if ($t > ($tstamp + 12)){ | |
// do the call, rewrite the timestamp |
This file contains hidden or 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
// named media queries - http://blog.scur.pl/2012/06/variable-media-queries-less-css/ | |
@highdensity: ~"only screen and (-webkit-min-device-pixel-ratio: 1.5)", | |
~"only screen and (min--moz-device-pixel-ratio: 1.5)", | |
~"only screen and (-o-min-device-pixel-ratio: 3/2)", | |
~"only screen and (min-device-pixel-ratio: 1.5)"; | |
@600: ~"only screen and (min-width: 600px)"; | |
@800: ~"only screen and (min-width: 800px)"; | |
@1000: ~"only screen and (min-width: 1000px)"; | |
@1200: ~"only screen and (min-width: 1200px)"; |
This file contains hidden or 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
User.joins(:assignments).where.not("(assignments.startdatetime > ? AND assignments.startdatetime < ?) OR (assignments.enddatetime < ? AND assignments.enddatetime > ?)", startdatetime, enddatetime, startdatetime, enddatetime) | |
# This would be fine, except it does not include users who do not have assignments at all. |
This file contains hidden or 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
<!-- Classdate form --> | |
<% if (params[:classdate] and params[:classdate][:course_id]) or @classdate.id %> | |
<%= nested_form_for(@classdate) do |f| %> | |
<% if @classdate.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@classdate.errors.count, "error") %> prohibited this classdate from being saved:</h2> | |
<ul> | |
<% @classdate.errors.full_messages.each do |msg| %> |
This file contains hidden or 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 ClassRegistrationsController < InheritedResources::Base | |
before_filter :authenticate_user! | |
def permitted_params | |
params.permit(:class_registration => [ | |
:person_id, :classdate_id, | |
:document_assignments_attributes => [ | |
:uploaded_document_id, | |
:uploaded_document => [ | |
:document, :owner_type, :owner_id |
This file contains hidden or 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
// Examples for using socat (and filan) | |
//"$" means normal user, "#" requires privileges, "//" starts a comment | |
/////////////////////////////////////////////////////////////////////////////// | |
// similar to netcat | |
// connect to 10.1.1.1 on port 80 and relay to and from stdio |
This file contains hidden or 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 StripeTransaction < ActiveRecord::Base | |
has_many :line_items | |
accepts_nested_attributes_for :line_items | |
belongs_to :user | |
belongs_to :stripe_card | |
end |
This file contains hidden or 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
- (NSData *)getDataPartAtOffset:(NSInteger)offset { | |
__block NSData *chunkData = nil; | |
if (fileAsset_){ | |
static const NSUInteger BufferSize = PART_SIZE; // 5 MB chunk | |
ALAssetRepresentation *rep = [fileAsset_ defaultRepresentation]; | |
uint8_t *buffer = calloc(BufferSize, sizeof(*buffer)); | |
NSUInteger bytesRead = 0; | |
NSError *error = nil; | |
@try |
This file contains hidden or 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
def assets_library | |
@_assets_library ||= ALAssetsLibrary.alloc.init | |
end | |
@foo.clips.each_with_index do |clip,i| | |
# clip[1][:reference_url] refers to a video file chosen via BW::Device.camera.any.picture(media_types: [:movie]) do |result| | |
asset_url = clip[1][:reference_url] | |
assets_library.assetForURL(asset_url, resultBlock: lambda { |asset| | |
selectedAsset = asset | |
byteArraySize = selectedAsset.defaultRepresentation.size |
This file contains hidden or 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
@clip_object.clips.each_with_index do |clip, i| | |
# puts clip[:video][:media_url] | |
gcdq = Dispatch::Queue.concurrent(:high) | |
gcdq.async { | |
# por = S3PutObjectRequest.alloc.initWithKey(clip[:aws_path], inBucket:"southtree_dvds") | |
# por.contentType = "video/mp4" | |
# por.filename = clip[:video][:media_url].to_s | |
asset_url = clip[:video][:reference_url] | |
assets_library.assetForURL(asset_url, resultBlock: lambda { |asset| | |
# clip[:raw_data] = rawData |