Skip to content

Instantly share code, notes, and snippets.

View carols10cents's full-sized avatar

Carol (Nichols || Goulding) carols10cents

View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
@brobertsaz
brobertsaz / serversetup.md
Last active July 6, 2020 08:56
Ubuntu 12.04 Ruby, Rails, Nginx, Unicorn

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key
@nyinyithann
nyinyithann / semi_monad_function_of_result_type.rs
Last active February 8, 2019 18:45
composition of functions of Result<T,E>
use std::io;
use std::io::prelude::*;
fn main() {
loop {
let r = get_input("Enter the first number: ")
.and_then(|x| get_input("Enter the second number: ")
.and_then(|y| get_input("Enter the third number: ")
.and_then(|z| Ok(x + y + z))));
@wycats
wycats / errors.md
Last active October 21, 2018 12:04
How I think about error handling in Rust
  • Option: "None is a totally valid result, usually found in data structures"
    • unwrap(): YOLO use in prototyping
    • expect(...): to indicate the reason you believe None is impossible (or a contract violation for the method)
  • Result: 😱 "Errors are unexpected but not bugs; the decision for how to handle them is up to the caller"
    • unwrap(): YOLO "I'm an app and don't know how to handle this error -- I'm fine if the whole process aborts"
    • try! / ?: "Leave the decision about how to handle this error to the caller; they have more information"
    • match / catch: "I'm going to handle the error right here right now"
  • panic!: ☠ "The error is a bug and can't be recovered from. Game over man. Rust is allowed to abort the process if it wants"
@xaviershay
xaviershay / rewrite.rb
Created January 10, 2013 06:11
Proof-of-concept squid proxy settings for proxying http://rubygems.org/ Tested on one project on my local machine both cold, and warm with internet turned off.
#!/usr/bin/env ruby
# url rewriter for rubygems squid proxy
STDOUT.sync = true
while line = gets
url = line.split(' ')[0]
# Cargo-culted this conditional, not sure if it is necessary
response = if url
anonymous
anonymous / playground.rs
Created December 31, 2016 22:15
Rust code shared from the playground
use std::collections::BTreeMap;
// Why we might want multiple lifetimes...
// We want this structure to be trivially copyable as we pass it
// around and modify the position.
#[derive(Copy, Clone)]
struct Cache<'d, 's: 'd> {
data: &'d BTreeMap<usize, &'s str>,
position: usize,
enum Meal {
TvDinner,
HomeCooked { healthy: bool },
}
let lunch = Meal::TvDinner;
let dinner = Meal::HomeCooked { healthy: true };
match lunch {
Meal::TvDinner => println!("Eating a TV dinner"),
anonymous
anonymous / playground.rs
Created March 17, 2016 00:07
Shared via Rust Playground
// The error is that there's an unused generic G declared...
fn foo<G>() -> String {
String::from("hi")
}
fn main() {
println!("{}", foo());
// ^ but here is where the error message points to:
// error: unable to infer enough type information about `_`; type annotations or generic parameter binding required [E0282]
@hadees
hadees / gist:7308571
Last active December 27, 2015 10:09 — forked from ericboehs/gist:7125105
Poltergeist hack to silence CoreText performance notes from phantomjs that works with billy.
module Capybara::Poltergeist
class Client
private
def redirect_stdout
prev = STDOUT.dup
prev.autoclose = false
$stdout = @write_io
STDOUT.reopen(@write_io)
prev = STDERR.dup