Skip to content

Instantly share code, notes, and snippets.


Matthew Closson mclosson

View GitHub Profile
mclosson / puma.service
Created Mar 10, 2018 — forked from arteezy/puma.service
Manage Puma with systemd on Ubuntu 16.04 and rbenv
View puma.service
Description=Puma Rails Server
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
use std::io::*;
fn main() {
let mut l = String::new();
let mut a = 0;
print!(">> ");
stdin().read_line(&mut l).unwrap();
View strtime.rb
require 'minitest/autorun'
class Strtime
def initialize(seconds)
@seconds = seconds
def to_s
raise ArgumentError if @seconds.to_i < 0
fn main() {
fn output<F: Fn(String)>(text: &str, strategy: F) {
let string = String::from(text);
// define strategies as closures
let bold = |s| println!("<strong>{}</strong>", s);
let italics = |s| println!("<em>{}</em>", s);
View serpslurp.rb
# 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
// This started out as an exploration on decoding Rails session cookies in Rust.
// After reaching the "it works" stage I found:
// 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.
extern crate hyper;
extern crate time;
use hyper::Url;
use hyper::client::*;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::sync::{Arc, Mutex};
use std::thread;
View encapsulate_and_override_demo.cs
/* Problem */
class Thing {
// testing this will result in expensive calls to event logs and database
public int dostuff() {
int result = something();
EventLogsAndDatabaseLogger.log(1, 2, 3, 4, 5, "message");
return result;
View cities.txt
Cape South Mobile Home Park
West Melbourne
Mintons Corner
June Park
Melbourne Village
Quail Run Mobile Home Estates
The Lakes of Melbourne Mobile Home Park
Lakes of Melbourne Mobile Home Park
Melbourne Gardens
Trailer Haven Mobile Home Park
View setup.c
/* The following program is an example of a setup program which generates a
* secret key and writes it to a file which is only readably by the owner of
* the file.
* In this example the program should be made owned by root and the wheel group
* and the suid (set user ID) permission should be set so that when a regular
* user runs the program, the secrets.txt file will be created and owned by the
* root user.
* Your goal is to try to find a way without modifying the code of the program
You can’t perform that action at this time.