Skip to content

Instantly share code, notes, and snippets.

@Kurt-P
Kurt-P / sensorOut.sh
Created August 25, 2013 03:51
This is a shell script that simply outputs every 15 seconds the temp of the chips on a MB, using lm_sensors. It's nothing that impressive.
#!/bin/bash
while [ true ]
do
sleep 15
sensors
done
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Write your commit message in the imperative: "Fix bug" and not "Fixed bug"
@Kurt-P
Kurt-P / ApplicationLauncher.java
Created August 20, 2013 20:56
Launch an app or something with Java. I think it would work with scrips as well.
/**
* @author Kurt P
* @version 1.1.08142012
*/
public class ApplicationLauncher {
private String path;
private Process p;
/**
@Kurt-P
Kurt-P / StreamGobbler.java
Created August 20, 2013 20:55
The stream gobbler likes to gobble streams, like cookie monster like to gobble cookies.
private class StreamGobbler extends Thread {
InputStream is;
String type;
/**
*
* @param is InputStream
* @param type The type: "ERROR", etc.
*/
@Kurt-P
Kurt-P / GropuAndSum.ps1
Created August 20, 2013 20:54
Group and sum a set of data with powershell
$gdata = $printsLogs | Group-Object -Property userId
$test = @()
$test += foreach($item in $gdata){
$item.Group | Select -Unique userId,
@{Name = 'PageTotal';Expression = {(($item.Group) | measure -Property pages -sum).Sum}}
}
@Kurt-P
Kurt-P / getUsers.sh
Created August 20, 2013 20:53
Get all users in Linux
awk -F":" '{ print "username: " $1 "\t\tuid:" $3 }' /etc/passwd
@Kurt-P
Kurt-P / SomeProgram.java
Created August 20, 2013 20:51
This is an example of getting cli input to a file with Java.
import java.io.File;
public class SomeProgram {
public static void main(String[] args) {
if(args.length > 0) {
File file = new File(args[0]);
// Work with your 'file' object here
}
}
@Kurt-P
Kurt-P / bubble.java
Created August 20, 2013 20:44
Bubble sort example if java. Not sure if it works.
public class bubble {
public static void main(String[] args) {
int[] a = {9, 1, 67, 54, 37};
int i, j, t = 0;
int n = 5;
for (i = 0; i < n; i++) {
for (j = 1; j < (n - i); j++) {
if (a[j - 1] > a[j]) {
t = a[j - 1];
@Kurt-P
Kurt-P / ChoiceExample.py
Created August 20, 2013 20:42
Give the user some choice with a python script.
#!/usr/bin/python
# Version 2
print (30 * '-')
print (" M A I N - M E N U")
print (30 * '-')
print ("1. Backup")
print ("2. User management")
print ("3. Reboot the server")
print (30 * '-')
@Kurt-P
Kurt-P / Scope.java
Created August 20, 2013 20:41
Some example of Java scopes.
package softwareconstructionexample_01;
public class SoftwareConstructionExample_01 {
public static void main(String[] args) {
int x = 0;
double y = 0.0;
for (int i = 0; i < 11; i++) {
y = 2.0;