Skip to content

Instantly share code, notes, and snippets.

@agirorn
agirorn / track-pad.sh
Last active July 6, 2017 10:23
Disable or enable the TrackPad on an IBM T450 laptop for Ubuntu.
#!/usr/bin/env bash
showHelp() {
cat <<HELP
$0 [OPTIONS]
Enable or Disable the trackpad on T450 on Ubuntu.
Options:
-h, --help Print help screen
@agirorn
agirorn / check-if-var-is-set.sh
Created July 6, 2017 09:32
Bash: Check if variable is set.
#!/usr/bin/env bash
# Uncomment next line to test
# VARIABLE=10
if [ -z ${VARIABLE+x} ]; then
echo "Variable \$VARIABLE is not set"
else
echo "Variable \$VARIABLE is set and has the value of => $VARIABLE"
fi
@agirorn
agirorn / kill-all.zsh
Created June 14, 2017 15:45
Kill all processes by name
# kill-all <NAME>
function kill-all() {
ps aux | grep $1| grep -v grep | awk '{print $2}'|xargs kill -s 9
}
@agirorn
agirorn / dec-2-hex-string.js
Created November 23, 2016 16:04
Convert decimal to hex in JavaScript.
function dec2hexString(dec) {
return '0x' + (dec+0x10000).toString(16).substr(-4).toUpperCase();
}
@agirorn
agirorn / Promise.js
Created November 18, 2016 10:44
How do I return the response from an asynchronous call.....
function foo() {
return new Promise(function(resolve) {
$.ajax({
url: '...',
success: function(response) {
resolve(response); // Returning the response
}
});
});
}
@agirorn
agirorn / dump-pagages.sh
Created May 27, 2016 10:54
Dump/Restore installed packages
dpkg --get-selections > ~/installed_libs.txt
@agirorn
agirorn / linux-beep.sh
Created March 1, 2016 13:27
Beep command for Linux ( Ubuntu desktop ).
#!/usr/bin/env bash
( speaker-test -t sine -f 1000 )& pid=$! ; sleep 0.2s ; kill -9 $pid
@agirorn
agirorn / custom-matcher-compackt.js
Last active April 24, 2017 12:37
Custom Jasmine Matcher
var customMatchers = {
toBeGoofy: function(util, customEqualityTesters) {
return {
compare: function(actual, expected) {
if (expected === undefined) {
expected = '';
}
var result = {};
result.pass = util.equals(actual.hyuk, "gawrsh" + expected, customEqualityTesters);
@agirorn
agirorn / fix-shrinkwrap.sh
Created January 27, 2016 14:15
Fix your shrinkwrap file
npm cache clean; \
rm -Rf node_modules; \
rm npm-shrinkwrap.json; \
npm install; \
rm -Rf node_modules; \
npm install; \
npm shrinkwrap;
@agirorn
agirorn / .gitignore
Last active August 29, 2015 14:19 — forked from karmi/.gitignore
.DS_Store
tmp/