Skip to content

Instantly share code, notes, and snippets.

View pseudomuto's full-sized avatar
📈
☁️ things

David Muto pseudomuto

📈
☁️ things
View GitHub Profile
@pseudomuto
pseudomuto / main_1.go
Last active October 12, 2024 14:49
Blog Code: Clean SQL Transactions in Golang
package main
import (
"database/sql"
"log"
)
func main() {
db, err := sql.Open("VENDOR_HERE", "YOUR_DSN_HERE")
handleError(err)
@pseudomuto
pseudomuto / rust-pre-push.sh
Created January 3, 2017 13:57
Linting Pre-Push Hooks
#!/bin/bash
set -euo pipefail
######################################################################
# Auto-formats code with RustFmt
# https://github.com/rust-lang-nursery/rustfmt
#
# After running, there will either be changes, or no changes.
#
# Possible outcomes:
# * No changes: push is executed
@pseudomuto
pseudomuto / Gemfile
Last active March 29, 2019 18:52
Blog Code: Monitoring Rails Requests
source "https://rubygems.org/"
...
...
gem "statsd-instrument"
@pseudomuto
pseudomuto / attributes.rb
Created January 27, 2015 21:53
Blog Code: Ruby/Python Support for Vim
default[:vim_version] = "7-4-589"
default[:vim_checksum] = "b3d320d5e103fb2bbfafc7f167970a576148baa6ce3521e8d08a2edd42532420"
@pseudomuto
pseudomuto / Vagrantfile
Last active August 29, 2015 14:12
Blog Code: Running Rails Inside Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANT_IP = '192.168.211.39'
Vagrant.configure("2") do |config|
config.vm.box = ...
config.vm.box_url = ...
config.vm.network :private_network, ip: VAGRANT_IP
...
### Keybase proof
I hereby claim:
* I am pseudomuto on github.
* I am pseudomuto (https://keybase.io/pseudomuto) on keybase.
* I have a public key whose fingerprint is 07AD 880F 9E9F 7BBF DA41 8344 DAC1 3574 DD84 2F2F
To claim this, I am signing this object:
@pseudomuto
pseudomuto / philosophers.c
Last active June 23, 2020 12:34
Blog Code: Dining Philosophers in C
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
typedef struct {
int position;
int count;
sem_t *forks;
sem_t *lock;
@pseudomuto
pseudomuto / git-freeze
Last active December 31, 2015 02:49
Blog Code: Freezing and Thawing Git State
#!/bin/bash
count=0
if git commit -m "WIP [STAGED]" > /dev/null
then
let count+=1
fi
git add --all .
if git commit -am "WIP [UNSTAGED]" > /dev/null
then
@pseudomuto
pseudomuto / ContentService.cs
Last active December 24, 2015 22:59
Blog Code: Pushing Files to GitHub Programmatically
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GitHubPushLib
{
public sealed class ContentService
{
private ContentRepo _repo;
@pseudomuto
pseudomuto / web.config
Created August 25, 2013 18:42
Blog Code: Global Namespace Includes with MVC3 and Razor
<configuration>
<configSections>
...
...
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
...