curl -L http://install.perlbrew.pl | bash
mkdir /opt/perlbrew
export PERLBREW_ROOT=/opt/perlbrew
export PERLBREW_HOME=/opt/perlbrew
perlbrew init # and follow the directions
# 假设新建一个叫 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 |
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) |
#! /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 |
# if you want to monkey patch every controller, put this in initializers/active_admin.rb | |
ActiveAdmin::ResourceController.class_eval do | |
include ActiveAdmin::CSVStream | |
end |
#!/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 |
require "prawn" | |
Prawn::Document.generate("report.pdf") do | |
10.times do | |
start_new_page | |
end | |
repeat :all do | |
move_down 50 |
# 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): |
#!/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 |