Skip to content

Instantly share code, notes, and snippets.

@jcasimir
jcasimir / exporter.rb
Created February 26, 2012 20:09 — forked from chad/exporter.rb
Export ActiveRecord Tables to CSV
require 'csv'
module Exporter
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ]
DESTINATION_FOLDER = "tmp/"
def self.included(klass)
klass.extend ClassLevelMethods
end
@roberto
roberto / _flash_messages.html.erb
Created August 13, 2012 22:47
Rails flash messages using Twitter Bootstrap
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@deps
deps / gist:6028795
Last active August 6, 2016 07:58
A reminder to myself and anyone wanting to use Sinatra on Nitrous.IO
require 'sinatra'
# Set port for compatability with Nitrous.IO
configure :development do
set :bind, '0.0.0.0'
set :port, 3000 # Not really needed, but works well with the "Preview" menu option
end
get '/' do
"Sinatra on Nitrous.IO"
Spree::Order.joins(:ship_address).each do |order|
# do something with order.ship_address here
end
@BrandonPotter
BrandonPotter / restart-kubectl-master-services.md
Last active February 23, 2021 17:25
Restart Kubernetes Master Services
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler flanneld; do
	systemctl restart $SERVICES
	systemctl enable $SERVICES
	systemctl status $SERVICES
done

restart kubelet/node services

for SERVICES in kube-proxy kubelet flanneld docker; do

systemctl restart $SERVICES

@dmahugh
dmahugh / comparision.py
Created May 23, 2017 17:21
comparison of asynchronous HTTP requests (aiohttp/asyncio) and traditional sequential requests (with Requests library)
"""Comparison of fetching web pages sequentially vs. asynchronously
Requirements: Python 3.5+, Requests, aiohttp, cchardet
For a walkthrough see this blog post:
http://mahugh.com/2017/05/23/http-requests-asyncio-aiohttp-vs-requests/
"""
import asyncio
from timeit import default_timer
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@cmer
cmer / haproxy.cfg
Last active April 15, 2024 09:54
Simple, no bullshit TCP port forwarding using HAProxy
listen l1
bind 0.0.0.0:443
mode tcp
timeout connect 4000
timeout client 180000
timeout server 180000
server srv1 host.example.com:9443
@u1i
u1i / start-private-registry.sh
Created September 20, 2017 10:16
Run a private Docker registry
# Run a private registry
docker run -d -p 80:5000 --restart=always --name my_registry registry:2
# Run a private registry with SSL cert and Basic Auth
# you should generate the certs and htpasswd file before
docker run -d -p 443:5000 --restart=always --name registry \
-v /etc/ssl-certs:/certs \
@htruong
htruong / raspberry-pi-chroot-armv7-qemu.md
Last active June 18, 2023 18:00 — forked from jkullick/raspberry-pi-chroot-armv7-qemu.md
Chroot into Raspberry Pi ARMv7 Image with Qemu
# raspbian stretch lite on ubuntu

### You can write the raspbian image onto the sd card,
# boot the pi so it expands the fs, then plug back to your laptop/desktop
# and chroot to it with my script 
# https://gist.github.com/htruong/7df502fb60268eeee5bca21ef3e436eb
# sudo ./chroot-to-pi.sh /dev/sdb
# I found it to be much less of a pain in the ass and more reliable
# than doing the kpartx thing