This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xrandr --output LVDS-0 --mode 1920x1080 --output VGA-0 --mode 1024x768 --same-as LVDS-0 --scale 1.875x1.40625 #Scale down the 1920x1080 resolution of an LVDS display and display it on a 1024x768 VGA display. | |
# Scaling one display from 1024x768 to 1920x1080: xrandr --output LVDS-0 --scale 1.875x1.40625 | |
# Multiple for scaling 1280x1024 to 1920x1080: 1.5x1.0546875 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unquotedPropertyString = '{obj_One: "Hello", obj_Two: "World!"}'; //Mixing camelCase and snake_case. It's a test. Sue me. | |
// brokenParse = JSON.parse(unquotedPropertyString); //Error! Why is obj_One not quoted?!?!?! | |
quotedPropertyString = unquotedPropertyString.replace(/([A-Za-z0-9_]+):/g, '\"$1\":'); //Result: '{"obj_One": "Hello", "obj_Two": "World!"}' | |
// * The above won't work if you're not using alphanumeric characters or underscores for your object property names. | |
// ** The regex will also have some false positives if your property values have colons in them. You'll need to adjust the regex for your purposes. | |
// For me, I needed to process output from the Node.js "formidable" module, which prints each property line-by-line, so I used output.replace(/([\s|\{]) ([A-Za-z0-9_]+): \"/g, '$1 \"$2\": \"') | |
// I also needed to fix the single quotes around property value from the formidable output, but that doesn't apply to this example. | |
workingParse = JSON.parse(quotedPropertyString); //Yay! It works!* ** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exampleArray = [ "Hello", "World", "foo", "bar", "generic", "example", "recuerdos", "a todos" ]; | |
objText = ""; | |
for (i = 0, len = exampleArray.length; i < len; i++) { | |
thisResult = exampleArray[i]; | |
objText += '"obj_' + i + '": "' + thisResult + '", '; // First time this loops will result in --"obj_0": "Hello", -- | |
} | |
// objText should now be --"obj_0": "Hello", "obj_1": "World", "obj_2": "foo", "obj_3": "bar", -- etc., but this string ends with a comma, which JSON.parse won't allow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
numberOfRuns="10" | |
i="0" | |
while [ $i -lt ${numberOfRuns} ] | |
do | |
results[${i}]=`./performanceTest` # Replace ./performanceTest with the command line of the test you want to run. | |
# ^ This assumes that the result of the test will be a number (integer or decimal). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
THRESHOLD="15000" # You'll need to do some testing to come up with this number. | |
# Requires ImageMagick, also using PNG format since JPEG adds too much noise | |
echo "`compare -metric RMSE clean_webcam_image.png corrupt_webcam_image.png NULL: 2>&1 | awk '{print $1}'` > ${THRESHOLD}" | bc # Returns 1 if the difference is greater than 15000, 0 otherwise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# How to kill a bunch of gunicorns in one line | |
ps aux | grep gunicorn | awk '{print $2}' | sudo xargs kill -9 | |
# And no, `pkill -9 gunicorn` doesn't work because it kills out of sequence and causes a crash. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
find . -name "*.tar.gz" -maxdepth 1 -exec tar -zxvf {} \; # untar/ungzip all archives in the current directory | |
# find . -name "*.tar.bz2" -maxdepth 1 -exec tar -vxjf {} \; # Do the same for .tar.bz2 files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
# Example: Look for dependencies for https://github.com/ToolsOnAir/gl-frame-bender | |
echo "cmake boost protobuf glfw glm devil" | tr ' ' '\n' | xargs -I '{}' apt search '{}' # apt warns against this, but you can redirect output to a file if needed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Work for 25 minutes, break for 5 minutes. | |
while [ TRUE ]; do | |
echo "Worktime: The time is `date +%l:%M`" | |
notify-send "Work" "Time to start working." | |
sleep 1200 | |
echo "Worktime: 5 minutes left. The time is `date +%l:%M`" | |
notify-send "Work" "5 minutes left." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# I would hope there's a more elegant way of doing this directly in yum/DNF, but I couldn't find one. | |
yum group info "Development and Creative Workstation" | grep "\+" | sed 's/ +\+//g' | xargs yum group info | grep "Group:" | sed 's/.*Group: //g' > prettyGroupNames.txt | |
# Replace "Development and Creative Workstation" with your package group of choice. | |
# Untested in DNF |
OlderNewer