Skip to content

Instantly share code, notes, and snippets.

@ccarrasc
ccarrasc / if_root.sh
Last active March 1, 2019 22:47
Verify a script is being executed as root. The current process has unrestricted/unlimited (root) access when the Effective User ID (EUID) is 0:
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31mThis script must be run as root or it will fail\e[0m" 1>&2
exit 1
fi
@ccarrasc
ccarrasc / if_centos.sh
Last active March 1, 2019 22:50
Verify we are on CentOS
#!/bin/bash
OS=`cat /etc/redhat-release | awk {'print $1}'`
if [ "$OS" != "CentOS" ]; then
echo -e "\e[1;31mThis script is intended for CentOS only\e[0m" 1>&2
#exit 1
fi
@ccarrasc
ccarrasc / install_graphite.sh
Last active December 18, 2015 16:49
Install Graphite on CentOS 6
#!/bin/bash
# The current process has unrestricted/unlimited (root) access when the Effective User ID (EUID) is 0:
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31mThis script must be run as root or it will fail\e[0m" 1>&2
exit 1
fi
# Make sure we are on CentOS
OS=`cat /etc/redhat-release | awk {'print $1}'`
@ccarrasc
ccarrasc / GetCookie.js
Last active December 18, 2015 16:49
Get cookie value (must be same domain)
var getCookie = function (key) {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; ++i) {
var currentKey = cookies[i].substr(0, cookies[i].indexOf('='));
currentKey = currentKey.replace(/^\s+|\s+$/g, "");
if (currentKey === key) {
return cookies[i].substr(cookies[i].indexOf('=') + 1);
}
}
@ccarrasc
ccarrasc / install-graphite.sh
Created July 19, 2013 17:04
Script to install graphite locally on CentOs
#!/bin/bash
# Add the EPEL repo if not added already
yum repolist | grep -i epel
if [ $? -ne 0 ]; then
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
fi
# Install the preqs
yum install gcc-c++ httpd python-devel python-pip python-sqlite2 \
@ccarrasc
ccarrasc / centos_mongo.sh
Created September 9, 2013 17:37
Add repo and install MongoDb on CentOs
#!/bin/bash
# Create a repo for fetching Mongo
cat << 'EOF' > /etc/yum.repos.d/10gen.repo
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1
EOF
@ccarrasc
ccarrasc / postJSON.js
Created October 14, 2013 12:43
Serialize form input fields to JSON and POST with jQuery
// Using <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
var array = $('form').serializeArray();
var json = {};
$.each(array, function() {
json[this.name] = this.value || '';
});
$.ajax({
@ccarrasc
ccarrasc / eclipse.ini
Last active December 25, 2015 16:39
.ini for Windows 7 + Eclipse Kepler + JDK 1.7.0_45
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20130807-1835
-product
org.eclipse.epp.package.standard.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
@ccarrasc
ccarrasc / node-bookmarks.xml
Last active December 27, 2015 01:09
Eclipse Software Site bookmarks for Node development: Window -> Preferences -> Install/Update -> Available Software Sites -> Import
<?xml version="1.0" encoding="UTF-8"?>
<bookmarks>
<site url="http://download.eclipse.org/egit/updates" selected="true" name="EGit"/>
<site url="https://svn.codespot.com/a/eclipselabs.org/jsdt-jquery/updatesite" selected="true" name="JSDT jQuery"/>
<site url="http://github.eclipsesource.com/jshint-eclipse/updates/" selected="true" name="JSHint"/>
<site url="https://sourceforge.net/projects/eclipsejsonedit/files/update" selected="true" name="JSON Editor"/>
<site url="http://dl.bintray.com/nodeclipse/nodeclipse/0.7.0/" selected="true" name="Nodeclipse"/>
</bookmarks>
@ccarrasc
ccarrasc / build-volley.ps1
Created December 13, 2013 13:01
Compile volley using PowerShell. Using application paths since I forget where I put shit on Windows :/
git clone https://android.googlesource.com/platform/frameworks/volley
cd .\volley
C:\Android\android-sdk\tools\android.bat update project -p .
$Env:JAVA_HOME = "C:\Program Files (x86)\Java\jdk1.6.0_45"
C:\Ant\apache-ant-1.9.2\bin\ant.bat jar