Skip to content

Instantly share code, notes, and snippets.

View hsuh's full-sized avatar
🦕

Hsu Hlaing hsuh

🦕
  • Edinburgh
  • 12:26 (UTC -12:00)
View GitHub Profile
@hsuh
hsuh / gist:9944c36d508e568b9126
Last active August 29, 2015 14:15
Cygwin: recursive copy with ACLs or set noacl to solve file permisssion problems
# Cygwin's cp discards ACLs (complex windows permissions). You have to copy them separately as follows:
# First copy files themselves, with timestamps:
cp -a folder1 folder2
# Set all ACLs of copies to ACLs of originals:
cd folder2
find . | while read f ; do getfacl ../folder1/"$f" | setfacl -f - "$f" ; done
# or when permissions are equal for all files / directories:
getfacl folder1 > folder-perms
@hsuh
hsuh / gist:069becb4a3482968cc19
Last active August 29, 2015 14:15
copying files (like a boss)
#!bin/bash
#set -xv
cpSource='your/root/folderxxx'
cpDest='your/root/folderxxx'
verbose=false
case "$1" in
-v)
verbose=true;;
@hsuh
hsuh / gist:938c247f3e418bb96d9e
Created February 26, 2015 10:25
building ms project from command line
Go to Visual Studio Tools > start Developer Command Prompt for VS2013
msbuild yourprojectname.build /target:buildall /property:BUILD_NUMBER=1
@hsuh
hsuh / gist:84c8e509170849631a8d
Created March 1, 2015 19:42
Solving GPG Key error for RVM installation
rm -rf ~/.gnupg/
curl -#LO https://rvm.io/mpapis.asc
gpg --import mpapis.asc
\curl -sSL https://get.rvm.io | bash -s stable
@hsuh
hsuh / gist:1a087fe39e67aae7910f
Created March 18, 2015 07:55
angularjs directive to directive communication (directive's controllers)
app.directive("child", function() {
return {
...
require: ["^parent", "child"],
link: function(scope, elem, attrs, ctrls) {
var parentController = ctrls[0],
childController = ctrls[1];
childController.setParent(parentController);
},
@hsuh
hsuh / README.md
Last active August 29, 2015 14:18 — forked from mbostock/.block
@hsuh
hsuh / gist:d0e6727e42fc2c504734
Last active August 29, 2015 14:20
Removing old linux images
*** 1. Remove --no-act for run the commands for real.
*** 2. Find out the range of your kernel version numbers and replace the numbers below. e.g. {start..end}
Finding out versions:
dpkg -l | grep linux-image
Purging the images:
sudo dpkg -P --no-act --force-depends linux-image-3.13.0-{32..46}-generic
sudo dpkg -P --no-act --force-depends linux-image-extra-3.13.0-{32..46}-generic
sudo dpkg -P --no-act --force-depends linux-headers-3.13.0-{32..46}-generic
@hsuh
hsuh / objects.js
Created January 10, 2016 20:39
Mucking about with javascript objects
var a = function(y) {
var z = 1; //shared between instances, accessible via prototype method
var x = 2; //shared between instances
var self = this;
this.y = null; //not shared
var impl = function(y) {
};
var init = function(y) {
url - https://aws.amazon.com/blogs/security/a-safer-way-to-distribute-aws-credentials-to-ec2/
Finding hard-coded credentials in your code
Hopefully you’re excited about deploying credentials to EC2 that are automatically rotated. Now that you’re using Roles, a good security practice would be to go through your code and remove any references to AKID/Secret. We suggest running the following regular expressions against your code base:
Search for access key IDs: (?<![A-Z0-9])[A-Z0-9]{20}(?![A-Z0-9]). In English, this regular expression says: Find me 20-character, uppercase, alphanumeric strings that don’t have any uppercase, alphanumeric characters immediately before or after.
Search for secret access keys: (?<![A-Za-z0-9/+=])[A-Za-z0-9/+=]{40}(?![A-Za-z0-9/+=]). In English, this regular expression says: Find me 40-character, base-64 strings that don’t have any base 64 characters immediately before or after.
If grep is your preferred tool, run a recursive, Perl-compatible search using the following commands
url - https://forums.aws.amazon.com/message.jspa?messageID=671934
You could verify that they match a regular expression that describes every access key and every secret key (the AWS Security Blog has regexes you could use), but there's no way for the SDK to check if your credentials are valid without sending a request to a service. (Otherwise, the SDK would need to ship with everyone's access keys embedded in its source.)
If you do make a call to a service, though, the remote service will be able to validate your credentials and respond accordingly. If you call $s3Client->listBuckets() before calling $s3Client->registerStreamWrapper(), the client will call the service and convert the error to an exception if your credentials are invalid.