Skip to content

Instantly share code, notes, and snippets.

// This started out as an exploration on decoding Rails session cookies in Rust.
// After reaching the "it works" stage I found:
//
// https://github.com/mikeycgto/message_verifier/ by @mikeycgto
// and you should really use that as its a much more elegant solution
// and also implements verifying the message as well as decrypting it
// which would be critical in actual use.
//
// https://gist.github.com/profh/e36e5dd0bec124fef04c
// https://gist.github.com/JoshCheek/7b1c1eb231dfa83098be
# May 2017 Google SERP (Search Engine Result Page) extraction tool
# Written and tested with Ruby 2.4 but likely works with any Ruby 2.0 or above
#
# Usage:
#
# Customize these settings to your liking:
# user_agent: the browser user_agent string to be sent with each request
# total_pages: total number of pages requested (10 results per page)
# query: the search query to run
#
fn main() {
fn output<F: Fn(String)>(text: &str, strategy: F) {
let string = String::from(text);
strategy(string)
}
// define strategies as closures
let bold = |s| println!("<strong>{}</strong>", s);
let italics = |s| println!("<em>{}</em>", s);
require 'minitest/autorun'
class Strtime
def initialize(seconds)
@seconds = seconds
end
def to_s
raise ArgumentError if @seconds.to_i < 0
use std::io::*;
fn main() {
loop{
let mut l = String::new();
let mut a = 0;
print!(">> ");
stdout().flush().unwrap();
stdin().read_line(&mut l).unwrap();
@mclosson
mclosson / puma.service
Created March 10, 2018 21:43 — forked from arteezy/puma.service
Manage Puma with systemd on Ubuntu 16.04 and rbenv
[Unit]
Description=Puma Rails Server
After=network.target
[Service]
Type=simple
User=deploy
WorkingDirectory=/home/deploy/app/current
ExecStart=/home/deploy/.rbenv/bin/rbenv exec bundle exec puma -C /home/deploy/app/shared/config/puma.rb
ExecStop=/home/deploy/.rbenv/bin/rbenv exec bundle exec pumactl -S /home/deploy/app/shared/tmp/pids/puma.state stop