Skip to content

Instantly share code, notes, and snippets.

I've got an array of file names, with their relative file sizes. I want to break them down into X - size fragments, each
fragment representing the byte offset within that file (and also recognize that some of these fragments may point to two or more files) as the fragmentation of the files is measured sequentially. I'm trying to do this neatly, but I think there's something big that I am missing.
any ideas?
module Fech
class Utilities
# usage examples:
# Fech::Utilities.retrieve_table(:candidate, 2012, :type => :summary, :mode => :to_csv) #=> renders a CSV file; returns nil
# Fech::Utilities.retrieve_table(:committee_contribution, 2010, :mode => :to_db, :db => <db location>, :db_table => Sequel.table)
def self.retrieve_table(table, cycle, opts={})
table = table.to_s.split("_").map { |t| t.capitalize }.join
table = begin
Fech.const_get("Fech::#{table}")
class Node
attr_accessor :data, :nxt, :prev
def initialize(data=nil, prev=nil)
@data = data
@prev = prev
@nxt = nil
end
def add(val)
if @nxt.nil?
var LoadStream = React.createClass({
getInitialState: function() {
return {tweets: []}
},
grabTweets: function() {
$.getJSON("/gamergate/tweets", function(data){
if (this.isMounted()) {
this.setState(data)
}
var Timeline = React.createClass({
// timeline component starts with no initial tweets/active tweet
getInitialState: function() {
return { tweets: [], activeTweet: {} };
},
// if called initially, loadTweets makes an Ajax call to the server for 20 tweets using the default
// hashtag "#gamergate" as the primary search parameter for the twitter client
// otherwise, the function gets called whenever the current number of tweets dips below 20 after removing a tweet
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
class LittleBits
def query_tags
@doc = Nokogiri::HTML(open("http://littlebits.cc"))
binding.pry
count = doc.search("//script").length
print "#{count} of <script/> tags on littlebits.cc homepage."
require 'sinatra'
require 'twitter'
require 'oauth'
require 'yaml'
require 'sequel'
module ShieldsUp
# hold the config keys and the DB info here.
CONFIG = YAML.load_file('config.yaml')
DB = Sequel.mysql(
use std::fs;
use std::ffi::OsStr;
use std::path::{self, Path, PathBuf};
// fn get_expansion(file: &PathBuf) {
//
// }
struct Card {
name: String,
fn sort_vec(nums: &Vec<i32>) -> Vec<i32> {
let mut numbers = nums.clone();
let mut greater_than = vec![];
let mut less_than = vec![];
if numbers.len() < 2 {
return numbers
}
let pivot = get_piv(numbers.pop());
@wismer
wismer / index.html
Last active August 29, 2015 14:28 — forked from anonymous/index.html
JS Bin // source http://jsbin.com/pusunibiru
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var thing = 'fun';