Skip to content

Instantly share code, notes, and snippets.

@jalex19100
jalex19100 / aws user-data to change default ssh port
Last active August 17, 2021 09:01
User-Data script for AWS, to change the default SSHD port from 22 to 2222, or 443, the same port HTTPS uses.
#!/bin/bash -ex
perl -pi -e 's/^#?Port 22$/Port 2222/' /etc/ssh/sshd_config
service sshd restart || service ssh restart
@jalex19100
jalex19100 / self-destruct.js
Created January 22, 2014 17:47
Self-Destruct JavaScript function - executes the contents of the function once, but does nothing on any subsequent calls. Pretty straightforward.
var selfDestructMessage = function(element) {
// Do some stuff
selfDestructMessage = function(element) { /* Replace myself with an empty block */ }
};
/*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
@jalex19100
jalex19100 / LiferayScripting.rb
Last active November 11, 2015 22:44
Some handy ruby scripting for Liferay Administration
### LIST users
userCount = com.liferay.portal.service.UserLocalServiceUtil.getUsersCount();
users = com.liferay.portal.service.UserLocalServiceUtil.getUsers(0, userCount);
users.each{ |user| $out.print user.getFullName() + "\n"}
userCount = com.liferay.portal.service.UserLocalServiceUtil.getUsersCount();
users = com.liferay.portal.service.UserLocalServiceUtil.getUsers(0, userCount);
users.each{ |user| $out.print user.toString()+ "\n" }
### UPDATE user properties
/**
* Remember to clear the previous refreshId before setting a new one. IE, in particular, will not remove the prior id automatically.
*/
var defaultRefreshInterval = 5; // minutes
var url = window.location.protocol + '//' + document.domain;
var refreshId;
var enableAutoRefresh = function() {
var interval = jQuery('#autorefresh_interval').val();
var enabled = jQuery('#enable_autorefresh').is(':checked');
Object.prototype.getName = function() {
var funcNameRegex = /function (.{1,})\(/;
var results = (funcNameRegex).exec((this).constructor.toString());
return (results && results.length > 1) ? results[1] : "";
};
@jalex19100
jalex19100 / simple.linux.commands.sh
Last active November 11, 2015 22:44
UNIX magic
# show any ghost/phantom resources that could still be affecting df but have been deleted
lsof +L 1 /home | grep -i deleted
# hog
du -sk *
# add up the hogs
du -sk * |sort -n| awk {'print $1'}| paste -sd+| bc
# use date to get the date 30 days ago
@jalex19100
jalex19100 / GuavaOrdering.java
Last active November 11, 2015 22:45
Adhoc ordering outside of Comparable
Ordering<Item> o = new Ordering<Item>() {
@Override
public int compare(Item left, Item right) {
return Ints.compare(left.getValue(), right.getValue());
}
};
return o.max(listOfItem);
@jalex19100
jalex19100 / MavenWeblogicDeploy.cmd
Last active November 11, 2015 22:45
Maven Weblogic Deploy plugin
@REM store user credentials
@REM setDomainEnv.cmd only seems to work when you are in the same PWD
C:\Oracle\middleware\user_projects\domains\base_domain\bin>setDomainEnv.cmd
C:\Oracle\middleware\user_projects\domains\base_domain>java weblogic.WLST
wls:/offline> connect ('myUserid','myPassword','t3s://localhost:7001');
wls:/CLUSTERNAME/serverConfig> storeUserConfig(userConfigFile='wls.local.config', userKeyFile='wls.local.key');
@Deploying with maven weblogic plugin
mvn weblogic:wlst -nsu -Penv-local -DfileName=etc\redeploy.py -DfailOnError=false -Dargs="${wls.userConfigFile} ${wls.userKeyFile} ${wls.adminurl}"
@jalex19100
jalex19100 / modifyVMAcl.ps1
Created September 26, 2015 02:02
Modify Azure VM ACL with Powershell
$name = "myVM"
$acl1 = New-AzureAclConfig
$vm = Get-AzureVM -ServiceName $name -Name $name
Set-AzureAclConfig -AddRule -ACL $acl1 -Order 100 -Action permit -RemoteSubnet "X.X.0.0/16" -Description "rule1"
Set-AzureAclConfig -AddRule -ACL $acl1 -Order 200 -Action permit -RemoteSubnet "X.X.0.0/16" -Description "rule2"
$vm | Get-AzureEndpoint | ForEach-Object {Set-AzureEndpoint -ACL $acl1 -Nam
e $_.Name -VM $vm}