Skip to content

Instantly share code, notes, and snippets.

#include <sys/stat.h>
#include "otp.h"
#define WORD_LENGTH 32
#define BLOCK_SIZE 1024
// int fseek ( FILE * stream, long int offset, int origin );
// size_t fread ( void * ptr, size_t size, size_t count, FILE * stream );
// unsigned char *SHA256 ( const unsigned char *d, size_t n, unsigned char *md );
@dce
dce / fold.rkt
Last active December 11, 2015 20:29
Better implementation of `fold`.
(define fold
(lambda (l result fun)
(cond
((null? l) result)
(else
(fold (cdr l) (fun result (car l)) fun)))))
(define fold
(lambda (l init fun)
(cond

Why Not SSL Everywhere?

  • Cost
  • Setup
  • Performance impact
  • Mixed-content warnings
  • Third-party content (ads, analytics)
  • User-embedded content
  • CDNs (CNAMEs)
@dce
dce / encode.c
Created September 24, 2012 19:04
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int index_of(char* needle, char* haystack[], int length) {
int i;
for (i = 0; i < length; i++) {
if (strcmp(haystack[i], needle) == 0) {
return i;
@dce
dce / encode.md
Created September 20, 2012 18:38

encode.c

Simple exercise for learning C:

  • Reads text from STDIN
  • By default, rotates all text by one character ("abc" => "bcd")
  • Prints to STDOUT
  • If the "-n [number]" flag is supplied, rotate by that many characters
  • If the "-d" (decode) flag is supplied, rotate in the opposite direction
  • If the "-f [filename]" flag is supplied, read from that file rather than STDIN
PATH
remote: .
specs:
paperclip-meta (0.4.2)
paperclip
GEM
remote: http://rubygems.org/
specs:
activemodel (3.2.3)
/Users/dce/.rvm/rubies/ruby-1.9.3-p0/bin/ruby -S rspec ./spec/paperclip-meta/paperclip-meta_spec.rb
/Users/dce/.rvm/gems/ruby-1.9.3-p0@paperclip-meta/gems/paperclip-3.0.2/lib/paperclip/validators/attachment_content_type_validator.rb:3:in `<module:Validators>': uninitialized constant Paperclip::Validators::ActiveModel (NameError)
from /Users/dce/.rvm/gems/ruby-1.9.3-p0@paperclip-meta/gems/paperclip-3.0.2/lib/paperclip/validators/attachment_content_type_validator.rb:2:in `<module:Paperclip>'
from /Users/dce/.rvm/gems/ruby-1.9.3-p0@paperclip-meta/gems/paperclip-3.0.2/lib/paperclip/validators/attachment_content_type_validator.rb:1:in `<top (required)>'
from /Users/dce/.rvm/gems/ruby-1.9.3-p0@paperclip-meta/gems/paperclip-3.0.2/lib/paperclip/validators.rb:2:in `require'
from /Users/dce/.rvm/gems/ruby-1.9.3-p0@paperclip-meta/gems/paperclip-3.0.2/lib/paperclip/validators.rb:2:in `<top (required)>'
from /Users/dce/.rvm/gems/ruby-1.9.3-p0@paperclip-meta/gems/paperclip-3.0.2/lib/paperclip.rb:45:in `require'
from
#!/usr/bin/env ruby
files = `grep -lir :focus spec`.split(/\n/) - ["spec/spec_helper.rb"]
if files.any?
puts "FOCUS: #{files.inspect}"
exit 1
end
<% list_items_for @products do |product| %>
<%= link_to product.name, product %>
<% end %>
<!--
<li class="first"><a href="/products/1">Product #1</a></li>
<li><a href="/products/2">Product #2</a></li>
<li class="last"><a href="/products/3">Product #3</a></li>
-->

Rails 3.1 Asset Pipeline

  • The new asset pipeline in Rails 3.1 makes assets first class citizens in Rails
  • Assets now in app/assets rather than public (also lib/assets, vendor/assets)
  • Asset files can inline other asset files using requires
  • Asset packages are defined in manifests
/*