#Mac OS X
| #!/bin/bash | |
| # bash generate random alphanumeric string | |
| # | |
| # bash generate random 32 character alphanumeric string (upper and lowercase) and | |
| NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
| # bash generate random 32 character alphanumeric string (lowercase only) | |
| cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1 |
| #/bin/bash | |
| #-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password | |
| REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'` | |
| if [ -z "$REPO_URL" ]; then | |
| echo "-- ERROR: Could not identify Repo url." | |
| echo " It is possible this repo is already using SSH instead of HTTPS." | |
| exit | |
| fi |
| --This script MUST be named "Switch to <User>.scpt", where <User> is the name of the user to switch to. | |
| --You must first make a password item (a.k.a. a key) for the other user's password using Keychain Access, | |
| --and call it "<user>", where "<user>" is the other user's name.the field "Kind" must be "User Login" (without quotes). | |
| --The script assumes that you make this key in your login.keychain, which is the default one. | |
| --The first time you run this script, you will be prompted to allow Keychain Scripting to access the password of the key. | |
| --This script requires "Enable access for assistive devices" to be enabled in the Universal Access system preference pane. | |
| set username to word -1 of my findReplace(".scpt", "", (path to me as text)) | |
| -- Invoke Fast User Switching. The `id -ur username` part gets the uid number that corresponds to the username and substitutes it at the end of the CGSession command |
| In [1]: policy = """{ | |
| ...: "Statement":[{ | |
| ...: "Effect":"Allow", | |
| ...: "Action":["s3:*"], | |
| ...: "Resource":["arn:aws:s3:::mybucket"]}]}""" | |
| In [2]: import boto | |
| In [4]: c = boto.connect_iam() | |
| In [5]: instance_profile = c.create_instance_profile('myinstanceprofile') | |
| In [6]: role = c.create_role('myrole') | |
| In [7]: c.add_role_to_instance_profile('myinstanceprofile', 'myrole') |
An introduction to curl using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).
First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.
Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.
| wget http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txt | |
| sudo mv add-apt-repository.sh.txt /usr/sbin/add-apt-repository | |
| sudo chmod o+x /usr/sbin/add-apt-repository | |
| sudo chown root:root /usr/sbin/add-apt-repository | |
| sudo add-apt-repository ppa:webupd8team/sublime-text-2 |
| require 'nokogiri' | |
| require 'uri' | |
| module FeedTags | |
| def absolute_url(url, base='/') | |
| return url if url.match /^(javascript|data):/ | |
| root = @context.registers[:site].config['home'] | |
| URI.join(root, base, url).to_s | |
| end |