#!/bin/bashcd$ROOT_DIR
DOT_FILES="lastpass weechat ssh Xauthority"fordotfilein$DOT_FILES;do conform_link "$DATA_DIR/$dotfile"".$dotfile";done# TODO: refactor with suffix variables (or common cron values)case"$PLATFORM"in
linux)
#conform_link "$CONF_DIR/shell/zshenv" ".zshenv"
crontab -l >$ROOT_DIR/tmp/crontab-conflict-arch
cd$ROOT_DIR/$CONF_DIR/cron
if [[ "$(diff ~/tmp/crontab-conflict-arch crontab-current-arch)"==""
]];then# no difference with current backup
logger "$LOG_PREFIX: crontab live settings match stored "\
"settings; no restore required"
rm ~/tmp/crontab-conflict-arch
else# current crontab settings in file do not match live settings
crontab $ROOT_DIR/$CONF_DIR/cron/crontab-current-arch
logger "$LOG_PREFIX: crontab stored settings conflict with "\
"live settings; stored settings restored. "\
"Previous settings recorded in ~/tmp/crontab-conflict-arch."fi
;;
C
#defineUNICODE
#include<windows.h>intmain(int argc, char **argv) {
int speed = 0, speed1 = 0, speed2 = 0; // 1-20printf("Set Mouse Speed by Maverick\n");
SystemParametersInfo(SPI_GETMOUSESPEED, 0, &speed, 0);
printf("Current speed: %2d\n", speed);
if (argc == 1) return0;
if (argc >= 2) sscanf(argv[1], "%d", &speed1);
if (argc >= 3) sscanf(argv[2], "%d", &speed2);
if (argc == 2) // set speed to first value
speed = speed1;
elseif (speed == speed1 || speed == speed2) // alternate
speed = speed1 + speed2 - speed;
else
speed = speed1; // start with first valueSystemParametersInfo(SPI_SETMOUSESPEED, 0, speed, 0);
SystemParametersInfo(SPI_GETMOUSESPEED, 0, &speed, 0);
printf("New speed: %2d\n", speed);
return0;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>A Tiny Page</title><!-- Valid HTML Comment --><styletype="text/css">
<!-- Invalid HTML Comment -->/* Inline CSS Comment */
p {
font-size: 15pt;
color:#000;
float:right;
}
</style></head><bodybgcolor="#FFFFFF" text="#000000" link="#0000CC"><h1>Heading 1</h1><h2>Heading 2</h2><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><!-- Valid HTML Comment --><scriptlanguage="javascript" type="text/javascript">functionchangeHeight(h){vartds=document.getElementsByTagName("td");for(vari=0;i<tds.length;i++){tds[i].setAttribute("height",h+"px");}}</script></body></html>
Java
importjava.util.Map;
importjava.util.TreeSet;
publicclassGetEnv {
/** * let's test generics * @param args the command line arguments */publicstaticvoidmain(String[] args) {
// get a map of environment variablesMap<String, String> env = System.getenv();
// build a sorted set out of the keys and iteratefor(Stringk: newTreeSet<String>(env.keySet())) {
System.out.printf("%s = %s\n", k, env.get(k));
}
}
}
# Inline Python CommentclassExitNotifyThread(Thread):
""" Block-Level Python Comment """defrun(self):
globalexitthreads, profiledirself.threadid=thread.get_ident()
try:
ifnotprofiledir: # normal caseThread.run(self)
else:
try:
importcProfileasprofileexceptImportError:
importprofileprof=profile.Profile()
try:
prof=prof.runctx("Thread.run(self)", globals(), locals())
exceptSystemExit:
passprof.dump_stats( \
profiledir+"/"+str(self.threadid) +"_"+ \
self.getName() +".prof")
except:
self.setExitCause('EXCEPTION')
ifsys:
self.setExitException(sys.exc_info()[1])
tb=traceback.format_exc()
self.setExitStackTrace(tb)
else:
self.setExitCause('NORMAL')
ifnothasattr(self, 'exitmessage'):
self.setExitMessage(None)
ifexitthreads:
exitthreads.put(self, True)
defsetExitCause(self, cause):
self.exitcause=causedefgetExitCause(self):
"""Returns the cause of the exit, one of: 'EXCEPTION' -- the thread aborted because of an exception 'NORMAL' -- normal termination."""returnself.exitcausedefsetExitException(self, exc):
self.exitexception=excdefgetExitException(self):
"""If getExitCause() is 'EXCEPTION', holds the value from sys.exc_info()[1] for this exception."""returnself.exitexceptiondefsetExitStackTrace(self, st):
self.exitstacktrace=stdefgetExitStackTrace(self):
"""If getExitCause() is 'EXCEPTION', returns a string representing the stack trace for this exception."""returnself.exitstacktracedefsetExitMessage(self, msg):
"""Sets the exit message to be fetched by a subsequent call to getExitMessage. This message may be any object or type except None."""self.exitmessage=msgdefgetExitMessage(self):
"""For any exit cause, returns the message previously set by a call to setExitMessage(), or None if there was no such message set."""returnself.exitmessage
Ruby
desc"Edit a post (defaults to most recent)"task:edit_post,:titledo |t,args|
args.with_defaults(:title=>false)posts=Dir.glob("#{source_dir}/#{posts_dir}/*.*")post=(args.title) ? post=posts.keep_if{|post| post =~ /#{args.title}/}.last : posts.lastifpostputs"Opening #{post} with #{editor}..."system"#{ENV['EDITOR']}#{post} &"elseputs"No posts were found with \"#{args.title}\" in the title."endend