Download hazelcast-3.8
Copy hazelcast.xml from /bin into /demo.
Run demo/console.sh
Note the file name must be hazelcast.xml or else the ConsoleApp will not recognize the provided config file.
Connecting your hazelcast instance to mancenter is done through mancenter. Make sure your mancenter url appears as it does in the hazelcast.xml file.
Nerd Posts
Nexus Repository Manager
Unzip
Potentially add bin to the PATH var
./nexus start
(wait about 2 minutes for the services to start up)
visit http://localhost:8082/#browse/welcome
Top right, click Sign in
Default creds: admin / admin
Click on Settings in the top bar > Repositories
Create repository
Here is how to proxy live repositories such as maven central:
Select Recipe: maven2 (proxy)
Name: maven central, Release, Strict, maven central url
Create repository
After using the generated url to fetch 1 or 2 jars, the repository Status will change from Online - Remote Connection Pending to Online.
You can also create your own local by using Select Recipe: maven2 (hosted).
Setting up ssh tunnel
On remote windows server:
sshd start
# must create all ssh_host_keys first
# ssh-keygen -a
# the sshd_config is probably inside /etc/ssh/sshd_config
on the local client:
ssh -L [localport]:[redirect-ip]:[redirect-port] -N
you can also chain them like this:
ssh -L 10000:test.com:10000 -N \
-L 20000:test.com:20000 -N \
-L 30000:test.com:30000 -N
http://localhost:10000 will now reach test.com:10000 THROUGH your ssh tunnel (remote windows server)
sshd start
# must create all ssh_host_keys first
# ssh-keygen -a
# the sshd_config is probably inside /etc/ssh/sshd_config
on the local client:
ssh -L [localport]:[redirect-ip]:[redirect-port] -N
you can also chain them like this:
ssh -L 10000:test.com:10000 -N \
-L 20000:test.com:20000 -N \
-L 30000:test.com:30000 -N
http://localhost:10000 will now reach test.com:10000 THROUGH your ssh tunnel (remote windows server)
Setting up karaf w/ cellar
edit bin/setenv
export JAVA_MIN_MEM=1024M
export JAVA_MAX_MEM=2048M
export JAVA_PERM_MEM=1024M
export JAVA_MAX_PERM_MEM=2048M
feature:repo-add cellar 3.0.3
feature:list | grep -i cellar
feature:install cellar
# feature:install cellar/3.0.3
feature:install cellar-obr
# feature:install cellar-obr/3.0.3
cluster:obr-[hit tab] # should show cluster:obr-add-url
cluster:group-create group # optional, I just use default
cluster:obr-add-url default file:///path/to/repo/index.xml # note the file protocol is needed
# alternatively, add the uri above to etc/config.properties under obr.repository.url
cluster:group-list
cluster:obr-list-url default
cluster:obr-list default | grep -i [package name]
note: if you remove ~/.karaf, you will have to re-exec all of the above again.
export JAVA_MIN_MEM=1024M
export JAVA_MAX_MEM=2048M
export JAVA_PERM_MEM=1024M
export JAVA_MAX_PERM_MEM=2048M
feature:repo-add cellar 3.0.3
feature:list | grep -i cellar
feature:install cellar
# feature:install cellar/3.0.3
feature:install cellar-obr
# feature:install cellar-obr/3.0.3
cluster:obr-[hit tab] # should show cluster:obr-add-url
cluster:group-create group # optional, I just use default
cluster:obr-add-url default file:///path/to/repo/index.xml # note the file protocol is needed
# alternatively, add the uri above to etc/config.properties under obr.repository.url
cluster:group-list
cluster:obr-list-url default
cluster:obr-list default | grep -i [package name]
note: if you remove ~/.karaf, you will have to re-exec all of the above again.
Setting up basic auth in IIS 7 for a specific sub-directory
Add the following in web.config under < connectionStrings />:
In IIS make sure anonymous authentication is enabled, and basic authentication is disabled.
<!-- restrict api help with AD basic auth -->
<location path="help">
<system.web>
<authorization>
<deny users="?" /> <!-- deny anonymous users -->
</authorization>
</system.web>
<system.webServer>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="" roles="ApiUsers" />
</authorization>
<authentication>
<basicAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
<!-- restrict api help with AD basic auth -->
<location path="help">
<system.web>
<authorization>
<deny users="?" /> <!-- deny anonymous users -->
</authorization>
</system.web>
<system.webServer>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="" roles="ApiUsers" />
</authorization>
<authentication>
<basicAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
Using query to alter sysmail servername in SQL SERVER 2012
to check db mail server configuration:
select * from
msdb.dbo.sysmail_account sa
left join msdb.dbo.sysmail_server ss
on ss.account_id = sa.account_id;
to update the servername for an existing account:
exec msdb.dbo.sysmail_update_account_sp
@account_id = #,
@mailserver_name = 'something the resolves to an IP within your network';
GIT rebase
git checkout feature-branch
ff merge:
git checkout master
git merge master-rebase
git checkout -b master-rebase
git rebase -i master
(pick the first commit and squash the rest of the commits)
during merge conflicts:
git checkout --theirs .
git add .
git rebase --continue
ff merge:
git checkout master
git merge master-rebase
cleanup:
git branch -D master-rebase
----------------------------
.. to overwrite current branch1 with branch2
git checkout branch2
git merge -s ours branch1
.. this effectively makes branch1 = branch2
.. now to fast forward branch1 to sync the branches
git checkout branch1
git merge branch2
----------------------------
.. to overwrite current branch1 with branch2
git checkout branch2
git merge -s ours branch1
.. this effectively makes branch1 = branch2
.. now to fast forward branch1 to sync the branches
git checkout branch1
git merge branch2
GIT force take branch changes
Situation:
[origin/branch1] [branch1] took only partial changes from branch2 during merge
[origin/branch2] [branch2] has changes 1, 2, 3
In other words, branch1 has only done a partial merge of branch2. As such branch2 has changes that are 'newer' than branch1. You can complete the merge with the following commands.
git checkout branch1
git merge branch2
But this isn't what you want. You left out those merges on purpose. In this case, you know that branch1 is up-to-date (even though it has left out some files from branch2). What you really want to do is to overwrite branch2 with branch1. You can do this with the following commands.
git checkout branch1 # branch missing files
git merge -s ours branch2 # branch with unnecessary changes
OMFG GIT REBASE
Situation:
[origin/branch1] [branch1] some commit message
[origin/branch2] [branch2] another commit message
git checkout branch1
git rebase branch2
oops...
[origin/branch1] some commit message
[origin/branch2] [branch2] [branch1] another commit message
to undo this:
git checkout branch1
git fetch origin
git reset --hard origin/branch1
OSX Launching mysql at startup in Yosemite
This assumes that you installed mysql using homebrew (ie. brew install mysql)
ln -sfv /usr/local/opt/mysql/*.plist /Library/LaunchDaemons
# to manualy start the service
# sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
Gotta make sure it's got the right permissions:
sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
Contents of the homebrew.mxcl.mysql.plist file:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple 3 <plist version="1.0"> 4 <dict> 5 <key>KeepAlive</key> 6 <true/> 7 <key>Label</key> 8 <string>homebrew.mxcl.mysql</string> 9 <key>ProgramArguments</key> 10 <array> 11 <string>/usr/local/opt/mysql/bin/mysqld_safe</string> 12 <string>--user=root</string> 13 <string>--socket=<socket filepath></string> 14 <string>--pid-file=<pid filepath></string> 15 <string>--bind-address=127.0.0.1</string> 16 <string>--datadir=<data directory></string> 17 </array> 18 <key>RunAtLoad</key> 19 <true/> 20 <key>WorkingDirectory</key> 21 <string>/usr/local/var</string> 22 </dict> 23 </plist>
Reinstalling homebrew (Yosemite update)
# clean up homebrew
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
# reinstall homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
# recommended
brew doctor
cd /usr/local/Library && git stash && git clean -d -f
now you can start clean again with homebrew:
ie. brew install mysql
MySql Hell: error! the server quit without updating pid file
First I have to note that several other developers have recommended removing the .err file, or renaming the ib_logfile## files. Obviously this didn't work for me or else I wouldn't be writing this post.
This issue started occurring once I placed my.cnf into the /etc directory.
The best way to see what's actually happen is to open the err file and debug. You can specify the location of the log file via:
[mysqld]
datadir = /usr/local/mysql
With the above setting, your log file will be:
/usr/local/mysql/.err
In my case it was actually a permissions issue. My database uses a non-standard socket setting (to match linux environment). I also disabled the root access, and have specific credentials that mysqld and mysql needs during startup. That said, my my.cnf file looks as follows:
[client]
user=myuser
password=mypassword
[mysqld]
user=sysuser
pid-file=/path/to/mysqld.pid
socket=/path/to/mysqld.sock
port=3306
datadir=/dir/for/mysql/data
tmpdir=/tmp
general_log_file=/tmp/logs/mysql.log
log_bin=/tmp/logs/mysql-bin.log
# DO NOT USE THIS NEXT LINE OR YOUR DB WILL BE LOCKED IN READ ONLY MODE
# innodb_force_recovery = 1
It's important to note that sysuser is actually the user who OWNS the directories on your system (ie. root or yourMacUserName), not to be confused with your mysql users. So, in my case, I would also need to make sure that the datadir, pid-file-dir, socket-dir, and log-dir are all accessible (via chown) by 'sysuser'.
now try starting the db via: sudo mysql.server start
This issue started occurring once I placed my.cnf into the /etc directory.
The best way to see what's actually happen is to open the err file and debug. You can specify the location of the log file via:
[mysqld]
datadir = /usr/local/mysql
With the above setting, your log file will be:
/usr/local/mysql/
In my case it was actually a permissions issue. My database uses a non-standard socket setting (to match linux environment). I also disabled the root access, and have specific credentials that mysqld and mysql needs during startup. That said, my my.cnf file looks as follows:
[client]
user=myuser
password=mypassword
[mysqld]
user=sysuser
pid-file=/path/to/mysqld.pid
socket=/path/to/mysqld.sock
port=3306
datadir=/dir/for/mysql/data
tmpdir=/tmp
general_log_file=/tmp/logs/mysql.log
log_bin=/tmp/logs/mysql-bin.log
# DO NOT USE THIS NEXT LINE OR YOUR DB WILL BE LOCKED IN READ ONLY MODE
# innodb_force_recovery = 1
It's important to note that sysuser is actually the user who OWNS the directories on your system (ie. root or yourMacUserName), not to be confused with your mysql users. So, in my case, I would also need to make sure that the datadir, pid-file-dir, socket-dir, and log-dir are all accessible (via chown) by 'sysuser'.
now try starting the db via: sudo mysql.server start
Odd image rotation when uploading photos taken from Samsung S4
Issue occurs when I upload an image to my webapp from the Samsung S4. The actual image displays just fine when requested directly through Chrome (ie. http://xxxxx/image.jpg). However, when rendered using rails image tag, the image appears 90 degrees rotated. The image appears rotated in Chrome but renders fine in mobile safari.
The proper solution is to allow your rendering code to detect the image orientation. Perhaps there's a way to solve this through CSS. Since I'm bound by time, I've came up with the most fastest (albeit hacky) solution possible... manual commands via imagemagick!
Turns out it's extremely easy to install imagemagick on linux:
sudo apt-get install imagemagick
Rotating the image:
convert source_photo.jpg -rotate 90 dest_photo.jpg
Removing the image metadata:
mogrify -strip image.jpg
Please share if you have a more automated solution!!
Various jQuery filters
basic filters
:first
:last
:even
:odd
:eq(n)
:gt(n)
:lt(n)
:header // selects H1, H2...
:animated
:not(selector)
attribute filters
[attribute]
[attribute=value]
[attribute!=value[
[attribute^=value[ // starts with
[attribute$=value[ // ends with
[attribute*=value[ // contains
[attrFilter1][attrFilterN] // match all specified filters
content filters
:contains(text) // contains text string
:empty // only include empty elements
:has(selector) // element containing at least one element with specified selector
:parent // all elements that are parents
visibility filters
:visible
:hidden
child filters
:nth-child(index)
:nth-child(even)
:nth-child(odd)
:nth-child(equation)
:first-child
:last-child
:only-child
form filters
:input
:text
:password
:radio
:checkbox
:submit
:reset
:image
:button
:file
form state filters
:enabled
:disabled
:checked
:selected
:first
:last
:even
:odd
:eq(n)
:gt(n)
:lt(n)
:header // selects H1, H2...
:animated
:not(selector)
attribute filters
[attribute]
[attribute=value]
[attribute!=value[
[attribute^=value[ // starts with
[attribute$=value[ // ends with
[attribute*=value[ // contains
[attrFilter1][attrFilterN] // match all specified filters
content filters
:contains(text) // contains text string
:empty // only include empty elements
:has(selector) // element containing at least one element with specified selector
:parent // all elements that are parents
visibility filters
:visible
:hidden
child filters
:nth-child(index)
:nth-child(even)
:nth-child(odd)
:nth-child(equation)
:first-child
:last-child
:only-child
form filters
:input
:text
:password
:radio
:checkbox
:submit
:reset
:image
:button
:file
form state filters
:enabled
:disabled
:checked
:selected
Deploying .NET through Plesk
Need:
To deploy a .NET 4.0 web application
Plesk is used to manage sites and application pools :(
Plesk is old and only supports .NET 2.0 :( :(
Solution:
create new subdomain in plesk. By default the site will use ASP.NET 2.0
cd c:\...\framework\v4.0.xxxxx
aspnet_regiis.exe -lk
# now go find the identifier of the site/subdomain in IIS, should be a number
# now update .NET version of that site/subdomain using identifier
aspnet_regiis -sn W3SVC//ROOT/
# verify that it worked
aspnet_regiis.exe -lk
Site now served using .NET 4.0 application pool even though Plesk doesn't support it.
Problems in Rails
Problem: Issue with rails missing the rake gem
Solution: Install rake to the rvm global environment
rvm ruby-2.0.0-p###
gem install rake -v 10.1.0
Problem: It looks like Bundler could not find a gem. This is probably because your application is being run under a different environment than it's supposed to.
Solution: Manage gems with rvm. In my case, 'passenger' was using the global gemset even though I specified the project to use env1... solution is of course to install all missing gems for the global gemset.
# list the gemsets
rvm gemset list
# to use env1 gemset
rvm 2.0.0-p###@env1
# to use global gemset
rvm 2.0.0-p###@global
# install missing gems
gem install
bundle install
Problem: Various commands for cloning/creating/deleting gemsets
Solution: Use rvm
# clone
rvm gemset copy 2.0.0-pXXX@env1 2.0.0-pXXX@env2
# create
rvm gemset create env2
# delete
rvm gemset delete env2
Problem: When POW complains that rake does not exist
Solution: Add a .powrc file with the following content:
Solution: Install rake to the rvm global environment
rvm ruby-2.0.0-p###
gem install rake -v 10.1.0
Problem: It looks like Bundler could not find a gem. This is probably because your application is being run under a different environment than it's supposed to.
Solution: Manage gems with rvm. In my case, 'passenger' was using the global gemset even though I specified the project to use env1... solution is of course to install all missing gems for the global gemset.
# list the gemsets
rvm gemset list
# to use env1 gemset
rvm 2.0.0-p###@env1
# to use global gemset
rvm 2.0.0-p###@global
# install missing gems
gem install
bundle install
Problem: Various commands for cloning/creating/deleting gemsets
Solution: Use rvm
# clone
rvm gemset copy 2.0.0-pXXX@env1 2.0.0-pXXX@env2
# create
rvm gemset create env2
# delete
rvm gemset delete env2
Problem: When POW complains that rake does not exist
Solution: Add a .powrc file with the following content:
if [ -f "$rvm_path/scripts/rvm" ]; then
source "$rvm_path/scripts/rvm"
fi
rvm ruby-2.0.0-pXXX@env1
Problem: Gem::LoadError: You have already activated json 1.8.1, but your Gemfile requires json 1.8.0 ...
Solution-1: Globally, call bundle uninstall json -v 1.8.1
Solution-2: Locally, call bundle update json
Getting PHP and Apache to work again after upgrading to Yosemite
One of the worst part about upgrading OSX has to be reconfiguring Apache to work. It was the same when I upgraded to Maverick, and again now in my upgrade to Yosemite.
You can use sudo apachectl configtest to check configuration errors. Diff-ing the previous version against the current version yielded the following (annoying) gotchas:
Apache:
The httpd.conf is still at the same place: /etc/apache2/httpd.conf, but it was overwritten. I think the previous is automatically backed up as httpd.conf~previous.You can use sudo apachectl configtest to check configuration errors. Diff-ing the previous version against the current version yielded the following (annoying) gotchas:
- Many modules were turned off by default (ie. php5_module). Some were added (ie. session_module), renamed (ie. disk_cache_module), or removed (ie. ident_module)
- User & Group were reset to _www
- Order deny,allow / Deny from all is now Require all denied
- Order deny,allow / Allow from all is now Require all granted
- Supplemental configs were removed (ie. httpd-vhosts.conf, httpd-ssl.conf, etc)
- For SSLSessionCache, you need to enable several modules in the httpd.conf file (ie. socache_shmcb_module, socache_dbm_module, socache_memcache_module)
The biggest, and most annoying gotcha of all were items #3 and #4. Make sure you make these changes in all supplemental configs like httpd-vhosts.conf.
PHP:
php.ini was removed. I think the previous is automatically backed up as php.ini-x.x-previous. For some reason, my php zts extension was updated as well, so I had to make a minor update to the php.ini ie. /usr/lib/php/extensions/no-debug-non-zts-xxxxxxxx/xdebug.so
P.s. I don't remember if I had to reinstall pear.
MySQL:
If MySQL isn't started, run this command to start it again:
sudo /usr/local/mysql/support-files/mysql.server start
Setting up a local proxy on your phone
The software I chose to use is called Squidman Proxy. A more robust and intuitive (albeit costly) option is Charles Proxy.
http://squidman.net/squidman/
http://www.charlesproxy.com/
This tutorial is for setting up Squidman for iOS or Android.
Precursor:
Make sure that the computer is accessible by your device by IP.
It's easiest to set up your environment if both are connected to the same router.
Steps:
On your iOS device, select WIFI and click on the little (i) icon
Select Manual for HTTP PROXY
Set Server IP to the IP of your computer
Set Port to 8112
Leave authentication empty
On your computer, open Squidman
Set your HTTP Port to 8112.
Go to the Template tab, and paste the following
Replace the highlighted IP with your device's IP
Click on Start Squid
http://squidman.net/squidman/
http://www.charlesproxy.com/
This tutorial is for setting up Squidman for iOS or Android.
Precursor:
Make sure that the computer is accessible by your device by IP.
It's easiest to set up your environment if both are connected to the same router.
Steps:
On your iOS device, select WIFI and click on the little (i) icon
Select Manual for HTTP PROXY
Set Server IP to the IP of your computer
Set Port to 8112
Leave authentication empty
On your computer, open Squidman
Set your HTTP Port to 8112.
Go to the Template tab, and paste the following
Replace the highlighted IP with your device's IP
Click on Start Squid
cache_peer %PARENTPROXY% parent %PARENTPORT% 7 no-query no-digest no-netdb-exchange default cache_dir ufs %CACHEDIR% %CACHESIZE% 16 256 maximum_object_size %MAXOBJECTSIZE% coredump_dir %CACHEDIR% visible_hostname %VISIBLEHOSTNAME% cache_access_log stdio:/Users/dyu/Desktop/access.log cache_store_log stdio:/Users/dyu/Desktop/store.log cache_log /Users/dyu/Desktop/cache.log pid_filename %PIDFILE% http_port %PORT% acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT %ALLOWEDHOSTS% %DIRECTHOSTS% http_access allow localhost manager http_access deny manager acl allcomputers src 192.168.0.0/255.255.252.0 http_access allow allcomputers http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access deny to_localhost http_access allow localhost %HTTPACCESSALLOWED% http_access deny all %ALWAYSDIRECT% always_direct deny all hierarchy_stoplist cgi-bin ? refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320
Subscribe to:
Posts (Atom)