Skip to content

Instantly share code, notes, and snippets.

@yesmeck
yesmeck / core.sh
Last active December 26, 2018 14:30
Sunspot create solr core
# 假设新建一个叫 core1 的 core
mkdir -p /path/to/core1/data
cd /path/to/project
cp -r `bundle show sunspot_solr`/solr/solr/conf /path/to/core1
bundle exec rake sunspot:solr:start
@jicowan
jicowan / enable-mfa-delete.py
Created July 14, 2017 05:26
enable mfa-delete on a bucket
import boto3
from botocore.exceptions import ClientError
s3_client = boto3.client('s3')
s3_bucket = boto3.resource('s3')
bucket_name = raw_input('Enter the name of the bucket that you want to enable MFA-delete on: ')
mfa_token = raw_input('Enter your MFA serial number and token code, e.g. <deviceSerialNumber> <tokenCode>: ')
try:
s3_bucket.meta.client.head_bucket(Bucket=bucket_name)
@jkeroes
jkeroes / perlbrew perl install with libs.markdown
Last active November 19, 2019 17:26
Build Perl with perlbrew, libs, and cpanm

Install Perlbrew with the system perl

curl -L http://install.perlbrew.pl | bash

Initialize Perlbrew

mkdir /opt/perlbrew
export PERLBREW_ROOT=/opt/perlbrew
export PERLBREW_HOME=/opt/perlbrew

perlbrew init # and follow the directions

@lefant
lefant / README.unison.md
Created October 9, 2015 04:53
how to set up unison on mac os x for dropbox style instant syncing

installing unison on mac

brew install unison

workaround for missing unison-fswatch in brew

sudo pip install macfsevents
curl https://raw.githubusercontent.com/jumpstarter-io/unox/master/unox.py |sudo tee /usr/local/bin/unison-fsmonitor >/dev/null
sudo chmod +x /usr/local/bin/unison-fsmonitor
@flomotlik
flomotlik / heroku_run.sh
Last active January 10, 2020 21:40
Heroku run script that exits with the correct error code
#! /bin/bash
array=( $@ )
len=${#array[@]}
app=${array[$len-1]}
args=${array[@]:0:$len-1}
buffer_file=/tmp/last_heroku_run_`date +%N`
/usr/bin/heroku run "$args; echo \$?" --app $app 2>&1 | tee $buffer_file
@stereoscott
stereoscott / active_admin.rb
Last active March 15, 2020 10:47
Stream CSV exports in ActiveAdmin in Rails 4
# if you want to monkey patch every controller, put this in initializers/active_admin.rb
ActiveAdmin::ResourceController.class_eval do
include ActiveAdmin::CSVStream
end
@abhishek77in
abhishek77in / install_ruby_rpi.sh
Created April 11, 2016 18:48 — forked from blacktm/install_ruby_rpi.sh
A Bash script to install Ruby 2.3 on the Raspberry Pi (Raspbian)
#!/bin/bash
# -----------------------------------------------------------------------
# Installs Ruby 2.3 using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s raw_script_url_here)
# -----------------------------------------------------------------------
# Set up variables
@abhishek77in
abhishek77in / report.rb
Created December 9, 2012 19:31
Create a PDF Document using Prawn Library with header, footer and page numbering.
require "prawn"
Prawn::Document.generate("report.pdf") do
10.times do
start_new_page
end
repeat :all do
move_down 50
@tuatara
tuatara / admin.py
Last active April 7, 2021 21:23
Allow case-insensitive usernames with Django & Postgres
# Add the mixin to the default admin objects
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin as ContribUserAdmin
from django.contrib.auth.forms import UserChangeForm as ContribUserChangeForm, \
UserCreationForm as ContribUserCreationForm
from accounts.forms import CaseInsensitiveUsernameMixin # adjust if forms.py is not in `accounts` app
class UserChangeForm(CaseInsensitiveUsernameMixin, ContribUserChangeForm):
@penguinpowernz
penguinpowernz / nwinfo.rb
Created February 28, 2016 03:33
Ruby network interface information parser
#!/usr/bin/env ruby
require 'json'
ifaces = []
whitelist = [ "eth", "wlan", "en" ]
names = `ip link sh`.scan(/^\d+: (.*):/).flatten.select do |name|
whitelist.any? {|pattern| name.start_with?(pattern) }
end